From: Neil Roberts Date: Thu, 1 Jul 2010 10:07:03 +0000 (+0100) Subject: Move _cogl_texture_2d_is_pot to cogl-util.h X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=423f7128711ee891ef88f18a6b7bb1d28850ac55;p=profile%2Fivi%2Fclutter.git Move _cogl_texture_2d_is_pot to cogl-util.h This function could be used in many places in Cogl so it makes sense to share it in cogl-util.h as _cogl_util_is_pot(). --- diff --git a/clutter/cogl/cogl/cogl-texture-2d.c b/clutter/cogl/cogl/cogl-texture-2d.c index 6a42e1e..bfec5df 100644 --- a/clutter/cogl/cogl/cogl-texture-2d.c +++ b/clutter/cogl/cogl/cogl-texture-2d.c @@ -159,13 +159,6 @@ _cogl_texture_2d_free (CoglTexture2D *tex_2d) } static gboolean -_cogl_texture_2d_is_pot (unsigned int num) -{ - /* Make sure there is only one bit set */ - return (num & (num - 1)) == 0; -} - -static gboolean _cogl_texture_2d_can_create (unsigned int width, unsigned int height, CoglPixelFormat internal_format) @@ -183,8 +176,8 @@ _cogl_texture_2d_can_create (unsigned int width, /* If NPOT textures aren't supported then the size must be a power of two */ if (!cogl_features_available (COGL_FEATURE_TEXTURE_NPOT) && - (!_cogl_texture_2d_is_pot (width) || - !_cogl_texture_2d_is_pot (height))) + (!_cogl_util_is_pot (width) || + !_cogl_util_is_pot (height))) return FALSE; _cogl_pixel_format_to_gl (internal_format, diff --git a/clutter/cogl/cogl/cogl-util.h b/clutter/cogl/cogl/cogl-util.h index 9d399ea..f63863a 100644 --- a/clutter/cogl/cogl/cogl-util.h +++ b/clutter/cogl/cogl/cogl-util.h @@ -60,4 +60,12 @@ cogl_util_float_signbit (float x) negative numbers. */ #define COGL_UTIL_NEARBYINT(x) ((int) ((x) < 0.0f ? (x) - 0.5f : (x) + 0.5f)) +/* Returns whether the given integer is a power of two */ +static inline gboolean +_cogl_util_is_pot (unsigned int num) +{ + /* Make sure there is only one bit set */ + return (num & (num - 1)) == 0; +} + #endif /* __COGL_UTIL_H */