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().
This commit is contained in:
parent
31c127bfa7
commit
423f712871
@ -158,13 +158,6 @@ _cogl_texture_2d_free (CoglTexture2D *tex_2d)
|
||||
_cogl_texture_free (COGL_TEXTURE (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,
|
||||
@ -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,
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user