Move _cogl_texture_2d_is_pot to cogl-util.h
authorNeil Roberts <neil@linux.intel.com>
Thu, 1 Jul 2010 10:07:03 +0000 (11:07 +0100)
committerNeil Roberts <neil@linux.intel.com>
Tue, 13 Jul 2010 13:28:35 +0000 (14:28 +0100)
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().

clutter/cogl/cogl/cogl-texture-2d.c
clutter/cogl/cogl/cogl-util.h

index 6a42e1e..bfec5df 100644 (file)
@@ -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,
index 9d399ea..f63863a 100644 (file)
@@ -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 */