diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-02-18 19:17:49 +0100 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2013-02-18 19:17:49 +0100 |
commit | 67355db150b683f02443e5b0ece97c0567c90c3a (patch) | |
tree | 56479bb61299016e368371d47dbc2f7e8e41d4ea /src/text_gltex.c | |
parent | dd13dd06ee53574ec92c800d415984bf00ac2ca6 (diff) |
shl: misc: provide shl_next_pow2()
Move the next_pow2() helper to shl_misc.h so we can use it everywhere.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Diffstat (limited to 'src/text_gltex.c')
-rw-r--r-- | src/text_gltex.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/text_gltex.c b/src/text_gltex.c index 3151ec6..9e864a0 100644 --- a/src/text_gltex.c +++ b/src/text_gltex.c @@ -48,6 +48,7 @@ #include "log.h" #include "shl_dlist.h" #include "shl_hashtable.h" +#include "shl_misc.h" #include "static_gl.h" #include "text.h" #include "uterm_video.h" @@ -263,20 +264,6 @@ static void gltex_unset(struct kmscon_text *txt) } } -static unsigned int next_pow2(unsigned int num) -{ - int i; - - if (!num) - return num; - - --num; - for (i = 1; i < sizeof(unsigned int) * CHAR_BIT; i <<= 1) - num = num | num >> i; - - return num + 1; -} - /* returns an atlas with at least 1 free glyph position; NULL on error */ static struct atlas *get_atlas(struct kmscon_text *txt, unsigned int num) { @@ -318,8 +305,8 @@ static struct atlas *get_atlas(struct kmscon_text *txt, unsigned int num) * valid texture size that is big enough to hold as many glyphs as * possible but at least 1 */ try_next: - width = next_pow2(FONT_WIDTH(txt) * newsize); - height = next_pow2(FONT_HEIGHT(txt)); + width = shl_next_pow2(FONT_WIDTH(txt) * newsize); + height = shl_next_pow2(FONT_HEIGHT(txt)); gl_clear_error(); |