Fix bug in rasterizeEdges() where the stride was treated as if in
authorSøren Sandmann <sandmann@redhat.com>
Wed, 23 May 2007 19:39:03 +0000 (15:39 -0400)
committerSøren Sandmann <sandmann@redhat.com>
Wed, 23 May 2007 19:39:03 +0000 (15:39 -0400)
bytes, when it was in uint32_t's. Formatting fixes. Delete misleading
comment from pixman-private.h

pixman/pixman-edge-imp.h
pixman/pixman-private.h

index 6754305..f87bea4 100644 (file)
 #ifndef rasterizeSpan
 #endif
 
-#define GET_IMAGE(image)                       \
-    uint32_t *buf = (image)->bits.bits;                \
-    uint32_t stride = (image)->bits.rowstride; \
-    uint32_t width = (image)->bits.width;
-
 static void
 rasterizeEdges (pixman_image_t  *image,
                pixman_edge_t   *l,
@@ -39,114 +34,116 @@ rasterizeEdges (pixman_image_t  *image,
 {
     pixman_fixed_t  y = t;
     uint32_t  *line;
-    GET_IMAGE(image);
+    uint32_t *buf = (image)->bits.bits;
+    uint32_t stride = (image)->bits.rowstride;
+    uint32_t width = (image)->bits.width;
     
-    line = buf + pixman_fixed_to_int (y) * (stride / sizeof (uint32_t));
+    line = buf + pixman_fixed_to_int (y) * stride;
     
-       for (;;)
+    for (;;)
+    {
+       pixman_fixed_t  lx;
+       pixman_fixed_t      rx;
+       int     lxi;
+       int rxi;
+       
+       /* clip X */
+       lx = l->x;
+       if (lx < 0)
+           lx = 0;
+       rx = r->x;
+       if (pixman_fixed_to_int (rx) >= width)
+           rx = pixman_int_to_fixed (width);
+       
+       /* Skip empty (or backwards) sections */
+       if (rx > lx)
        {
-           pixman_fixed_t      lx;
-           pixman_fixed_t      rx;
-           int lxi;
-           int rxi;
            
-           /* clip X */
-           lx = l->x;
-           if (lx < 0)
-               lx = 0;
-           rx = r->x;
-           if (pixman_fixed_to_int (rx) >= width)
-               rx = pixman_int_to_fixed (width);
+           /* Find pixel bounds for span */
+           lxi = pixman_fixed_to_int (lx);
+           rxi = pixman_fixed_to_int (rx);
            
-           /* Skip empty (or backwards) sections */
-           if (rx > lx)
+#if N_BITS == 1
            {
+               uint32_t  *a = line;
+               uint32_t  startmask;
+               uint32_t  endmask;
+               int         nmiddle;
+               int         width = rxi - lxi;
+               int         x = lxi;
                
-               /* Find pixel bounds for span */
-               lxi = pixman_fixed_to_int (lx);
-               rxi = pixman_fixed_to_int (rx);
+               a += x >> FB_SHIFT;
+               x &= FB_MASK;
                
-#if N_BITS == 1
-               {
-                   uint32_t  *a = line;
-                   uint32_t  startmask;
-                   uint32_t  endmask;
-                   int     nmiddle;
-                   int     width = rxi - lxi;
-                   int     x = lxi;
-                   
-                   a += x >> FB_SHIFT;
-                   x &= FB_MASK;
-                   
-                   ACCESS_MEM(
-                       FbMaskBits (x, width, startmask, nmiddle, endmask);
-                       if (startmask) {
-                           WRITE(a, READ(a) | startmask);
-                           a++;
-                       }
-                       while (nmiddle--)
-                           WRITE(a++, FB_ALLONES);
-                       if (endmask)
-                           WRITE(a, READ(a) | endmask);
-                       );
-               }
+               FbMaskBits (x, width, startmask, nmiddle, endmask);
+               ACCESS_MEM(
+                   if (startmask) {
+                       WRITE(a, READ(a) | startmask);
+                       a++;
+                   }
+                   while (nmiddle--)
+                       WRITE(a++, FB_ALLONES);
+                   if (endmask)
+                       WRITE(a, READ(a) | endmask);
+                   );
+           }
 #else
-               {
-                   DefineAlpha(line,lxi);
-                   int     lxs;
-                   int     rxs;
-                   
-                   /* Sample coverage for edge pixels */
-                   lxs = RenderSamplesX (lx, N_BITS);
-                   rxs = RenderSamplesX (rx, N_BITS);
-                   
-                   /* Add coverage across row */
-                   ACCESS_MEM(
-                       if (lxi == rxi)
-                       {
-                           AddAlpha (rxs - lxs);
-                       }
-                       else
+           {
+               DefineAlpha(line,lxi);
+               int         lxs;
+               int     rxs;
+               
+               /* Sample coverage for edge pixels */
+               lxs = RenderSamplesX (lx, N_BITS);
+               rxs = RenderSamplesX (rx, N_BITS);
+               
+               /* Add coverage across row */
+               ACCESS_MEM(
+                   if (lxi == rxi)
+                   {
+                       AddAlpha (rxs - lxs);
+                   }
+                   else
+                   {
+                       int     xi;
+                       
+                       AddAlpha (N_X_FRAC(N_BITS) - lxs);
+                       StepAlpha;
+                       for (xi = lxi + 1; xi < rxi; xi++)
                        {
-                           int xi;
-                           
-                           AddAlpha (N_X_FRAC(N_BITS) - lxs);
+                           AddAlpha (N_X_FRAC(N_BITS));
                            StepAlpha;
-                           for (xi = lxi + 1; xi < rxi; xi++)
-                           {
-                               AddAlpha (N_X_FRAC(N_BITS));
-                               StepAlpha;
-                           }
-                           /* Do not add in a 0 alpha here. This check is necessary
-                            * to avoid a buffer overrun when rx is exactly on a pixel
-                            * boundary.
-                            */
-                           if (rxs != 0)
-                               AddAlpha (rxs);
-                       });
-               }
-#endif
+                       }
+                       /* Do not add in a 0 alpha here. This check is necessary
+                        * to avoid a buffer overrun when rx is exactly on a pixel
+                        * boundary.
+                        */
+                       if (rxs != 0)
+                           AddAlpha (rxs);
+                   });
            }
-           
-           if (y == b)
-               break;
-           
+#endif
+       }
+       
+       if (y == b)
+           break;
+       
 #if N_BITS > 1
-           if (pixman_fixed_frac (y) != Y_FRAC_LAST(N_BITS))
-           {
-               RenderEdgeStepSmall (l);
-               RenderEdgeStepSmall (r);
-               y += STEP_Y_SMALL(N_BITS);
-           }
-           else
+       if (pixman_fixed_frac (y) != Y_FRAC_LAST(N_BITS))
+       {
+           RenderEdgeStepSmall (l);
+           RenderEdgeStepSmall (r);
+           y += STEP_Y_SMALL(N_BITS);
+       }
+       else
 #endif
-           {
-               RenderEdgeStepBig (l);
-               RenderEdgeStepBig (r);
-               y += STEP_Y_BIG(N_BITS);
-               line += stride;
-           }
+       {
+           RenderEdgeStepBig (l);
+           RenderEdgeStepBig (r);
+           y += STEP_Y_BIG(N_BITS);
+           line += stride;
        }
+    }
 }
 
 #undef rasterizeSpan
index d233ee4..06d641c 100644 (file)
@@ -223,7 +223,7 @@ struct bits_image
     int                                width;
     int                                height;
     uint32_t *                 bits;
-    int                                rowstride; /* in bytes */
+    int                                rowstride; /* in number of uint32_t's */
 };
 
 union pixman_image