Eliminate Fetch/Store24 macros.
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Mon, 22 Jun 2009 12:09:11 +0000 (08:09 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Mon, 22 Jun 2009 12:09:11 +0000 (08:09 -0400)
Replace them with inline functions in pixman-bits-image.c.

pixman/pixman-access.c
pixman/pixman-fast-path.c
pixman/pixman-private.h

index a20aec4..737d492 100644 (file)
@@ -209,8 +209,16 @@ fbFetch_r8g8b8 (bits_image_t *pict, int x, int y, int width, uint32_t *buffer)
     const uint8_t *pixel = (const uint8_t *)bits + 3*x;
     const uint8_t *end = pixel + 3*width;
     while (pixel < end) {
-       uint32_t b = Fetch24(pict, pixel) | 0xff000000;
-       pixel += 3;
+       uint32_t b = 0xff000000;
+#ifdef WORDS_BIGENDIAN
+       b |= (READ(pict, pixel++) << 16);
+       b |= (READ(pict, pixel++) << 8);
+       b |= (READ(pict, pixel++));
+#else
+       b |= (READ(pict, pixel++));
+       b |= (READ(pict, pixel++) << 8);
+       b |= (READ(pict, pixel++) << 16);
+#endif
        *buffer++ = b;
     }
 }
@@ -1900,9 +1908,18 @@ fbStore_r8g8b8 (pixman_image_t *image,
 {
     int i;
     uint8_t *pixel = ((uint8_t *) bits) + 3*x;
-    for (i = 0; i < width; ++i) {
-       Store24(image, pixel, values[i]);
-       pixel += 3;
+    for (i = 0; i < width; ++i)
+    {
+       uint32_t val = values[i];
+#ifdef WORDS_BIGENDIAN
+       WRITE(image, pixel++, (val & 0x00ff0000) >> 16);
+       WRITE(image, pixel++, (val & 0x0000ff00) >>  8);
+       WRITE(image, pixel++, (val & 0x000000ff) >>  0);
+#else
+       WRITE(image, pixel++, (val & 0x000000ff) >>  0);
+       WRITE(image, pixel++, (val & 0x0000ff00) >>  8);
+       WRITE(image, pixel++, (val & 0x00ff0000) >> 16);
+#endif
     }
 }
 
@@ -1912,7 +1929,8 @@ fbStore_b8g8r8 (pixman_image_t *image,
 {
     int i;
     uint8_t *pixel = ((uint8_t *) bits) + 3*x;
-    for (i = 0; i < width; ++i) {
+    for (i = 0; i < width; ++i)
+    {
        uint32_t val = values[i];
 #ifdef WORDS_BIGENDIAN
        WRITE(image, pixel++, (val & 0x000000ff) >>  0);
index 49c1d4c..4c04d60 100644 (file)
 #include "pixman-combine32.h"
 
 static force_inline uint32_t
+Fetch24 (uint8_t *a)
+{
+    if (((unsigned long)a) & 1)
+    {
+#ifdef WORDS_BIGENDIAN
+       return (*a << 16) | (*(uint16_t *)(a + 1));
+#else
+       return *a | (*(uint16_t *)(a + 1) << 8);
+#endif
+    }
+    else
+    {
+#ifdef WORDS_BIGENDIAN
+       return (*(uint16_t *)a << 8) | *(a + 2);
+#else
+       return *(uint16_t *)a | (*(a + 2) << 16);
+#endif
+    }
+}
+
+static force_inline void
+Store24 (uint8_t *a, uint32_t v)
+{
+    if (((unsigned long)a) & 1)
+    {
+#ifdef WORDS_BIGENDIAN
+       *a = (uint8_t) (v >> 16);
+       *(uint16_t *)(a + 1) = (uint16_t) (v);
+#else
+       *a = (uint8_t) (v);
+       *(uint16_t *)(a + 1) = (uint16_t) (v >> 8);
+#endif 
+    }
+    else
+    {
+#ifdef WORDS_BIGENDIAN
+       *(uint16_t *)a = (uint16_t)(v >> 8)
+       *(a + 2) = (uint8_t)v;
+#else
+       *(uint16_t *)a = (uint16_t)v;
+       *(a + 2) = (uint8_t)(v >> 16);
+#endif 
+    }
+}
+
+static force_inline uint32_t
 fbOver (uint32_t src, uint32_t dest)
 {
-    // dest = (dest * (255 - alpha)) / 255 + src
-    uint32_t a = ~src >> 24; // 255 - alpha == 255 + (~alpha + 1) == ~alpha
+    uint32_t a = ~src >> 24; 
+
     FbByteMulAdd(dest, a, src);
 
     return dest;
@@ -439,15 +485,15 @@ fbCompositeSolidMask_nx8x0888 (pixman_implementation_t *imp,
                    d = src;
                else
                {
-                   d = Fetch24(pDst, dst);
+                   d = Fetch24(dst);
                    d = fbOver24 (src, d);
                }
-               Store24(pDst, dst,d);
+               Store24(dst, d);
            }
            else if (m)
            {
-               d = fbOver24 (fbIn(src,m), Fetch24(pDst, dst));
-               Store24(pDst, dst, d);
+               d = fbOver24 (fbIn(src,m), Fetch24(dst));
+               Store24(dst, d);
            }
            dst += 3;
        }
@@ -679,8 +725,9 @@ fbCompositeSrc_8888x0888 (pixman_implementation_t *imp,
                if (a == 0xff)
                    d = s;
                else
-                   d = fbOver24 (s, Fetch24(pDst, dst));
-               Store24(pDst, dst, d);
+                   d = fbOver24 (s, Fetch24(dst));
+
+               Store24(dst, d);
            }
            dst += 3;
        }
index beb9292..34775d4 100644 (file)
@@ -307,28 +307,6 @@ uint32_t
 _pixman_gradient_walker_pixel (pixman_gradient_walker_t       *walker,
                               pixman_fixed_32_32_t  x);
 
-
-
-#ifdef WORDS_BIGENDIAN
-#define Fetch24(img, a)  ((unsigned long) (a) & 1 ?          \
-    ((READ(img, a) << 16) | READ(img, (uint16_t *) ((a)+1))) : \
-    ((READ(img, (uint16_t *) (a)) << 8) | READ(img, (a)+2)))
-#define Store24(img,a,v) ((unsigned long) (a) & 1 ? \
-    (WRITE(img, a, (uint8_t) ((v) >> 16)),               \
-     WRITE(img, (uint16_t *) ((a)+1), (uint16_t) (v))) :  \
-    (WRITE(img, (uint16_t *) (a), (uint16_t) ((v) >> 8)), \
-     WRITE(img, (a)+2, (uint8_t) (v))))
-#else
-#define Fetch24(img,a)  ((unsigned long) (a) & 1 ?                          \
-    (READ(img, a) | (READ(img, (uint16_t *) ((a)+1)) << 8)) : \
-    (READ(img, (uint16_t *) (a)) | (READ(img, (a)+2) << 16)))
-#define Store24(img,a,v) ((unsigned long) (a) & 1 ? \
-    (WRITE(img, a, (uint8_t) (v)),                             \
-     WRITE(img, (uint16_t *) ((a)+1), (uint16_t) ((v) >> 8))) : \
-    (WRITE(img, (uint16_t *) (a), (uint16_t) (v)),             \
-     WRITE(img, (a)+2, (uint8_t) ((v) >> 16))))
-#endif
-
 #define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
 #define FbIntDiv(a,b)   (((uint16_t) (a) * 255) / (b))