[cairo] fbcompose.c: Help wanted, and an xserver patch

Billy Biggs vektor at dumbterm.net
Fri Aug 5 23:59:48 PDT 2005


  The latest code in xserver causes three cairo test failures:

  1. composite-integer-translate-over

     I tracked this one down to a precision error in the bilinear
     interpolation code in xserver.  A patch for xserver is attached.
     The fix does the dumb code, and could be made to look nicer
     depending on what you think is good style.  Could someone here
     review this change, or know where I should post the patch?

  2. mask-image
  3. trap-clip

     In both of these cases, it's only a few pixels that are off by a
     small amount.  I've tried to track down the problem, but all of the
     code that seems to be hit in these cases is really sane.  Either
     the new result is correct, or it's a well hidden problem.

  If anyone's up for a challenge, I'd really like some help with solving
those two failures.  My latest patch to libpixman from HEAD is attached.
This new patch simply deletes iccompose.c for the new fbcompose.c.

  -Billy

-------------- next part --------------
A non-text attachment was scrubbed...
Name: iccompose-latest4.diff.gz
Type: application/x-gunzip
Size: 26888 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050806/0f3ebe46/iccompose-latest4.diff.bin
-------------- next part --------------
Index: fb/fbcompose.c
===================================================================
RCS file: /cvs/xserver/xserver/fb/fbcompose.c,v
retrieving revision 1.34
diff -p -u -r1.34 fbcompose.c
--- fb/fbcompose.c	1 Aug 2005 19:40:34 -0000	1.34
+++ fb/fbcompose.c	6 Aug 2005 06:33:59 -0000
@@ -2963,9 +2963,9 @@ static void fbFetchTransformed(PicturePt
                     if (!v.vector[2]) {
                         buffer[i] = 0;
                     } else {
-                        int x1, x2, y1, y2, distx, idistx, disty, idisty;
+                        int x1, x2, y1, y2, distx, idistx, disty, idisty, k;
                         FbBits *b;
-                        CARD32 tl, tr, bl, br;
+                        CARD32 tl, tr, bl, br, r;
                         xFixed_48_16 div;
 
                         div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
@@ -2993,10 +2993,13 @@ static void fbFetchTransformed(PicturePt
                         bl = fetch(b, x1 + pict->pDrawable->x, indexed);
                         br = fetch(b, x2 + pict->pDrawable->x, indexed);
 
-                        FbByteAddMul_256(tl, idistx, tr, distx);
-                        FbByteAddMul_256(bl, idistx, br, distx);
-                        FbByteAddMul_256(tl, idisty, bl, disty);
-                        buffer[i] = tl;
+                        for (k = 0; k < 4; k++) {
+                            CARD32 t, b;
+                            t = (((CARD8*)&tl)[k] * idistx) + (((CARD8*)&tr)[k] * distx);
+                            b = (((CARD8*)&bl)[k] * idistx) + (((CARD8*)&br)[k] * distx);
+                            ((CARD8*) &r)[k] = (((t * idisty) + (b * disty)) >> 16) & 0xff;
+                        }
+                        buffer[i] = r;
                     }
                     v.vector[0] += unit.vector[0];
                     v.vector[1] += unit.vector[1];
@@ -3007,9 +3010,9 @@ static void fbFetchTransformed(PicturePt
                     if (!v.vector[2]) {
                         buffer[i] = 0;
                     } else {
-                        int x1, x2, y1, y2, distx, idistx, disty, idisty;
+                        int x1, x2, y1, y2, distx, idistx, disty, idisty, k;
                         FbBits *b;
-                        CARD32 tl, tr, bl, br;
+                        CARD32 tl, tr, bl, br, r;
                         xFixed_48_16 div;
 
                         div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
@@ -3041,10 +3044,13 @@ static void fbFetchTransformed(PicturePt
                         br = POINT_IN_REGION(0, pict->pCompositeClip, x2, y2, &box)
                              ? fetch(b, x2 + pict->pDrawable->x, indexed) : 0;
 
-                        FbByteAddMul_256(tl, idistx, tr, distx);
-                        FbByteAddMul_256(bl, idistx, br, distx);
-                        FbByteAddMul_256(tl, idisty, bl, disty);
-                        buffer[i] = tl;
+                        for (k = 0; k < 4; k++) {
+                            CARD32 t, b;
+                            t = (((CARD8*)&tl)[k] * idistx) + (((CARD8*)&tr)[k] * distx);
+                            b = (((CARD8*)&bl)[k] * idistx) + (((CARD8*)&br)[k] * distx);
+                            ((CARD8*) &r)[k] = (((t * idisty) + (b * disty)) >> 16) & 0xff;
+                        }
+                        buffer[i] = r;
                     }
                     v.vector[0] += unit.vector[0];
                     v.vector[1] += unit.vector[1];
@@ -3058,9 +3064,9 @@ static void fbFetchTransformed(PicturePt
                     if (!v.vector[2]) {
                         buffer[i] = 0;
                     } else {
-                        int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
+                        int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off, k;
                         FbBits *b;
-                        CARD32 tl, tr, bl, br;
+                        CARD32 tl, tr, bl, br, r;
                         Bool x1_out, x2_out, y1_out, y2_out;
                         xFixed_48_16 div;
 
@@ -3090,10 +3096,13 @@ static void fbFetchTransformed(PicturePt
                         bl = x1_out|y2_out ? 0 : fetch(b, x_off, indexed);
                         br = x2_out|y2_out ? 0 : fetch(b, x_off + 1, indexed);
 
-                        FbByteAddMul_256(tl, idistx, tr, distx);
-                        FbByteAddMul_256(bl, idistx, br, distx);
-                        FbByteAddMul_256(tl, idisty, bl, disty);
-                        buffer[i] = tl;
+                        for (k = 0; k < 4; k++) {
+                            CARD32 t, b;
+                            t = (((CARD8*)&tl)[k] * idistx) + (((CARD8*)&tr)[k] * distx);
+                            b = (((CARD8*)&bl)[k] * idistx) + (((CARD8*)&br)[k] * distx);
+                            ((CARD8*) &r)[k] = (((t * idisty) + (b * disty)) >> 16) & 0xff;
+                        }
+                        buffer[i] = r;
                     }
                     v.vector[0] += unit.vector[0];
                     v.vector[1] += unit.vector[1];
@@ -3104,9 +3113,9 @@ static void fbFetchTransformed(PicturePt
                     if (!v.vector[2]) {
                         buffer[i] = 0;
                     } else {
-                        int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off;
+                        int x1, x2, y1, y2, distx, idistx, disty, idisty, x_off, k;
                         FbBits *b;
-                        CARD32 tl, tr, bl, br;
+                        CARD32 tl, tr, bl, br, r;
                         xFixed_48_16 div;
 
                         div = ((xFixed_48_16)v.vector[0] << 16)/v.vector[2];
@@ -3134,10 +3143,13 @@ static void fbFetchTransformed(PicturePt
                         br = POINT_IN_REGION(0, pict->pCompositeClip, x2, y2, &box)
                              ? fetch(b, x_off + 1, indexed) : 0;
 
-                        FbByteAddMul_256(tl, idistx, tr, distx);
-                        FbByteAddMul_256(bl, idistx, br, distx);
-                        FbByteAddMul_256(tl, idisty, bl, disty);
-                        buffer[i] = tl;
+                        for (k = 0; k < 4; k++) {
+                            CARD32 t, b;
+                            t = (((CARD8*)&tl)[k] * idistx) + (((CARD8*)&tr)[k] * distx);
+                            b = (((CARD8*)&bl)[k] * idistx) + (((CARD8*)&br)[k] * distx);
+                            ((CARD8*) &r)[k] = (((t * idisty) + (b * disty)) >> 16) & 0xff;
+                        }
+                        buffer[i] = r;
                     }
                     v.vector[0] += unit.vector[0];
                     v.vector[1] += unit.vector[1];


More information about the cairo mailing list