Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-12-16 13:25:07 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-12-16 13:25:07 +0400
commit2253b63c979fbfbbb6f06c93ede85d9b9b6caddf (patch)
tree6fe58202f96a7edd8448d7fbf17a14df6098d0f7 /source/blender/windowmanager/intern/wm_draw.c
parent91f14ddf3da140156c722e347b6f188210903629 (diff)
static functions for getting power of 2 values were being copied about too much, add to the BLI_math api.
- is_power_of_2_i - power_of_2_min_i - power_of_2_max_i
Diffstat (limited to 'source/blender/windowmanager/intern/wm_draw.c')
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c35
1 files changed, 6 insertions, 29 deletions
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index f03680852ea..4fe11044d30 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -43,6 +43,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BLI_math_base.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -355,36 +356,12 @@ typedef struct wmDrawTriple {
GLenum target;
} wmDrawTriple;
-static int is_pow2(int n)
-{
- return ((n)&(n-1))==0;
-}
-
-static int smaller_pow2(int n)
-{
- while (!is_pow2(n))
- n= n&(n-1);
-
- return n;
-}
-
-static int larger_pow2(int n)
-{
- if (is_pow2(n))
- return n;
-
- while(!is_pow2(n))
- n= n&(n-1);
-
- return n*2;
-}
-
static void split_width(int x, int n, int *splitx, int *nx)
{
int a, newnx, waste;
/* if already power of two just use it */
- if(is_pow2(x)) {
+ if(is_power_of_2_i(x)) {
splitx[0]= x;
(*nx)++;
return;
@@ -392,12 +369,12 @@ static void split_width(int x, int n, int *splitx, int *nx)
if(n == 1) {
/* last part, we have to go larger */
- splitx[0]= larger_pow2(x);
+ splitx[0]= power_of_2_max_i(x);
(*nx)++;
}
else {
/* two or more parts to go, use smaller part */
- splitx[0]= smaller_pow2(x);
+ splitx[0]= power_of_2_min_i(x);
newnx= ++(*nx);
split_width(x-splitx[0], n-1, splitx+1, &newnx);
@@ -406,8 +383,8 @@ static void split_width(int x, int n, int *splitx, int *nx)
/* if we waste more space or use the same amount,
* revert deeper splits and just use larger */
- if(waste >= larger_pow2(x)) {
- splitx[0]= larger_pow2(x);
+ if(waste >= power_of_2_max_i(x)) {
+ splitx[0]= power_of_2_max_i(x);
memset(splitx+1, 0, sizeof(int)*(n-1));
}
else