diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-08-23 20:56:11 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-12-17 16:57:18 -0500 |
commit | a2afcc9ba4ed5a2843fd133ca23704960846185b (patch) | |
tree | 67fc649591d5399c0357b39790dc217f61c2a627 /test | |
parent | 4d8d2fa47e457e3c8a5ab956b52cff4785aa45c3 (diff) |
test: Make composite test use some existing macros instead of defining its own
Also move the ARRAY_LENGTH macro into utils.h so it can be used elsewhere.
Diffstat (limited to 'test')
-rw-r--r-- | test/composite.c | 56 | ||||
-rw-r--r-- | test/utils.h | 2 |
2 files changed, 28 insertions, 30 deletions
diff --git a/test/composite.c b/test/composite.c index 5cdc521..e14f954 100644 --- a/test/composite.c +++ b/test/composite.c @@ -31,10 +31,6 @@ #include <time.h> #include "utils.h" -#define ARRAY_LENGTH(A) ((int) (sizeof (A) / sizeof ((A) [0]))) -#define min(a,b) ((a) <= (b) ? (a) : (b)) -#define max(a,b) ((a) >= (b) ? (a) : (b)) - typedef struct color_t color_t; typedef struct format_t format_t; typedef struct image_t image_t; @@ -211,7 +207,7 @@ static const operator_t operators[] = static double calc_op (pixman_op_t op, double src, double dst, double srca, double dsta) { -#define mult_chan(src, dst, Fa, Fb) min ((src) * (Fa) + (dst) * (Fb), 1.0) +#define mult_chan(src, dst, Fa, Fb) MIN ((src) * (Fa) + (dst) * (Fb), 1.0) double Fa, Fb; @@ -267,150 +263,150 @@ calc_op (pixman_op_t op, double src, double dst, double srca, double dsta) if (srca == 0.0) Fa = 1.0; else - Fa = min (1.0, (1.0 - dsta) / srca); + Fa = MIN (1.0, (1.0 - dsta) / srca); return mult_chan (src, dst, Fa, 1.0); case PIXMAN_OP_DISJOINT_OVER: if (dsta == 0.0) Fb = 1.0; else - Fb = min (1.0, (1.0 - srca) / dsta); + Fb = MIN (1.0, (1.0 - srca) / dsta); return mult_chan (src, dst, 1.0, Fb); case PIXMAN_OP_DISJOINT_IN: if (srca == 0.0) Fa = 0.0; else - Fa = max (0.0, 1.0 - (1.0 - dsta) / srca); + Fa = MAX (0.0, 1.0 - (1.0 - dsta) / srca); return mult_chan (src, dst, Fa, 0.0); case PIXMAN_OP_DISJOINT_IN_REVERSE: if (dsta == 0.0) Fb = 0.0; else - Fb = max (0.0, 1.0 - (1.0 - srca) / dsta); + Fb = MAX (0.0, 1.0 - (1.0 - srca) / dsta); return mult_chan (src, dst, 0.0, Fb); case PIXMAN_OP_DISJOINT_OUT: if (srca == 0.0) Fa = 1.0; else - Fa = min (1.0, (1.0 - dsta) / srca); + Fa = MIN (1.0, (1.0 - dsta) / srca); return mult_chan (src, dst, Fa, 0.0); case PIXMAN_OP_DISJOINT_OUT_REVERSE: if (dsta == 0.0) Fb = 1.0; else - Fb = min (1.0, (1.0 - srca) / dsta); + Fb = MIN (1.0, (1.0 - srca) / dsta); return mult_chan (src, dst, 0.0, Fb); case PIXMAN_OP_DISJOINT_ATOP: if (srca == 0.0) Fa = 0.0; else - Fa = max (0.0, 1.0 - (1.0 - dsta) / srca); + Fa = MAX (0.0, 1.0 - (1.0 - dsta) / srca); if (dsta == 0.0) Fb = 1.0; else - Fb = min (1.0, (1.0 - srca) / dsta); + Fb = MIN (1.0, (1.0 - srca) / dsta); return mult_chan (src, dst, Fa, Fb); case PIXMAN_OP_DISJOINT_ATOP_REVERSE: if (srca == 0.0) Fa = 1.0; else - Fa = min (1.0, (1.0 - dsta) / srca); + Fa = MIN (1.0, (1.0 - dsta) / srca); if (dsta == 0.0) Fb = 0.0; else - Fb = max (0.0, 1.0 - (1.0 - srca) / dsta); + Fb = MAX (0.0, 1.0 - (1.0 - srca) / dsta); return mult_chan (src, dst, Fa, Fb); case PIXMAN_OP_DISJOINT_XOR: if (srca == 0.0) Fa = 1.0; else - Fa = min (1.0, (1.0 - dsta) / srca); + Fa = MIN (1.0, (1.0 - dsta) / srca); if (dsta == 0.0) Fb = 1.0; else - Fb = min (1.0, (1.0 - srca) / dsta); + Fb = MIN (1.0, (1.0 - srca) / dsta); return mult_chan (src, dst, Fa, Fb); case PIXMAN_OP_CONJOINT_OVER: if (dsta == 0.0) Fb = 0.0; else - Fb = max (0.0, 1.0 - srca / dsta); + Fb = MAX (0.0, 1.0 - srca / dsta); return mult_chan (src, dst, 1.0, Fb); case PIXMAN_OP_CONJOINT_OVER_REVERSE: if (srca == 0.0) Fa = 0.0; else - Fa = max (0.0, 1.0 - dsta / srca); + Fa = MAX (0.0, 1.0 - dsta / srca); return mult_chan (src, dst, Fa, 1.0); case PIXMAN_OP_CONJOINT_IN: if (srca == 0.0) Fa = 1.0; else - Fa = min (1.0, dsta / srca); + Fa = MIN (1.0, dsta / srca); return mult_chan (src, dst, Fa, 0.0); case PIXMAN_OP_CONJOINT_IN_REVERSE: if (dsta == 0.0) Fb = 1.0; else - Fb = min (1.0, srca / dsta); + Fb = MIN (1.0, srca / dsta); return mult_chan (src, dst, 0.0, Fb); case PIXMAN_OP_CONJOINT_OUT: if (srca == 0.0) Fa = 0.0; else - Fa = max (0.0, 1.0 - dsta / srca); + Fa = MAX (0.0, 1.0 - dsta / srca); return mult_chan (src, dst, Fa, 0.0); case PIXMAN_OP_CONJOINT_OUT_REVERSE: if (dsta == 0.0) Fb = 0.0; else - Fb = max (0.0, 1.0 - srca / dsta); + Fb = MAX (0.0, 1.0 - srca / dsta); return mult_chan (src, dst, 0.0, Fb); case PIXMAN_OP_CONJOINT_ATOP: if (srca == 0.0) Fa = 1.0; else - Fa = min (1.0, dsta / srca); + Fa = MIN (1.0, dsta / srca); if (dsta == 0.0) Fb = 0.0; else - Fb = max (0.0, 1.0 - srca / dsta); + Fb = MAX (0.0, 1.0 - srca / dsta); return mult_chan (src, dst, Fa, Fb); case PIXMAN_OP_CONJOINT_ATOP_REVERSE: if (srca == 0.0) Fa = 0.0; else - Fa = max (0.0, 1.0 - dsta / srca); + Fa = MAX (0.0, 1.0 - dsta / srca); if (dsta == 0.0) Fb = 1.0; else - Fb = min (1.0, srca / dsta); + Fb = MIN (1.0, srca / dsta); return mult_chan (src, dst, Fa, Fb); case PIXMAN_OP_CONJOINT_XOR: if (srca == 0.0) Fa = 0.0; else - Fa = max (0.0, 1.0 - dsta / srca); + Fa = MAX (0.0, 1.0 - dsta / srca); if (dsta == 0.0) Fb = 0.0; else - Fb = max (0.0, 1.0 - srca / dsta); + Fb = MAX (0.0, 1.0 - srca / dsta); return mult_chan (src, dst, Fa, Fb); case PIXMAN_OP_MULTIPLY: @@ -617,7 +613,7 @@ eval_diff (color_t *expected, color_t *test, pixman_format_code_t format) gdiff = fabs (test->b - expected->b) * bscale; adiff = fabs (test->a - expected->a) * ascale; - return max (max (max (rdiff, gdiff), bdiff), adiff); + return MAX (MAX (MAX (rdiff, gdiff), bdiff), adiff); } static char * diff --git a/test/utils.h b/test/utils.h index e7920f0..2ea4170 100644 --- a/test/utils.h +++ b/test/utils.h @@ -3,6 +3,8 @@ #include <assert.h> #include "pixman-private.h" /* For 'inline' definition */ +#define ARRAY_LENGTH(A) ((int) (sizeof (A) / sizeof ((A) [0]))) + /* A primitive pseudorandom number generator, * taken from POSIX.1-2001 example */ |