Eliminate bit fiddling macros from pixman-private.h.
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Sun, 21 Jun 2009 22:40:25 +0000 (18:40 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Sun, 21 Jun 2009 22:40:25 +0000 (18:40 -0400)
There was one remaining use of FbMaskBits in the a1 trap rasterizer;
just move that macro there.

pixman/pixman-bits-image.c
pixman/pixman-edge-imp.h
pixman/pixman-private.h

index d535b85..699402f 100644 (file)
@@ -795,7 +795,7 @@ create_bits (pixman_format_code_t format,
     
     /* what follows is a long-winded way, avoiding any possibility of integer
      * overflows, of saying:
-     * stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (uint32_t);
+     * stride = ((width * bpp + 0x1f) >> 5) * sizeof (uint32_t);
      */
     
     bpp = PIXMAN_FORMAT_BPP (format);
@@ -803,16 +803,12 @@ create_bits (pixman_format_code_t format,
        return NULL;
     
     stride = width * bpp;
-    if (pixman_addition_overflows_int (stride, FB_MASK))
+    if (pixman_addition_overflows_int (stride, 0x1f))
        return NULL;
     
-    stride += FB_MASK;
-    stride >>= FB_SHIFT;
+    stride += 0x1f;
+    stride >>= 5;
     
-#if FB_SHIFT < 2
-    if (pixman_multiply_overflows_int (stride, sizeof (uint32_t)))
-       return NULL;
-#endif
     stride *= sizeof (uint32_t);
     
     if (pixman_multiply_overflows_int (height, stride))
index 016bfab..477ab6b 100644 (file)
@@ -78,25 +78,57 @@ rasterizeEdges (pixman_image_t  *image,
 
 #if N_BITS == 1
            {
+
+#ifdef WORDS_BIGENDIAN
+#   define FbScrLeft(x,n)      ((x) << (n))
+#   define FbScrRight(x,n)     ((x) >> (n))
+#else
+#   define FbScrLeft(x,n)      ((x) >> (n))
+#   define FbScrRight(x,n)     ((x) << (n))
+#endif
+
+#define FbLeftMask(x)                                                  \
+               (((x) & 0x1f) ?                                         \
+                FbScrRight (0xffffffff, (x) & 0x1f) : 0)
+#define FbRightMask(x)                                                 \
+               (((32 - (x)) & 0x1f) ?                                  \
+                FbScrLeft (0xffffffff, (32 - (x)) & 0x1f) : 0)
+               
+#define FbMaskBits(x,w,l,n,r) {                                                \
+                   n = (w);                                            \
+                   r = FbRightMask ((x) + n);                          \
+                   l = FbLeftMask (x);                                 \
+                   if (l) {                                            \
+                       n -= 32 - ((x) & 0x1f);                         \
+                       if (n < 0) {                                    \
+                           n = 0;                                      \
+                           l &= r;                                     \
+                           r = 0;                                      \
+                       }                                               \
+                   }                                                   \
+                   n >>= 5;                                            \
+               }
+               
                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;
-
+               
+               a += x >> 5;
+               x &= 0x1f;
+               
                FbMaskBits (x, width, startmask, nmiddle, endmask);
-                   if (startmask) {
-                       WRITE(image, a, READ(image, a) | startmask);
-                       a++;
-                   }
-                   while (nmiddle--)
-                       WRITE(image, a++, FB_ALLONES);
-                   if (endmask)
-                       WRITE(image, a, READ(image, a) | endmask);
+
+               if (startmask) {
+                   WRITE(image, a, READ(image, a) | startmask);
+                   a++;
+               }
+               while (nmiddle--)
+                   WRITE(image, a++, FB_ALLONES);
+               if (endmask)
+                   WRITE(image, a, READ(image, a) | endmask);
            }
 #else
            {
index 4d1cdc8..259a87d 100644 (file)
 #undef DEBUG
 #define DEBUG 0
 
-#define FB_SHIFT    5
-#define FB_UNIT     (1 << FB_SHIFT)
-#define FB_HALFUNIT (1 << (FB_SHIFT-1))
-#define FB_MASK     (FB_UNIT - 1)
+#define FB_MASK     (0x1f)
 #define FB_ALLONES  ((uint32_t) -1)
 
 /* Memory allocation helpers */
@@ -374,44 +371,6 @@ _pixman_gradient_walker_pixel (pixman_gradient_walker_t       *walker,
 
 
 
-#define LOG2_BITMAP_PAD 5
-#define FB_STIP_SHIFT  LOG2_BITMAP_PAD
-#define FB_STIP_UNIT   (1 << FB_STIP_SHIFT)
-#define FB_STIP_MASK   (FB_STIP_UNIT - 1)
-#define FB_STIP_ALLONES        ((uint32_t) -1)
-
-#ifdef WORDS_BIGENDIAN
-#define FbScrLeft(x,n) ((x) << (n))
-#define FbScrRight(x,n)        ((x) >> (n))
-#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))
-#else
-#define FbScrLeft(x,n) ((x) >> (n))
-#define FbScrRight(x,n)        ((x) << (n))
-#define FbLeftStipBits(x,n) ((x) & ((((uint32_t) 1) << (n)) - 1))
-#endif
-
-#define FbStipLeft(x,n)        FbScrLeft(x,n)
-#define FbStipRight(x,n) FbScrRight(x,n)
-#define FbLeftMask(x)       ( ((x) & FB_MASK) ?        \
-                             FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0)
-#define FbRightMask(x)      ( ((FB_UNIT - (x)) & FB_MASK) ? \
-                             FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0)
-
-#define FbMaskBits(x,w,l,n,r) {                                                \
-       n = (w); \
-       r = FbRightMask((x)+n); \
-       l = FbLeftMask(x); \
-       if (l) { \
-           n -= FB_UNIT - ((x) & FB_MASK); \
-           if (n < 0) { \
-               n = 0; \
-               l &= r; \
-               r = 0; \
-           } \
-       } \
-       n >>= FB_SHIFT; \
-    }
-
 #ifdef WORDS_BIGENDIAN
 #define Fetch24(img, a)  ((unsigned long) (a) & 1 ?          \
     ((READ(img, a) << 16) | READ(img, (uint16_t *) ((a)+1))) : \