[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Boxygen-gtk/1=2E0=5D_src=3A_use_switch_statement_rat?=
From: Hugo Pereira Da Costa <hugo () oxygen-icons ! org>
Date: 2011-01-31 21:35:02
Message-ID: 20110131213502.E35C8A6094 () git ! kde ! org
[Download RAW message or body]
Git commit f90a60c647120d4580c774abd5c3c2521c28a95a by Hugo Pereira Da \
Costa. Pushed by hpereiradacosta into branch '1.0'.
use switch statement rather than "if" in cairo_surface_get_width/get_height
M +28 -16 src/oxygencairoutils.cpp
M +5 -2 src/oxygencairoutils.h
http://commits.kde.org/d1a86b4e/f90a60c647120d4580c774abd5c3c2521c28a95a
diff --git a/src/oxygencairoutils.cpp b/src/oxygencairoutils.cpp
index a7e2633..08cf352 100644
--- a/src/oxygencairoutils.cpp
+++ b/src/oxygencairoutils.cpp
@@ -160,34 +160,46 @@ namespace Oxygen
//_____________________________________________________
int cairo_surface_get_width( cairo_surface_t* surface )
{
- cairo_surface_type_t type=cairo_surface_get_type(surface);
- if(type==CAIRO_SURFACE_TYPE_IMAGE)
+ const cairo_surface_type_t type( cairo_surface_get_type(surface) \
); + switch( type )
+ {
+
+ case CAIRO_SURFACE_TYPE_IMAGE:
return cairo_image_surface_get_width(surface);
- else if(type==CAIRO_SURFACE_TYPE_XLIB)
+
+ case CAIRO_SURFACE_TYPE_XLIB:
return cairo_xlib_surface_get_width(surface);
- else
- {
- printf("returning -1 width, type: %d\n",type);
+
+ default:
+ // FIXME: we don't expect any surfaces other than Image and \
Xlib + // Do we need to implement a cairo_create + \
cairo_clip_extents fallback for unexpected surfaces? + std::cerr \
<< "Oxygen::cairo_surface_get_width - unsupported type " << type << \
std::endl; return -1;
+
}
- // FIXME: we don't expect any surfaces other than Image and Xlib
- // Do we need to implement a cairo_create + cairo_clip_extents \
fallback for unexpected surfaces? +
}
//_____________________________________________________
int cairo_surface_get_height( cairo_surface_t* surface )
{
- cairo_surface_type_t type=cairo_surface_get_type(surface);
- if(type==CAIRO_SURFACE_TYPE_IMAGE)
+ const cairo_surface_type_t type( cairo_surface_get_type(surface) \
); + switch( type )
+ {
+ case CAIRO_SURFACE_TYPE_IMAGE:
return cairo_image_surface_get_height(surface);
- else if(type==CAIRO_SURFACE_TYPE_XLIB)
+
+ case CAIRO_SURFACE_TYPE_XLIB:
return cairo_xlib_surface_get_height(surface);
- else
- {
- printf("returning -1 width, type: %d\n",type);
+
+ default:
+ // FIXME: we don't expect any surfaces other than Image and \
Xlib + // Do we need to implement a cairo_create + \
cairo_clip_extents fallback for unexpected surfaces? + std::cerr \
<< "Oxygen::cairo_surface_get_height - unsupported type " << type << \
std::endl; return -1;
+
}
- // FIXME: we don't expect any surfaces other than Image and Xlib
- // Do we need to implement a cairo_create + cairo_clip_extents \
fallback for unexpected surfaces? +
}
+
}
diff --git a/src/oxygencairoutils.h b/src/oxygencairoutils.h
index 3d6276b..7784837 100644
--- a/src/oxygencairoutils.h
+++ b/src/oxygencairoutils.h
@@ -116,8 +116,11 @@ namespace Oxygen
//@}
- int cairo_surface_get_width(cairo_surface_t* surface);
- int cairo_surface_get_height(cairo_surface_t* surface);
+ //! get width for surface
+ int cairo_surface_get_width( cairo_surface_t* );
+
+ //! get height for surface
+ int cairo_surface_get_height( cairo_surface_t* );
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic