From 4df446bb73b1ab89e119d6714a3feae8a384e113 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann?= Date: Sat, 19 May 2007 17:19:39 -0400 Subject: [PATCH] Move mod and div macros to pixman-private.h --- TODO | 2 +- pixman/pixman-compose.c | 6 ------ pixman/pixman-pict.c | 13 ++++--------- pixman/pixman-private.h | 10 ++++++++++ 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/TODO b/TODO index 2ccc28d..4bc4895 100644 --- a/TODO +++ b/TODO @@ -25,7 +25,7 @@ have to be kept uptodate every time something changes about the picture. - - Break the X server ABI and simply have the releveant parameter + - Break the X server ABI and simply have the relevant parameter stored in the pixman image. This would have the additional benefits that: diff --git a/pixman/pixman-compose.c b/pixman/pixman-compose.c index 50fa29e..ea153a4 100644 --- a/pixman/pixman-compose.c +++ b/pixman/pixman-compose.c @@ -109,8 +109,6 @@ SourcePictureClassify (source_image_t *pict, return pict->class; } -#define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) - #define SCANLINE_BUFFER_LENGTH 2048 typedef FASTCALL void (*fetchProc)(pixman_image_t *image, @@ -3036,10 +3034,6 @@ static void fbFetch(bits_image_t * pict, int x, int y, int width, uint32_t *buff fetch((pixman_image_t *)pict, bits, x, width, buffer, indexed); } -#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b)) -#define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) : \ - ((a) - (b) + 1 - (((b) < 0) << 1)) / (b)) - typedef struct { uint32_t left_ag; diff --git a/pixman/pixman-pict.c b/pixman/pixman-pict.c index f5d3991..5c4fe7a 100644 --- a/pixman/pixman-pict.c +++ b/pixman/pixman-pict.c @@ -918,8 +918,6 @@ fbCompositeSolidMask_nx1xn (pixman_op_t op, #endif } -# define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) - /* * Apply a constant alpha value in an over computation */ @@ -1013,9 +1011,6 @@ compute_composite_region (pixman_region16_t *region, return TRUE; } - -#define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) - static void pixman_walk_composite_region (pixman_op_t op, pixman_image_t * pSrc, @@ -1059,13 +1054,13 @@ pixman_walk_composite_region (pixman_op_t op, x_dst = pbox->x1; if (maskRepeat) { - y_msk = mod (y_msk, pMask->bits.height); + y_msk = MOD (y_msk, pMask->bits.height); if (h_this > pMask->bits.height - y_msk) h_this = pMask->bits.height - y_msk; } if (srcRepeat) { - y_src = mod (y_src, pSrc->bits.height); + y_src = MOD (y_src, pSrc->bits.height); if (h_this > pSrc->bits.height - y_src) h_this = pSrc->bits.height - y_src; } @@ -1074,13 +1069,13 @@ pixman_walk_composite_region (pixman_op_t op, w_this = w; if (maskRepeat) { - x_msk = mod (x_msk, pMask->bits.width); + x_msk = MOD (x_msk, pMask->bits.width); if (w_this > pMask->bits.width - x_msk) w_this = pMask->bits.width - x_msk; } if (srcRepeat) { - x_src = mod (x_src, pSrc->bits.width); + x_src = MOD (x_src, pSrc->bits.width); if (w_this > pSrc->bits.width - x_src) w_this = pSrc->bits.width - x_src; } diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index fbb8cb7..8b42e62 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -490,6 +490,16 @@ void pixmanCompositeRect (const FbComposeData *data, #define div_255(x) (((x) + 0x80 + (((x) + 0x80) >> 8)) >> 8) +#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b)) + +#define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) : \ + ((a) - (b) + 1 - (((b) < 0) << 1)) / (b)) + +#if 0 +/* FIXME: the MOD macro above is equivalent, but faster I think */ +#define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) +#endif + /* FIXME: the (void)__read_func hides lots of warnings (which is what they * are supposed to do), but some of them are real. For example the one * where Fetch4 doesn't have a READ -- 2.7.4