projects
/
profile
/
ivi
/
clutter.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ee7ebe0
)
cogl-texture-2d: Optimise _cogl_texture_2d_is_pot
author
Neil Roberts
<neil@linux.intel.com>
Thu, 20 May 2010 11:37:56 +0000
(12:37 +0100)
committer
Neil Roberts
<neil@linux.intel.com>
Thu, 20 May 2010 11:40:59 +0000
(12:40 +0100)
This takes the simple algorithm from here:
http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2
This avoids a loop and is much faster.
clutter/cogl/cogl/cogl-texture-2d.c
patch
|
blob
|
history
diff --git
a/clutter/cogl/cogl/cogl-texture-2d.c
b/clutter/cogl/cogl/cogl-texture-2d.c
index
044f75d
..
4ec2e0e
100644
(file)
--- a/
clutter/cogl/cogl/cogl-texture-2d.c
+++ b/
clutter/cogl/cogl/cogl-texture-2d.c
@@
-156,21
+156,8
@@
_cogl_texture_2d_free (CoglTexture2D *tex_2d)
static gboolean
_cogl_texture_2d_is_pot (unsigned int num)
{
- gboolean have_bit = FALSE;
-
/* Make sure there is only one bit set */
- while (num)
- {
- if (num & 1)
- {
- if (have_bit)
- return FALSE;
- have_bit = TRUE;
- }
- num >>= 1;
- }
-
- return TRUE;
+ return (num & (num - 1)) == 0;
}
static gboolean