[cairo-commit] libpixman/src ic.c, 1.15, 1.16 iccompose.c, 1.15,
1.16 icint.h, 1.21, 1.22
Carl Worth
commit at pdx.freedesktop.org
Wed Oct 27 07:26:38 PDT 2004
- Previous message: [cairo-commit] libpixman ChangeLog,1.24,1.25 NEWS,1.3,1.4
- Next message: [cairo-commit] libpixman .cvsignore, 1.2, 1.3 ChangeLog, 1.25,
1.26 Makefile.am, 1.2, 1.3 NEWS, 1.4, 1.5 RELEASING, 1.1,
1.2 TODO, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: cworth
Update of /cvs/cairo/libpixman/src
In directory gabe:/tmp/cvs-serv20533/src
Modified Files:
ic.c iccompose.c icint.h
Log Message:
* src/icint.h (MOD):
* src/iccompose.c (IcFetch_transform):
* src/ic.c (pixman_composite): Switch from two different buggy mod
macros to a new MOD macro which should work in C89 or C99.
Index: ic.c
===================================================================
RCS file: /cvs/cairo/libpixman/src/ic.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- ic.c 12 Sep 2004 02:27:59 -0000 1.15
+++ ic.c 27 Oct 2004 14:26:36 -0000 1.16
@@ -857,8 +857,6 @@
0x0);
}
-# define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
-
void
pixman_composite (pixman_operator_t op,
pixman_image_t *iSrc,
@@ -1103,13 +1101,13 @@
x_dst = pbox->x1;
if (maskRepeat)
{
- y_msk = mod (y_msk, iMask->pixels->height);
+ y_msk = MOD (y_msk, iMask->pixels->height);
if (h_this > iMask->pixels->height - y_msk)
h_this = iMask->pixels->height - y_msk;
}
if (srcRepeat)
{
- y_src = mod (y_src, iSrc->pixels->height);
+ y_src = MOD (y_src, iSrc->pixels->height);
if (h_this > iSrc->pixels->height - y_src)
h_this = iSrc->pixels->height - y_src;
}
@@ -1118,13 +1116,13 @@
w_this = w;
if (maskRepeat)
{
- x_msk = mod (x_msk, iMask->pixels->width);
+ x_msk = MOD (x_msk, iMask->pixels->width);
if (w_this > iMask->pixels->width - x_msk)
w_this = iMask->pixels->width - x_msk;
}
if (srcRepeat)
{
- x_src = mod (x_src, iSrc->pixels->width);
+ x_src = MOD (x_src, iSrc->pixels->width);
if (w_this > iSrc->pixels->width - x_src)
w_this = iSrc->pixels->width - x_src;
}
Index: iccompose.c
===================================================================
RCS file: /cvs/cairo/libpixman/src/iccompose.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- iccompose.c 12 Sep 2004 02:28:00 -0000 1.15
+++ iccompose.c 27 Oct 2004 14:26:36 -0000 1.16
@@ -2239,8 +2239,6 @@
(*op[2].store) (&op[2], value & 0xff000000);
}
-#define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (a) % (b) == 0 ? 0: (b) + (a) % (b))
-
static uint32_t
IcFetch_transform (pixman_compositeOperand *op)
{
@@ -2264,8 +2262,8 @@
x = xFixedToInt (v.vector[0]) + op->u.transform.left_x;
if (op->u.transform.repeat)
{
- y = mod (y, op->u.transform.height);
- x = mod (x, op->u.transform.width);
+ y = MOD (y, op->u.transform.height);
+ x = MOD (x, op->u.transform.width);
}
if (pixman_region_contains_point (op->clip, x, y, &box))
{
@@ -2292,7 +2290,7 @@
int tx, ty;
if (op->u.transform.repeat)
- ty = mod (y, op->u.transform.height);
+ ty = MOD (y, op->u.transform.height);
else
ty = y;
@@ -2300,7 +2298,7 @@
for (x = minx; x <= maxx; x++)
{
if (op->u.transform.repeat)
- tx = mod (x, op->u.transform.width);
+ tx = MOD (x, op->u.transform.width);
else
tx = x;
@@ -2363,8 +2361,8 @@
x = xFixedToInt (v.vector[0]) + op->u.transform.top_y;
if (op->u.transform.repeat)
{
- y = mod (y, op->u.transform.height);
- x = mod (x, op->u.transform.width);
+ y = MOD (y, op->u.transform.height);
+ x = MOD (x, op->u.transform.width);
}
if (pixman_region_contains_point (op->clip, x, y, &box))
{
@@ -2392,7 +2390,7 @@
int tx, ty;
if (op->u.transform.repeat)
- ty = mod (y, op->u.transform.height);
+ ty = MOD (y, op->u.transform.height);
else
ty = y;
@@ -2400,7 +2398,7 @@
for (x = minx; x <= maxx; x++)
{
if (op->u.transform.repeat)
- tx = mod (x, op->u.transform.width);
+ tx = MOD (x, op->u.transform.width);
else
tx = x;
Index: icint.h
===================================================================
RCS file: /cvs/cairo/libpixman/src/icint.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- icint.h 12 Sep 2004 02:55:24 -0000 1.21
+++ icint.h 27 Oct 2004 14:26:36 -0000 1.22
@@ -37,9 +37,17 @@
#include "slim_internal.h"
+/* C89 has implementation-defined behavior for % with negative operands.
+ C99 has well-defined behavior which is that / with integers rounds toward zero
+ and a%b is defined so that (a/b)*b + a%b == a.
+ The C99 version gives negative remainders rather than the modulus
+ in [0 .. b-1] that we want. This macro avoids using % with negative
+ operands to avoid both problems.
-
+ a and b are integers. b > 0.
+*/
+#define MOD(a, b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-(a) - 1) % (b) - 1)
typedef struct _IcPoint {
int16_t x,y ;
- Previous message: [cairo-commit] libpixman ChangeLog,1.24,1.25 NEWS,1.3,1.4
- Next message: [cairo-commit] libpixman .cvsignore, 1.2, 1.3 ChangeLog, 1.25,
1.26 Makefile.am, 1.2, 1.3 NEWS, 1.4, 1.5 RELEASING, 1.1,
1.2 TODO, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list