Replace hardcoded numbers and uint*_t in combine.inc.
authorAaron Plattner <aplattner@nvidia.com>
Tue, 1 Apr 2008 23:31:26 +0000 (16:31 -0700)
committerSøren Sandmann <sandmann@redhat.com>
Fri, 11 Apr 2008 23:58:31 +0000 (19:58 -0400)
The masks and shifts have been replaced with preprocessor defines generated by
combine.pl.  The uint*_t types have been replaced with comp4_t, comp2_t, and
comp1_t depending on how many components the value is supposed to hold.

Signed-off-by: Søren Sandmann <sandmann@redhat.com>
pixman/combine.inc
pixman/combine.pl

index 9cd51a4..42a06b2 100644 (file)
@@ -12,9 +12,8 @@
 
 #define FbGen(x,y,i,ax,ay,t,u,v) ((t) = (FbIntMult(FbGet8(y,i),ay,(u)) + \
                                         FbIntMult(FbGet8(x,i),ax,(v))), \
-                                 (uint32_t) ((uint8_t) ((t) |          \
-                                                        (0 - ((t) >> 8)))) << (i))
-
+                                 (comp4_t) ((comp1_t) ((t) |            \
+                                                        (0 - ((t) >> G_SHIFT)))) << (i))
 
 /*
   The methods below use some tricks to be able to do two color
 /*
   x_c = (x_c * a) / 255
 */
-#define FbByteMul(x, a) do {                                       \
-        uint32_t t = ((x & 0xff00ff) * a) + 0x800080;               \
-        t = (t + ((t >> 8) & 0xff00ff)) >> 8;                      \
-        t &= 0xff00ff;                                             \
-                                                                   \
-        x = (((x >> 8) & 0xff00ff) * a) + 0x800080;                \
-        x = (x + ((x >> 8) & 0xff00ff));                           \
-        x &= 0xff00ff00;                                           \
-        x += t;                                                            \
+#define FbByteMul(x, a) do {                                            \
+        comp4_t t = ((x & RB_MASK) * a) + RB_ONE_HALF;                  \
+        t = (t + ((t >> COMPONENT_SIZE) & RB_MASK)) >> COMPONENT_SIZE;  \
+        t &= RB_MASK;                                                   \
+                                                                        \
+        x = (((x >> COMPONENT_SIZE) & RB_MASK) * a) + RB_ONE_HALF;      \
+        x = (x + ((x >> COMPONENT_SIZE) & RB_MASK));                    \
+        x &= RB_MASK << COMPONENT_SIZE;                                 \
+        x += t;                                                         \
     } while (0)
 
 /*
   x_c = (x_c * a) / 255 + y
 */
-#define FbByteMulAdd(x, a, y) do {                                 \
-        uint32_t t = ((x & 0xff00ff) * a) + 0x800080;               \
-        t = (t + ((t >> 8) & 0xff00ff)) >> 8;                      \
-        t &= 0xff00ff;                                             \
-        t += y & 0xff00ff;                                         \
-        t |= 0x1000100 - ((t >> 8) & 0xff00ff);                            \
-        t &= 0xff00ff;                                             \
-                                                                   \
-        x = (((x >> 8) & 0xff00ff) * a) + 0x800080;                 \
-        x = (x + ((x >> 8) & 0xff00ff)) >> 8;                       \
-        x &= 0xff00ff;                                              \
-        x += (y >> 8) & 0xff00ff;                                   \
-        x |= 0x1000100 - ((x >> 8) & 0xff00ff);                     \
-        x &= 0xff00ff;                                              \
-        x <<= 8;                                                    \
-        x += t;                                                     \
+#define FbByteMulAdd(x, a, y) do {                                      \
+        comp4_t t = ((x & RB_MASK) * a) + RB_ONE_HALF;                  \
+        t = (t + ((t >> COMPONENT_SIZE) & RB_MASK)) >> COMPONENT_SIZE;  \
+        t &= RB_MASK;                                                   \
+        t += y & RB_MASK;                                               \
+        t |= RB_MASK_PLUS_ONE - ((t >> COMPONENT_SIZE) & RB_MASK);      \
+        t &= RB_MASK;                                                   \
+                                                                        \
+        x = (((x >> COMPONENT_SIZE) & RB_MASK) * a) + RB_ONE_HALF;      \
+        x = (x + ((x >> COMPONENT_SIZE) & RB_MASK)) >> COMPONENT_SIZE;  \
+        x &= RB_MASK;                                                   \
+        x += (y >> COMPONENT_SIZE) & RB_MASK;                           \
+        x |= RB_MASK_PLUS_ONE - ((x >> COMPONENT_SIZE) & RB_MASK);      \
+        x &= RB_MASK;                                                   \
+        x <<= COMPONENT_SIZE;                                           \
+        x += t;                                                         \
     } while (0)
 
 /*
   x_c = (x_c * a + y_c * b) / 255
 */
 #define FbByteAddMul(x, a, y, b) do {                                   \
-        uint32_t t;                                                    \
-        uint32_t r = (x >> 24) * a + (y >> 24) * b + 0x80;             \
-        r += (r >> 8);                                                  \
-        r >>= 8;                                                        \
-                                                                       \
-        t = (x & 0xff00) * a + (y & 0xff00) * b;                        \
-        t += (t >> 8) + 0x8000;                                         \
-        t >>= 16;                                                       \
-                                                                       \
-        t |= r << 16;                                                   \
-        t |= 0x1000100 - ((t >> 8) & 0xff00ff);                         \
-        t &= 0xff00ff;                                                  \
-        t <<= 8;                                                        \
-                                                                       \
-        r = ((x >> 16) & 0xff) * a + ((y >> 16) & 0xff) * b + 0x80;     \
-        r += (r >> 8);                                                  \
-        r >>= 8;                                                        \
-                                                                       \
-        x = (x & 0xff) * a + (y & 0xff) * b + 0x80;                     \
-        x += (x >> 8);                                                  \
-        x >>= 8;                                                        \
-        x |= r << 16;                                                   \
-        x |= 0x1000100 - ((x >> 8) & 0xff00ff);                         \
-        x &= 0xff00ff;                                                  \
+        comp4_t t;                                                      \
+        comp4_t r = (x >> A_SHIFT) * a + (y >> A_SHIFT) * b + ONE_HALF; \
+        r += (r >> G_SHIFT);                                            \
+        r >>= G_SHIFT;                                                  \
+                                                                        \
+        t = (x & G_MASK) * a + (y & G_MASK) * b;                        \
+        t += (t >> G_SHIFT) + (ONE_HALF << G_SHIFT);                    \
+        t >>= B_SHIFT;                                                  \
+                                                                        \
+        t |= r << B_SHIFT;                                              \
+        t |= RB_MASK_PLUS_ONE - ((t >> G_SHIFT) & RB_MASK);             \
+        t &= RB_MASK;                                                   \
+        t <<= G_SHIFT;                                                  \
+                                                                        \
+        r = ((x >> B_SHIFT) & MASK) * a +                               \
+            ((y >> B_SHIFT) & MASK) * b + ONE_HALF;                     \
+        r += (r >> G_SHIFT);                                            \
+        r >>= G_SHIFT;                                                  \
+                                                                        \
+        x = (x & MASK) * a + (y & MASK) * b + ONE_HALF;                 \
+        x += (x >> G_SHIFT);                                            \
+        x >>= G_SHIFT;                                                  \
+        x |= r << B_SHIFT;                                              \
+        x |= RB_MASK_PLUS_ONE - ((x >> G_SHIFT) & RB_MASK);             \
+        x &= RB_MASK;                                                   \
         x |= t;                                                         \
     } while (0)
 
   x_c = (x_c * a + y_c *b) / 256
 */
 #define FbByteAddMul_256(x, a, y, b) do {                               \
-        uint32_t t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;          \
-        t >>= 8;                                                        \
-        t &= 0xff00ff;                                                  \
-                                                                       \
-        x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;      \
-        x &= 0xff00ff00;                                                \
+        comp4_t t = (x & RB_MASK) * a + (y & RB_MASK) * b;              \
+        t >>= G_SHIFT;                                                  \
+        t &= RB_MASK;                                                   \
+                                                                        \
+        x = ((x >> G_SHIFT) & RB_MASK) * a +                            \
+            ((y >> G_SHIFT) & RB_MASK) * b;                             \
+        x &= AG_MASK;                                                   \
         x += t;                                                         \
     } while (0)
 
 /*
   x_c = (x_c * a_c) / 255
 */
-#define FbByteMulC(x, a) do {                            \
-        uint32_t t;                                       \
-        uint32_t r = (x & 0xff) * (a & 0xff);             \
-        r |= (x & 0xff0000) * ((a >> 16) & 0xff);        \
-       r += 0x800080;                                    \
-        r = (r + ((r >> 8) & 0xff00ff)) >> 8;            \
-        r &= 0xff00ff;                                   \
-                                                         \
-        x >>= 8;                                         \
-        t = (x & 0xff) * ((a >> 8) & 0xff);              \
-        t |= (x & 0xff0000) * (a >> 24);                 \
-        t += 0x800080;                                   \
-        t = t + ((t >> 8) & 0xff00ff);                   \
-        x = r | (t & 0xff00ff00);                        \
-                                                         \
+#define FbByteMulC(x, a) do {                                           \
+        comp4_t t;                                                      \
+        comp4_t r = (x & MASK) * (a & MASK);                            \
+        r |= (x & B_MASK) * ((a >> B_SHIFT) & MASK);                    \
+        r += RB_ONE_HALF;                                               \
+        r = (r + ((r >> G_SHIFT) & RB_MASK)) >> G_SHIFT;                \
+        r &= RB_MASK;                                                   \
+                                                                        \
+        x >>= G_SHIFT;                                                  \
+        t = (x & MASK) * ((a >> G_SHIFT) & MASK);                       \
+        t |= (x & B_MASK) * (a >> A_SHIFT);                             \
+        t += RB_ONE_HALF;                                               \
+        t = t + ((t >> G_SHIFT) & RB_MASK);                             \
+        x = r | (t & AG_MASK);                                          \
     } while (0)
 
 /*
   x_c = (x_c * a) / 255 + y
 */
-#define FbByteMulAddC(x, a, y) do {                                  \
-        uint32_t t;                                                   \
-        uint32_t r = (x & 0xff) * (a & 0xff);                         \
-        r |= (x & 0xff0000) * ((a >> 16) & 0xff);                    \
-       r += 0x800080;                                                \
-       r = (r + ((r >> 8) & 0xff00ff)) >> 8;                         \
-        r &= 0xff00ff;                                               \
-        r += y & 0xff00ff;                                           \
-        r |= 0x1000100 - ((r >> 8) & 0xff00ff);                              \
-        r &= 0xff00ff;                                               \
-                                                                     \
-        x >>= 8;                                                       \
-        t = (x & 0xff) * ((a >> 8) & 0xff);                            \
-        t |= (x & 0xff0000) * (a >> 24);                               \
-       t += 0x800080;                                                 \
-        t = (t + ((t >> 8) & 0xff00ff)) >> 8;                         \
-        t &= 0xff00ff;                                                 \
-        t += (y >> 8) & 0xff00ff;                                      \
-        t |= 0x1000100 - ((t >> 8) & 0xff00ff);                        \
-        t &= 0xff00ff;                                                 \
-        x = r | (t << 8);                                              \
+#define FbByteMulAddC(x, a, y) do {                                     \
+        comp4_t t;                                                      \
+        comp4_t r = (x & MASK) * (a & MASK);                            \
+        r |= (x & B_MASK) * ((a >> B_SHIFT) & MASK);                    \
+        r += RB_ONE_HALF;                                               \
+        r = (r + ((r >> G_SHIFT) & RB_MASK)) >> G_SHIFT;                \
+        r &= RB_MASK;                                                   \
+        r += y & RB_MASK;                                               \
+        r |= RB_MASK_PLUS_ONE - ((r >> G_SHIFT) & RB_MASK);             \
+        r &= RB_MASK;                                                   \
+                                                                        \
+        x >>= G_SHIFT;                                                  \
+        t = (x & MASK) * ((a >> G_SHIFT) & MASK);                       \
+        t |= (x & B_MASK) * (a >> A_SHIFT);                             \
+        t += RB_ONE_HALF;                                               \
+        t = (t + ((t >> G_SHIFT) & RB_MASK)) >> G_SHIFT;                \
+        t &= RB_MASK;                                                   \
+        t += (y >> G_SHIFT) & RB_MASK;                                  \
+        t |= RB_MASK_PLUS_ONE - ((t >> G_SHIFT) & RB_MASK);             \
+        t &= RB_MASK;                                                   \
+        x = r | (t << G_SHIFT);                                         \
     } while (0)
 
 /*
   x_c = (x_c * a_c + y_c * b) / 255
 */
 #define FbByteAddMulC(x, a, y, b) do {                                  \
-        uint32_t t;                                                    \
-        uint32_t r = (x >> 24) * (a >> 24) + (y >> 24) * b;            \
-        r += (r >> 8) + 0x80;                                           \
-        r >>= 8;                                                        \
-                                                                       \
-        t = (x & 0xff00) * ((a >> 8) & 0xff) + (y & 0xff00) * b;        \
-        t += (t >> 8) + 0x8000;                                         \
-        t >>= 16;                                                       \
-                                                                       \
-        t |= r << 16;                                                   \
-        t |= 0x1000100 - ((t >> 8) & 0xff00ff);                         \
-        t &= 0xff00ff;                                                  \
-        t <<= 8;                                                        \
-                                                                       \
-        r = ((x >> 16) & 0xff) * ((a >> 16) & 0xff) + ((y >> 16) & 0xff) * b + 0x80; \
-        r += (r >> 8);                                                  \
-        r >>= 8;                                                        \
-                                                                       \
-        x = (x & 0xff) * (a & 0xff) + (y & 0xff) * b + 0x80;            \
-        x += (x >> 8);                                                  \
-        x >>= 8;                                                        \
-        x |= r << 16;                                                   \
-        x |= 0x1000100 - ((x >> 8) & 0xff00ff);                         \
-        x &= 0xff00ff;                                                  \
+        comp4_t t;                                                      \
+        comp4_t r = (x >> A_SHIFT) * (a >> A_SHIFT) +                   \
+                     (y >> A_SHIFT) * b;                                \
+        r += (r >> G_SHIFT) + ONE_HALF;                                 \
+        r >>= G_SHIFT;                                                  \
+                                                                        \
+        t = (x & G_MASK) * ((a >> G_SHIFT) & MASK) + (y & G_MASK) * b;  \
+        t += (t >> G_SHIFT) + (ONE_HALF << G_SHIFT);                    \
+        t >>= B_SHIFT;                                                  \
+                                                                        \
+        t |= r << B_SHIFT;                                              \
+        t |= RB_MASK_PLUS_ONE - ((t >> G_SHIFT) & RB_MASK);             \
+        t &= RB_MASK;                                                   \
+        t <<= G_SHIFT;                                                  \
+                                                                        \
+        r = ((x >> B_SHIFT) & MASK) * ((a >> B_SHIFT) & MASK) +         \
+            ((y >> B_SHIFT) & MASK) * b + ONE_HALF;                     \
+        r += (r >> G_SHIFT);                                            \
+        r >>= G_SHIFT;                                                  \
+                                                                        \
+        x = (x & MASK) * (a & MASK) + (y & MASK) * b + ONE_HALF;        \
+        x += (x >> G_SHIFT);                                            \
+        x >>= G_SHIFT;                                                  \
+        x |= r << B_SHIFT;                                              \
+        x |= RB_MASK_PLUS_ONE - ((x >> G_SHIFT) & RB_MASK);             \
+        x &= RB_MASK;                                                   \
         x |= t;                                                         \
     } while (0)
 
   x_c = min(x_c + y_c, 255)
 */
 #define FbByteAdd(x, y) do {                                            \
-        uint32_t t;                                                    \
-        uint32_t r = (x & 0xff00ff) + (y & 0xff00ff);                  \
-        r |= 0x1000100 - ((r >> 8) & 0xff00ff);                         \
-        r &= 0xff00ff;                                                  \
-                                                                       \
-        t = ((x >> 8) & 0xff00ff) + ((y >> 8) & 0xff00ff);              \
-        t |= 0x1000100 - ((t >> 8) & 0xff00ff);                         \
-        r |= (t & 0xff00ff) << 8;                                       \
+        comp4_t t;                                                      \
+        comp4_t r = (x & RB_MASK) + (y & RB_MASK);                      \
+        r |= RB_MASK_PLUS_ONE - ((r >> G_SHIFT) & RB_MASK);             \
+        r &= RB_MASK;                                                   \
+                                                                        \
+        t = ((x >> G_SHIFT) & RB_MASK) + ((y >> G_SHIFT) & RB_MASK);    \
+        t |= RB_MASK_PLUS_ONE - ((t >> G_SHIFT) & RB_MASK);             \
+        r |= (t & RB_MASK) << G_SHIFT;                                  \
         x = r;                                                          \
     } while (0)
 
  * Combine src and mask
  */
 FASTCALL static void
-pixman_fbCombineMaskU (uint32_t *src, const uint32_t *mask, int width)
+pixman_fbCombineMaskU (comp4_t *src, const comp4_t *mask, int width)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t a = *(mask + i) >> 24;
-        uint32_t s = *(src + i);
+        comp4_t a = *(mask + i) >> A_SHIFT;
+        comp4_t s = *(src + i);
         FbByteMul(s, a);
         *(src + i) = s;
     }
@@ -222,26 +224,26 @@ pixman_fbCombineMaskU (uint32_t *src, const uint32_t *mask, int width)
  */
 
 FASTCALL static void
-fbCombineClear (uint32_t *dest, const uint32_t *src, int width)
+fbCombineClear (comp4_t *dest, const comp4_t *src, int width)
 {
-    memset(dest, 0, width*sizeof(uint32_t));
+    memset(dest, 0, width*sizeof(comp4_t));
 }
 
 FASTCALL static void
-fbCombineSrcU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineSrcU (comp4_t *dest, const comp4_t *src, int width)
 {
-    memcpy(dest, src, width*sizeof(uint32_t));
+    memcpy(dest, src, width*sizeof(comp4_t));
 }
 
 /* if the Src is opaque, call fbCombineSrcU */
 FASTCALL static void
-fbCombineOverU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineOverU (comp4_t *dest, const comp4_t *src, int width)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t s = *(src + i);
-        uint32_t d = *(dest + i);
-        uint32_t ia = Alpha(~s);
+        comp4_t s = *(src + i);
+        comp4_t d = *(dest + i);
+        comp4_t ia = Alpha(~s);
 
         FbByteMulAdd(d, ia, s);
        *(dest + i) = d;
@@ -250,13 +252,13 @@ fbCombineOverU (uint32_t *dest, const uint32_t *src, int width)
 
 /* if the Dst is opaque, this is a noop */
 FASTCALL static void
-fbCombineOverReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineOverReverseU (comp4_t *dest, const comp4_t *src, int width)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t s = *(src + i);
-        uint32_t d = *(dest + i);
-        uint32_t ia = Alpha(~*(dest + i));
+        comp4_t s = *(src + i);
+        comp4_t d = *(dest + i);
+        comp4_t ia = Alpha(~*(dest + i));
         FbByteMulAdd(s, ia, d);
        *(dest + i) = s;
     }
@@ -264,12 +266,12 @@ fbCombineOverReverseU (uint32_t *dest, const uint32_t *src, int width)
 
 /* if the Dst is opaque, call fbCombineSrcU */
 FASTCALL static void
-fbCombineInU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineInU (comp4_t *dest, const comp4_t *src, int width)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t s = *(src + i);
-        uint32_t a = Alpha(*(dest + i));
+        comp4_t s = *(src + i);
+        comp4_t a = Alpha(*(dest + i));
         FbByteMul(s, a);
        *(dest + i) = s;
     }
@@ -277,12 +279,12 @@ fbCombineInU (uint32_t *dest, const uint32_t *src, int width)
 
 /* if the Src is opaque, this is a noop */
 FASTCALL static void
-fbCombineInReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineInReverseU (comp4_t *dest, const comp4_t *src, int width)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t d = *(dest + i);
-        uint32_t a = Alpha(*(src + i));
+        comp4_t d = *(dest + i);
+        comp4_t a = Alpha(*(src + i));
         FbByteMul(d, a);
        *(dest + i) = d;
     }
@@ -290,12 +292,12 @@ fbCombineInReverseU (uint32_t *dest, const uint32_t *src, int width)
 
 /* if the Dst is opaque, call fbCombineClear */
 FASTCALL static void
-fbCombineOutU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineOutU (comp4_t *dest, const comp4_t *src, int width)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t s = *(src + i);
-        uint32_t a = Alpha(~*(dest + i));
+        comp4_t s = *(src + i);
+        comp4_t a = Alpha(~*(dest + i));
         FbByteMul(s, a);
        *(dest + i) = s;
     }
@@ -303,12 +305,12 @@ fbCombineOutU (uint32_t *dest, const uint32_t *src, int width)
 
 /* if the Src is opaque, call fbCombineClear */
 FASTCALL static void
-fbCombineOutReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineOutReverseU (comp4_t *dest, const comp4_t *src, int width)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t d = *(dest + i);
-        uint32_t a = Alpha(~*(src + i));
+        comp4_t d = *(dest + i);
+        comp4_t a = Alpha(~*(src + i));
         FbByteMul(d, a);
        *(dest + i) = d;
     }
@@ -318,14 +320,14 @@ fbCombineOutReverseU (uint32_t *dest, const uint32_t *src, int width)
 /* if the Dst is opaque, call fbCombineOverU */
 /* if both the Src and Dst are opaque, call fbCombineSrcU */
 FASTCALL static void
-fbCombineAtopU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineAtopU (comp4_t *dest, const comp4_t *src, int width)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t s = *(src + i);
-        uint32_t d = *(dest + i);
-        uint32_t dest_a = Alpha(d);
-        uint32_t src_ia = Alpha(~s);
+        comp4_t s = *(src + i);
+        comp4_t d = *(dest + i);
+        comp4_t dest_a = Alpha(d);
+        comp4_t src_ia = Alpha(~s);
 
         FbByteAddMul(s, dest_a, d, src_ia);
        *(dest + i) = s;
@@ -336,14 +338,14 @@ fbCombineAtopU (uint32_t *dest, const uint32_t *src, int width)
 /* if the Dst is opaque, call fbCombineInReverseU */
 /* if both the Src and Dst are opaque, call fbCombineDstU */
 FASTCALL static void
-fbCombineAtopReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineAtopReverseU (comp4_t *dest, const comp4_t *src, int width)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t s = *(src + i);
-        uint32_t d = *(dest + i);
-        uint32_t src_a = Alpha(s);
-        uint32_t dest_ia = Alpha(~d);
+        comp4_t s = *(src + i);
+        comp4_t d = *(dest + i);
+        comp4_t src_a = Alpha(s);
+        comp4_t dest_ia = Alpha(~d);
 
         FbByteAddMul(s, dest_ia, d, src_a);
        *(dest + i) = s;
@@ -354,14 +356,14 @@ fbCombineAtopReverseU (uint32_t *dest, const uint32_t *src, int width)
 /* if the Dst is opaque, call fbCombineOverReverseU */
 /* if both the Src and Dst are opaque, call fbCombineClear */
 FASTCALL static void
-fbCombineXorU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineXorU (comp4_t *dest, const comp4_t *src, int width)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t s = *(src + i);
-        uint32_t d = *(dest + i);
-        uint32_t src_ia = Alpha(~s);
-        uint32_t dest_ia = Alpha(~d);
+        comp4_t s = *(src + i);
+        comp4_t d = *(dest + i);
+        comp4_t src_ia = Alpha(~s);
+        comp4_t dest_ia = Alpha(~d);
 
         FbByteAddMul(s, dest_ia, d, src_ia);
        *(dest + i) = s;
@@ -369,12 +371,12 @@ fbCombineXorU (uint32_t *dest, const uint32_t *src, int width)
 }
 
 FASTCALL static void
-fbCombineAddU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineAddU (comp4_t *dest, const comp4_t *src, int width)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t s = *(src + i);
-        uint32_t d = *(dest + i);
+        comp4_t s = *(src + i);
+        comp4_t d = *(dest + i);
         FbByteAdd(d, s);
        *(dest + i) = d;
     }
@@ -384,16 +386,16 @@ fbCombineAddU (uint32_t *dest, const uint32_t *src, int width)
 /* if the Dst is opaque, call fbCombineAddU */
 /* if both the Src and Dst are opaque, call fbCombineAddU */
 FASTCALL static void
-fbCombineSaturateU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineSaturateU (comp4_t *dest, const comp4_t *src, int width)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t  s = *(src + i);
-        uint32_t d = *(dest + i);
-        uint16_t  sa, da;
+        comp4_t s = *(src + i);
+        comp4_t d = *(dest + i);
+        comp2_t sa, da;
 
-        sa = s >> 24;
-        da = ~d >> 24;
+        sa = s >> A_SHIFT;
+        da = ~d >> A_SHIFT;
         if (sa > da)
         {
             sa = FbIntDiv(da, sa);
@@ -445,20 +447,20 @@ fbCombineSaturateU (uint32_t *dest, const uint32_t *src, int width)
 #define CombineXor     (CombineAOut|CombineBOut)
 
 /* portion covered by a but not b */
-FASTCALL static uint8_t
-fbCombineDisjointOutPart (uint8_t a, uint8_t b)
+FASTCALL static comp1_t
+fbCombineDisjointOutPart (comp1_t a, comp1_t b)
 {
     /* min (1, (1-b) / a) */
 
     b = ~b;                /* 1 - b */
     if (b >= a)                    /* 1 - b >= a -> (1-b)/a >= 1 */
-       return 0xff;        /* 1 */
+       return MASK;        /* 1 */
     return FbIntDiv(b,a);   /* (1-b) / a */
 }
 
 /* portion covered by both a and b */
-FASTCALL static uint8_t
-fbCombineDisjointInPart (uint8_t a, uint8_t b)
+FASTCALL static comp1_t
+fbCombineDisjointInPart (comp1_t a, comp1_t b)
 {
     /* max (1-(1-b)/a,0) */
     /*  = - min ((1-b)/a - 1, 0) */
@@ -471,8 +473,8 @@ fbCombineDisjointInPart (uint8_t a, uint8_t b)
 }
 
 /* portion covered by a but not b */
-FASTCALL static uint8_t
-fbCombineConjointOutPart (uint8_t a, uint8_t b)
+FASTCALL static comp1_t
+fbCombineConjointOutPart (comp1_t a, comp1_t b)
 {
     /* max (1-b/a,0) */
     /* = 1-min(b/a,1) */
@@ -485,27 +487,27 @@ fbCombineConjointOutPart (uint8_t a, uint8_t b)
 }
 
 /* portion covered by both a and b */
-FASTCALL static uint8_t
-fbCombineConjointInPart (uint8_t a, uint8_t b)
+FASTCALL static comp1_t
+fbCombineConjointInPart (comp1_t a, comp1_t b)
 {
     /* min (1,b/a) */
 
     if (b >= a)                    /* b >= a -> b/a >= 1 */
-       return 0xff;        /* 1 */
+       return MASK;        /* 1 */
     return FbIntDiv(b,a);   /* b/a */
 }
 
 FASTCALL static void
-fbCombineDisjointGeneralU (uint32_t *dest, const uint32_t *src, int width, uint8_t combine)
+fbCombineDisjointGeneralU (comp4_t *dest, const comp4_t *src, int width, comp1_t combine)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t s = *(src + i);
-        uint32_t d = *(dest + i);
-        uint32_t m,n,o,p;
-        uint16_t Fa, Fb, t, u, v;
-        uint8_t sa = s >> 24;
-        uint8_t da = d >> 24;
+        comp4_t s = *(src + i);
+        comp4_t d = *(dest + i);
+        comp4_t m,n,o,p;
+        comp2_t Fa, Fb, t, u, v;
+        comp1_t sa = s >> A_SHIFT;
+        comp1_t da = d >> A_SHIFT;
 
         switch (combine & CombineA) {
         default:
@@ -518,7 +520,7 @@ fbCombineDisjointGeneralU (uint32_t *dest, const uint32_t *src, int width, uint8
             Fa = fbCombineDisjointInPart (sa, da);
             break;
         case CombineA:
-            Fa = 0xff;
+            Fa = MASK;
             break;
         }
 
@@ -533,32 +535,32 @@ fbCombineDisjointGeneralU (uint32_t *dest, const uint32_t *src, int width, uint8
             Fb = fbCombineDisjointInPart (da, sa);
             break;
         case CombineB:
-            Fb = 0xff;
+            Fb = MASK;
             break;
         }
         m = FbGen (s,d,0,Fa,Fb,t, u, v);
-        n = FbGen (s,d,8,Fa,Fb,t, u, v);
-        o = FbGen (s,d,16,Fa,Fb,t, u, v);
-        p = FbGen (s,d,24,Fa,Fb,t, u, v);
+        n = FbGen (s,d,G_SHIFT,Fa,Fb,t, u, v);
+        o = FbGen (s,d,B_SHIFT,Fa,Fb,t, u, v);
+        p = FbGen (s,d,A_SHIFT,Fa,Fb,t, u, v);
         s = m|n|o|p;
        *(dest + i) = s;
     }
 }
 
 FASTCALL static void
-fbCombineDisjointOverU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointOverU (comp4_t *dest, const comp4_t *src, int width)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t  s = *(src + i);
-        uint16_t  a = s >> 24;
+        comp4_t s = *(src + i);
+        comp2_t a = s >> A_SHIFT;
 
         if (a != 0x00)
         {
-            if (a != 0xff)
+            if (a != MASK)
             {
-                uint32_t d = *(dest + i);
-                a = fbCombineDisjointOutPart (d >> 24, a);
+                comp4_t d = *(dest + i);
+                a = fbCombineDisjointOutPart (d >> A_SHIFT, a);
                 FbByteMulAdd(d, a, s);
                 s = d;
             }
@@ -568,58 +570,58 @@ fbCombineDisjointOverU (uint32_t *dest, const uint32_t *src, int width)
 }
 
 FASTCALL static void
-fbCombineDisjointInU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointInU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineDisjointGeneralU (dest, src, width, CombineAIn);
 }
 
 FASTCALL static void
-fbCombineDisjointInReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointInReverseU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineDisjointGeneralU (dest, src, width, CombineBIn);
 }
 
 FASTCALL static void
-fbCombineDisjointOutU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointOutU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineDisjointGeneralU (dest, src, width, CombineAOut);
 }
 
 FASTCALL static void
-fbCombineDisjointOutReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointOutReverseU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineDisjointGeneralU (dest, src, width, CombineBOut);
 }
 
 FASTCALL static void
-fbCombineDisjointAtopU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointAtopU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineDisjointGeneralU (dest, src, width, CombineAAtop);
 }
 
 FASTCALL static void
-fbCombineDisjointAtopReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointAtopReverseU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineDisjointGeneralU (dest, src, width, CombineBAtop);
 }
 
 FASTCALL static void
-fbCombineDisjointXorU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineDisjointXorU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineDisjointGeneralU (dest, src, width, CombineXor);
 }
 
 FASTCALL static void
-fbCombineConjointGeneralU (uint32_t *dest, const uint32_t *src, int width, uint8_t combine)
+fbCombineConjointGeneralU (comp4_t *dest, const comp4_t *src, int width, comp1_t combine)
 {
     int i;
     for (i = 0; i < width; ++i) {
-        uint32_t  s = *(src + i);
-        uint32_t d = *(dest + i);
-        uint32_t  m,n,o,p;
-        uint16_t  Fa, Fb, t, u, v;
-        uint8_t sa = s >> 24;
-        uint8_t da = d >> 24;
+        comp4_t s = *(src + i);
+        comp4_t d = *(dest + i);
+        comp4_t m,n,o,p;
+        comp2_t Fa, Fb, t, u, v;
+        comp1_t sa = s >> A_SHIFT;
+        comp1_t da = d >> A_SHIFT;
 
         switch (combine & CombineA) {
         default:
@@ -632,7 +634,7 @@ fbCombineConjointGeneralU (uint32_t *dest, const uint32_t *src, int width, uint8
             Fa = fbCombineConjointInPart (sa, da);
             break;
         case CombineA:
-            Fa = 0xff;
+            Fa = MASK;
             break;
         }
 
@@ -647,71 +649,71 @@ fbCombineConjointGeneralU (uint32_t *dest, const uint32_t *src, int width, uint8
             Fb = fbCombineConjointInPart (da, sa);
             break;
         case CombineB:
-            Fb = 0xff;
+            Fb = MASK;
             break;
         }
         m = FbGen (s,d,0,Fa,Fb,t, u, v);
-        n = FbGen (s,d,8,Fa,Fb,t, u, v);
-        o = FbGen (s,d,16,Fa,Fb,t, u, v);
-        p = FbGen (s,d,24,Fa,Fb,t, u, v);
+        n = FbGen (s,d,G_SHIFT,Fa,Fb,t, u, v);
+        o = FbGen (s,d,B_SHIFT,Fa,Fb,t, u, v);
+        p = FbGen (s,d,A_SHIFT,Fa,Fb,t, u, v);
         s = m|n|o|p;
        *(dest + i) = s;
     }
 }
 
 FASTCALL static void
-fbCombineConjointOverU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointOverU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineConjointGeneralU (dest, src, width, CombineAOver);
 }
 
 
 FASTCALL static void
-fbCombineConjointOverReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointOverReverseU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineConjointGeneralU (dest, src, width, CombineBOver);
 }
 
 
 FASTCALL static void
-fbCombineConjointInU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointInU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineConjointGeneralU (dest, src, width, CombineAIn);
 }
 
 
 FASTCALL static void
-fbCombineConjointInReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointInReverseU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineConjointGeneralU (dest, src, width, CombineBIn);
 }
 
 FASTCALL static void
-fbCombineConjointOutU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointOutU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineConjointGeneralU (dest, src, width, CombineAOut);
 }
 
 FASTCALL static void
-fbCombineConjointOutReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointOutReverseU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineConjointGeneralU (dest, src, width, CombineBOut);
 }
 
 FASTCALL static void
-fbCombineConjointAtopU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointAtopU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineConjointGeneralU (dest, src, width, CombineAAtop);
 }
 
 FASTCALL static void
-fbCombineConjointAtopReverseU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointAtopReverseU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineConjointGeneralU (dest, src, width, CombineBAtop);
 }
 
 FASTCALL static void
-fbCombineConjointXorU (uint32_t *dest, const uint32_t *src, int width)
+fbCombineConjointXorU (comp4_t *dest, const comp4_t *src, int width)
 {
     fbCombineConjointGeneralU (dest, src, width, CombineXor);
 }
@@ -721,12 +723,12 @@ fbCombineConjointXorU (uint32_t *dest, const uint32_t *src, int width)
 /********************************************************************************/
 
 FASTCALL static void
-fbCombineMaskC (uint32_t *src, uint32_t *mask)
+fbCombineMaskC (comp4_t *src, comp4_t *mask)
 {
-    uint32_t a = *mask;
+    comp4_t a = *mask;
 
-    uint32_t   x;
-    uint16_t   xa;
+    comp4_t    x;
+    comp2_t    xa;
 
     if (!a)
     {
@@ -735,16 +737,16 @@ fbCombineMaskC (uint32_t *src, uint32_t *mask)
     }
 
     x = *(src);
-    if (a == 0xffffffff)
+    if (a == ~0)
     {
-       x = x >> 24;
-       x |= x << 8;
-       x |= x << 16;
+       x = x >> A_SHIFT;
+       x |= x << G_SHIFT;
+       x |= x << B_SHIFT;
        *(mask) = x;
        return;
     }
 
-    xa = x >> 24;
+    xa = x >> A_SHIFT;
     FbByteMulC(x, a);
     *(src) = x;
     FbByteMul(a, xa);
@@ -752,10 +754,10 @@ fbCombineMaskC (uint32_t *src, uint32_t *mask)
 }
 
 FASTCALL static void
-fbCombineMaskValueC (uint32_t *src, const uint32_t *mask)
+fbCombineMaskValueC (comp4_t *src, const comp4_t *mask)
 {
-    uint32_t a = *mask;
-    uint32_t   x;
+    comp4_t a = *mask;
+    comp4_t    x;
 
     if (!a)
     {
@@ -763,7 +765,7 @@ fbCombineMaskValueC (uint32_t *src, const uint32_t *mask)
        return;
     }
 
-    if (a == 0xffffffff)
+    if (a == ~0)
        return;
 
     x = *(src);
@@ -772,22 +774,22 @@ fbCombineMaskValueC (uint32_t *src, const uint32_t *mask)
 }
 
 FASTCALL static void
-fbCombineMaskAlphaC (const uint32_t *src, uint32_t *mask)
+fbCombineMaskAlphaC (const comp4_t *src, comp4_t *mask)
 {
-    uint32_t a = *(mask);
-    uint32_t   x;
+    comp4_t a = *(mask);
+    comp4_t    x;
 
     if (!a)
        return;
 
-    x = *(src) >> 24;
-    if (x == 0xff)
+    x = *(src) >> A_SHIFT;
+    if (x == MASK)
        return;
-    if (a == 0xffffffff)
+    if (a == ~0)
     {
-       x = x >> 24;
-       x |= x << 8;
-       x |= x << 16;
+       x = x >> A_SHIFT;
+       x |= x << G_SHIFT;
+       x |= x << B_SHIFT;
        *(mask) = x;
        return;
     }
@@ -799,19 +801,19 @@ fbCombineMaskAlphaC (const uint32_t *src, uint32_t *mask)
 
 
 FASTCALL static void
-fbCombineClearC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineClearC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
-    memset(dest, 0, width*sizeof(uint32_t));
+    memset(dest, 0, width*sizeof(comp4_t));
 }
 
 FASTCALL static void
-fbCombineSrcC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineSrcC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     int i;
 
     for (i = 0; i < width; ++i) {
-       uint32_t s = *(src + i);
-       uint32_t m = *(mask + i);
+       comp4_t s = *(src + i);
+       comp4_t m = *(mask + i);
 
        fbCombineMaskValueC (&s, &m);
 
@@ -820,23 +822,23 @@ fbCombineSrcC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
 }
 
 FASTCALL static void
-fbCombineOverC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineOverC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     int i;
 
     for (i = 0; i < width; ++i) {
-       uint32_t s = *(src + i);
-       uint32_t m = *(mask + i);
-       uint32_t a;
+       comp4_t s = *(src + i);
+       comp4_t m = *(mask + i);
+       comp4_t a;
 
        fbCombineMaskC (&s, &m);
 
        a = ~m;
-        if (a != 0xffffffff)
+        if (a != ~0)
         {
             if (a)
             {
-                uint32_t d = *(dest + i);
+                comp4_t d = *(dest + i);
                 FbByteMulAddC(d, a, s);
                 s = d;
             }
@@ -846,22 +848,22 @@ fbCombineOverC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
 }
 
 FASTCALL static void
-fbCombineOverReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineOverReverseC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     int i;
 
     for (i = 0; i < width; ++i) {
-        uint32_t d = *(dest + i);
-        uint32_t a = ~d >> 24;
+        comp4_t d = *(dest + i);
+        comp4_t a = ~d >> A_SHIFT;
 
         if (a)
         {
-            uint32_t s = *(src + i);
-           uint32_t m = *(mask + i);
+            comp4_t s = *(src + i);
+           comp4_t m = *(mask + i);
 
            fbCombineMaskValueC (&s, &m);
 
-            if (a != 0xff)
+            if (a != MASK)
             {
                 FbByteMulAdd(s, a, d);
             }
@@ -871,21 +873,21 @@ fbCombineOverReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
 }
 
 FASTCALL static void
-fbCombineInC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineInC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     int i;
 
     for (i = 0; i < width; ++i) {
-        uint32_t d = *(dest + i);
-        uint16_t a = d >> 24;
-        uint32_t s = 0;
+        comp4_t d = *(dest + i);
+        comp2_t a = d >> A_SHIFT;
+        comp4_t s = 0;
         if (a)
         {
-           uint32_t m = *(mask + i);
+           comp4_t m = *(mask + i);
 
            s = *(src + i);
            fbCombineMaskValueC (&s, &m);
-            if (a != 0xff)
+            if (a != MASK)
             {
                 FbByteMul(s, a);
             }
@@ -895,21 +897,21 @@ fbCombineInC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
 }
 
 FASTCALL static void
-fbCombineInReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineInReverseC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     int i;
 
     for (i = 0; i < width; ++i) {
-        uint32_t s = *(src + i);
-        uint32_t m = *(mask + i);
-        uint32_t a;
+        comp4_t s = *(src + i);
+        comp4_t m = *(mask + i);
+        comp4_t a;
 
        fbCombineMaskAlphaC (&s, &m);
 
        a = m;
-        if (a != 0xffffffff)
+        if (a != ~0)
         {
-            uint32_t d = 0;
+            comp4_t d = 0;
             if (a)
             {
                 d = *(dest + i);
@@ -921,22 +923,22 @@ fbCombineInReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
 }
 
 FASTCALL static void
-fbCombineOutC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineOutC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     int i;
 
     for (i = 0; i < width; ++i) {
-        uint32_t d = *(dest + i);
-        uint16_t a = ~d >> 24;
-        uint32_t s = 0;
+        comp4_t d = *(dest + i);
+        comp2_t a = ~d >> A_SHIFT;
+        comp4_t s = 0;
         if (a)
         {
-           uint32_t m = *(mask + i);
+           comp4_t m = *(mask + i);
 
            s = *(src + i);
            fbCombineMaskValueC (&s, &m);
 
-            if (a != 0xff)
+            if (a != MASK)
             {
                 FbByteMul(s, a);
             }
@@ -946,21 +948,21 @@ fbCombineOutC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
 }
 
 FASTCALL static void
-fbCombineOutReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineOutReverseC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     int i;
 
     for (i = 0; i < width; ++i) {
-       uint32_t s = *(src + i);
-       uint32_t m = *(mask + i);
-       uint32_t a;
+       comp4_t s = *(src + i);
+       comp4_t m = *(mask + i);
+       comp4_t a;
 
        fbCombineMaskAlphaC (&s, &m);
 
         a = ~m;
-        if (a != 0xffffffff)
+        if (a != ~0)
         {
-            uint32_t d = 0;
+            comp4_t d = 0;
             if (a)
             {
                 d = *(dest + i);
@@ -972,16 +974,16 @@ fbCombineOutReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
 }
 
 FASTCALL static void
-fbCombineAtopC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineAtopC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     int i;
 
     for (i = 0; i < width; ++i) {
-        uint32_t d = *(dest + i);
-        uint32_t s = *(src + i);
-        uint32_t m = *(mask + i);
-        uint32_t ad;
-        uint16_t as = d >> 24;
+        comp4_t d = *(dest + i);
+        comp4_t s = *(src + i);
+        comp4_t m = *(mask + i);
+        comp4_t ad;
+        comp2_t as = d >> A_SHIFT;
 
        fbCombineMaskC (&s, &m);
 
@@ -993,17 +995,17 @@ fbCombineAtopC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
 }
 
 FASTCALL static void
-fbCombineAtopReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineAtopReverseC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     int i;
 
     for (i = 0; i < width; ++i) {
 
-        uint32_t d = *(dest + i);
-        uint32_t s = *(src + i);
-        uint32_t m = *(mask + i);
-        uint32_t ad;
-        uint16_t as = ~d >> 24;
+        comp4_t d = *(dest + i);
+        comp4_t s = *(src + i);
+        comp4_t m = *(mask + i);
+        comp4_t ad;
+        comp2_t as = ~d >> A_SHIFT;
 
        fbCombineMaskC (&s, &m);
 
@@ -1015,16 +1017,16 @@ fbCombineAtopReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
 }
 
 FASTCALL static void
-fbCombineXorC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineXorC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     int i;
 
     for (i = 0; i < width; ++i) {
-        uint32_t d = *(dest + i);
-        uint32_t s = *(src + i);
-        uint32_t m = *(mask + i);
-        uint32_t ad;
-        uint16_t as = ~d >> 24;
+        comp4_t d = *(dest + i);
+        comp4_t s = *(src + i);
+        comp4_t m = *(mask + i);
+        comp4_t ad;
+        comp2_t as = ~d >> A_SHIFT;
 
        fbCombineMaskC (&s, &m);
 
@@ -1036,14 +1038,14 @@ fbCombineXorC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
 }
 
 FASTCALL static void
-fbCombineAddC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineAddC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     int i;
 
     for (i = 0; i < width; ++i) {
-        uint32_t s = *(src + i);
-        uint32_t m = *(mask + i);
-        uint32_t d = *(dest + i);
+        comp4_t s = *(src + i);
+        comp4_t m = *(mask + i);
+        comp4_t d = *(dest + i);
 
        fbCombineMaskValueC (&s, &m);
 
@@ -1053,15 +1055,15 @@ fbCombineAddC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
 }
 
 FASTCALL static void
-fbCombineSaturateC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineSaturateC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     int i;
 
     for (i = 0; i < width; ++i) {
-        uint32_t  s, d;
-        uint16_t  sa, sr, sg, sb, da;
-        uint16_t  t, u, v;
-        uint32_t  m,n,o,p;
+        comp4_t s, d;
+        comp2_t sa, sr, sg, sb, da;
+        comp2_t t, u, v;
+        comp4_t m,n,o,p;
 
         d = *(dest + i);
         s = *(src + i);
@@ -1069,53 +1071,53 @@ fbCombineSaturateC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
 
        fbCombineMaskC (&s, &m);
 
-        sa = (m >> 24);
-        sr = (m >> 16) & 0xff;
-        sg = (m >>  8) & 0xff;
-        sb = (m      ) & 0xff;
-        da = ~d >> 24;
+        sa = (m >> A_SHIFT);
+        sr = (m >> B_SHIFT) & MASK;
+        sg = (m >> G_SHIFT) & MASK;
+        sb =  m             & MASK;
+        da = ~d >> A_SHIFT;
 
         if (sb <= da)
             m = FbAdd(s,d,0,t);
         else
-            m = FbGen (s, d, 0, (da << 8) / sb, 0xff, t, u, v);
+            m = FbGen (s, d, 0, (da << G_SHIFT) / sb, MASK, t, u, v);
 
         if (sg <= da)
-            n = FbAdd(s,d,8,t);
+            n = FbAdd(s,d,G_SHIFT,t);
         else
-            n = FbGen (s, d, 8, (da << 8) / sg, 0xff, t, u, v);
+            n = FbGen (s, d, G_SHIFT, (da << G_SHIFT) / sg, MASK, t, u, v);
 
         if (sr <= da)
-            o = FbAdd(s,d,16,t);
+            o = FbAdd(s,d,B_SHIFT,t);
         else
-            o = FbGen (s, d, 16, (da << 8) / sr, 0xff, t, u, v);
+            o = FbGen (s, d, B_SHIFT, (da << G_SHIFT) / sr, MASK, t, u, v);
 
         if (sa <= da)
-            p = FbAdd(s,d,24,t);
+            p = FbAdd(s,d,A_SHIFT,t);
         else
-            p = FbGen (s, d, 24, (da << 8) / sa, 0xff, t, u, v);
+            p = FbGen (s, d, A_SHIFT, (da << G_SHIFT) / sa, MASK, t, u, v);
 
        *(dest + i) = m|n|o|p;
     }
 }
 
 FASTCALL static void
-fbCombineDisjointGeneralC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width, uint8_t combine)
+fbCombineDisjointGeneralC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width, comp1_t combine)
 {
     int i;
 
     for (i = 0; i < width; ++i) {
-        uint32_t  s, d;
-        uint32_t  m,n,o,p;
-        uint32_t  Fa, Fb;
-        uint16_t  t, u, v;
-        uint32_t  sa;
-        uint8_t   da;
+        comp4_t s, d;
+        comp4_t m,n,o,p;
+        comp4_t Fa, Fb;
+        comp2_t t, u, v;
+        comp4_t sa;
+        comp1_t da;
 
         s = *(src + i);
         m = *(mask + i);
         d = *(dest + i);
-        da = d >> 24;
+        da = d >> A_SHIFT;
 
        fbCombineMaskC (&s, &m);
 
@@ -1126,21 +1128,21 @@ fbCombineDisjointGeneralC (uint32_t *dest, uint32_t *src, uint32_t *mask, int wi
             Fa = 0;
             break;
         case CombineAOut:
-            m = fbCombineDisjointOutPart ((uint8_t) (sa >> 0), da);
-            n = fbCombineDisjointOutPart ((uint8_t) (sa >> 8), da) << 8;
-            o = fbCombineDisjointOutPart ((uint8_t) (sa >> 16), da) << 16;
-            p = fbCombineDisjointOutPart ((uint8_t) (sa >> 24), da) << 24;
+            m = fbCombineDisjointOutPart ((comp1_t) (sa >> 0), da);
+            n = fbCombineDisjointOutPart ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
+            o = fbCombineDisjointOutPart ((comp1_t) (sa >> B_SHIFT), da) << B_SHIFT;
+            p = fbCombineDisjointOutPart ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
             Fa = m|n|o|p;
             break;
         case CombineAIn:
-            m = fbCombineDisjointInPart ((uint8_t) (sa >> 0), da);
-            n = fbCombineDisjointInPart ((uint8_t) (sa >> 8), da) << 8;
-            o = fbCombineDisjointInPart ((uint8_t) (sa >> 16), da) << 16;
-            p = fbCombineDisjointInPart ((uint8_t) (sa >> 24), da) << 24;
+            m = fbCombineDisjointInPart ((comp1_t) (sa >> 0), da);
+            n = fbCombineDisjointInPart ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
+            o = fbCombineDisjointInPart ((comp1_t) (sa >> B_SHIFT), da) << B_SHIFT;
+            p = fbCombineDisjointInPart ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
             Fa = m|n|o|p;
             break;
         case CombineA:
-            Fa = 0xffffffff;
+            Fa = ~0;
             break;
         }
 
@@ -1149,97 +1151,97 @@ fbCombineDisjointGeneralC (uint32_t *dest, uint32_t *src, uint32_t *mask, int wi
             Fb = 0;
             break;
         case CombineBOut:
-            m = fbCombineDisjointOutPart (da, (uint8_t) (sa >> 0));
-            n = fbCombineDisjointOutPart (da, (uint8_t) (sa >> 8)) << 8;
-            o = fbCombineDisjointOutPart (da, (uint8_t) (sa >> 16)) << 16;
-            p = fbCombineDisjointOutPart (da, (uint8_t) (sa >> 24)) << 24;
+            m = fbCombineDisjointOutPart (da, (comp1_t) (sa >> 0));
+            n = fbCombineDisjointOutPart (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
+            o = fbCombineDisjointOutPart (da, (comp1_t) (sa >> B_SHIFT)) << B_SHIFT;
+            p = fbCombineDisjointOutPart (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
             Fb = m|n|o|p;
             break;
         case CombineBIn:
-            m = fbCombineDisjointInPart (da, (uint8_t) (sa >> 0));
-            n = fbCombineDisjointInPart (da, (uint8_t) (sa >> 8)) << 8;
-            o = fbCombineDisjointInPart (da, (uint8_t) (sa >> 16)) << 16;
-            p = fbCombineDisjointInPart (da, (uint8_t) (sa >> 24)) << 24;
+            m = fbCombineDisjointInPart (da, (comp1_t) (sa >> 0));
+            n = fbCombineDisjointInPart (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
+            o = fbCombineDisjointInPart (da, (comp1_t) (sa >> B_SHIFT)) << B_SHIFT;
+            p = fbCombineDisjointInPart (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
             Fb = m|n|o|p;
             break;
         case CombineB:
-            Fb = 0xffffffff;
+            Fb = ~0;
             break;
         }
         m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t, u, v);
-        n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t, u, v);
-        o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t, u, v);
-        p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t, u, v);
+        n = FbGen (s,d,G_SHIFT,FbGet8(Fa,G_SHIFT),FbGet8(Fb,G_SHIFT),t, u, v);
+        o = FbGen (s,d,B_SHIFT,FbGet8(Fa,B_SHIFT),FbGet8(Fb,B_SHIFT),t, u, v);
+        p = FbGen (s,d,A_SHIFT,FbGet8(Fa,A_SHIFT),FbGet8(Fb,A_SHIFT),t, u, v);
         s = m|n|o|p;
        *(dest + i) = s;
     }
 }
 
 FASTCALL static void
-fbCombineDisjointOverC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointOverC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineDisjointGeneralC (dest, src, mask, width, CombineAOver);
 }
 
 FASTCALL static void
-fbCombineDisjointInC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointInC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineDisjointGeneralC (dest, src, mask, width, CombineAIn);
 }
 
 FASTCALL static void
-fbCombineDisjointInReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointInReverseC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineDisjointGeneralC (dest, src, mask, width, CombineBIn);
 }
 
 FASTCALL static void
-fbCombineDisjointOutC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointOutC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineDisjointGeneralC (dest, src, mask, width, CombineAOut);
 }
 
 FASTCALL static void
-fbCombineDisjointOutReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointOutReverseC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineDisjointGeneralC (dest, src, mask, width, CombineBOut);
 }
 
 FASTCALL static void
-fbCombineDisjointAtopC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointAtopC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineDisjointGeneralC (dest, src, mask, width, CombineAAtop);
 }
 
 FASTCALL static void
-fbCombineDisjointAtopReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointAtopReverseC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineDisjointGeneralC (dest, src, mask, width, CombineBAtop);
 }
 
 FASTCALL static void
-fbCombineDisjointXorC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineDisjointXorC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineDisjointGeneralC (dest, src, mask, width, CombineXor);
 }
 
 FASTCALL static void
-fbCombineConjointGeneralC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width, uint8_t combine)
+fbCombineConjointGeneralC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width, comp1_t combine)
 {
     int i;
 
     for (i = 0; i < width; ++i) {
-        uint32_t  s, d;
-        uint32_t  m,n,o,p;
-        uint32_t  Fa, Fb;
-        uint16_t  t, u, v;
-        uint32_t  sa;
-        uint8_t   da;
+        comp4_t s, d;
+        comp4_t m,n,o,p;
+        comp4_t Fa, Fb;
+        comp2_t t, u, v;
+        comp4_t sa;
+        comp1_t da;
 
         s = *(src + i);
         m = *(mask + i);
         d = *(dest + i);
-        da = d >> 24;
+        da = d >> A_SHIFT;
 
        fbCombineMaskC (&s, &m);
 
@@ -1250,21 +1252,21 @@ fbCombineConjointGeneralC (uint32_t *dest, uint32_t *src, uint32_t *mask, int wi
             Fa = 0;
             break;
         case CombineAOut:
-            m = fbCombineConjointOutPart ((uint8_t) (sa >> 0), da);
-            n = fbCombineConjointOutPart ((uint8_t) (sa >> 8), da) << 8;
-            o = fbCombineConjointOutPart ((uint8_t) (sa >> 16), da) << 16;
-            p = fbCombineConjointOutPart ((uint8_t) (sa >> 24), da) << 24;
+            m = fbCombineConjointOutPart ((comp1_t) (sa >> 0), da);
+            n = fbCombineConjointOutPart ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
+            o = fbCombineConjointOutPart ((comp1_t) (sa >> B_SHIFT), da) << B_SHIFT;
+            p = fbCombineConjointOutPart ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
             Fa = m|n|o|p;
             break;
         case CombineAIn:
-            m = fbCombineConjointInPart ((uint8_t) (sa >> 0), da);
-            n = fbCombineConjointInPart ((uint8_t) (sa >> 8), da) << 8;
-            o = fbCombineConjointInPart ((uint8_t) (sa >> 16), da) << 16;
-            p = fbCombineConjointInPart ((uint8_t) (sa >> 24), da) << 24;
+            m = fbCombineConjointInPart ((comp1_t) (sa >> 0), da);
+            n = fbCombineConjointInPart ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
+            o = fbCombineConjointInPart ((comp1_t) (sa >> B_SHIFT), da) << B_SHIFT;
+            p = fbCombineConjointInPart ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
             Fa = m|n|o|p;
             break;
         case CombineA:
-            Fa = 0xffffffff;
+            Fa = ~0;
             break;
         }
 
@@ -1273,82 +1275,82 @@ fbCombineConjointGeneralC (uint32_t *dest, uint32_t *src, uint32_t *mask, int wi
             Fb = 0;
             break;
         case CombineBOut:
-            m = fbCombineConjointOutPart (da, (uint8_t) (sa >> 0));
-            n = fbCombineConjointOutPart (da, (uint8_t) (sa >> 8)) << 8;
-            o = fbCombineConjointOutPart (da, (uint8_t) (sa >> 16)) << 16;
-            p = fbCombineConjointOutPart (da, (uint8_t) (sa >> 24)) << 24;
+            m = fbCombineConjointOutPart (da, (comp1_t) (sa >> 0));
+            n = fbCombineConjointOutPart (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
+            o = fbCombineConjointOutPart (da, (comp1_t) (sa >> B_SHIFT)) << B_SHIFT;
+            p = fbCombineConjointOutPart (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
             Fb = m|n|o|p;
             break;
         case CombineBIn:
-            m = fbCombineConjointInPart (da, (uint8_t) (sa >> 0));
-            n = fbCombineConjointInPart (da, (uint8_t) (sa >> 8)) << 8;
-            o = fbCombineConjointInPart (da, (uint8_t) (sa >> 16)) << 16;
-            p = fbCombineConjointInPart (da, (uint8_t) (sa >> 24)) << 24;
+            m = fbCombineConjointInPart (da, (comp1_t) (sa >> 0));
+            n = fbCombineConjointInPart (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
+            o = fbCombineConjointInPart (da, (comp1_t) (sa >> B_SHIFT)) << B_SHIFT;
+            p = fbCombineConjointInPart (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
             Fb = m|n|o|p;
             break;
         case CombineB:
-            Fb = 0xffffffff;
+            Fb = ~0;
             break;
         }
         m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t, u, v);
-        n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t, u, v);
-        o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t, u, v);
-        p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t, u, v);
+        n = FbGen (s,d,G_SHIFT,FbGet8(Fa,G_SHIFT),FbGet8(Fb,G_SHIFT),t, u, v);
+        o = FbGen (s,d,B_SHIFT,FbGet8(Fa,B_SHIFT),FbGet8(Fb,B_SHIFT),t, u, v);
+        p = FbGen (s,d,A_SHIFT,FbGet8(Fa,A_SHIFT),FbGet8(Fb,A_SHIFT),t, u, v);
         s = m|n|o|p;
        *(dest + i) = s;
     }
 }
 
 FASTCALL static void
-fbCombineConjointOverC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointOverC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineConjointGeneralC (dest, src, mask, width, CombineAOver);
 }
 
 FASTCALL static void
-fbCombineConjointOverReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointOverReverseC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineConjointGeneralC (dest, src, mask, width, CombineBOver);
 }
 
 FASTCALL static void
-fbCombineConjointInC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointInC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineConjointGeneralC (dest, src, mask, width, CombineAIn);
 }
 
 FASTCALL static void
-fbCombineConjointInReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointInReverseC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineConjointGeneralC (dest, src, mask, width, CombineBIn);
 }
 
 FASTCALL static void
-fbCombineConjointOutC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointOutC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineConjointGeneralC (dest, src, mask, width, CombineAOut);
 }
 
 FASTCALL static void
-fbCombineConjointOutReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointOutReverseC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineConjointGeneralC (dest, src, mask, width, CombineBOut);
 }
 
 FASTCALL static void
-fbCombineConjointAtopC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointAtopC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineConjointGeneralC (dest, src, mask, width, CombineAAtop);
 }
 
 FASTCALL static void
-fbCombineConjointAtopReverseC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointAtopReverseC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineConjointGeneralC (dest, src, mask, width, CombineBAtop);
 }
 
 FASTCALL static void
-fbCombineConjointXorC (uint32_t *dest, uint32_t *src, uint32_t *mask, int width)
+fbCombineConjointXorC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
 {
     fbCombineConjointGeneralC (dest, src, mask, width, CombineXor);
 }
index 126db6c..8024333 100644 (file)
@@ -7,6 +7,47 @@ $size = int($ARGV[0]);
 $size == 8 or $size == 16 or die $usage;
 
 $pixel_size = $size * 4;
+$half_pixel_size = $size * 2;
+
+sub mask {
+    my $str = shift;
+    my $suffix;
+    $suffix = "ULL" if $size > 8;
+
+    return "0x" . $str . $suffix;
+}
+
+# Generate mask strings.
+$nibbles = $size / 4;
+$mask = "f" x $nibbles;
+$zero_mask = "0" x $nibbles;
+$one_half = "8" . "0" x ($nibbles - 1);
+
+print "/* WARNING: This file is generated by combine.pl from combine.inc.\n";
+print "   Please edit one of those files rather than this one. */\n";
+print "\n";
+
+# Mask and 1/2 value for a single component.
+print "#define COMPONENT_SIZE ", $size, "\n";
+print "#define MASK ", mask($mask), "\n";
+print "#define ONE_HALF ", mask($one_half), "\n";
+print "\n";
+
+# Shifts and masks for green, blue, and alpha.
+print "#define G_SHIFT ", $size, "\n";
+print "#define B_SHIFT ", $size * 2, "\n";
+print "#define A_SHIFT ", $size * 3, "\n";
+print "#define G_MASK ", mask($mask . $zero_mask), "\n";
+print "#define B_MASK ", mask($mask . $zero_mask x 2), "\n";
+print "#define A_MASK ", mask($mask . $zero_mask x 3), "\n";
+print "\n";
+
+# Special values for dealing with red + blue at the same time.
+print "#define RB_MASK ", mask($mask . $zero_mask . $mask), "\n";
+print "#define AG_MASK ", mask($mask . $zero_mask . $mask . $zero_mask), "\n";
+print "#define RB_ONE_HALF ", mask($one_half . $zero_mask . $one_half), "\n";
+print "#define RB_MASK_PLUS_ONE ", mask("1" . $zero_mask x 2 . "1" .  $zero_mask), "\n";
+print "\n";
 
 print "#line 1 \"combine.inc\"\n";
 while (<STDIN>) {
@@ -16,5 +57,10 @@ while (<STDIN>) {
     s/\bCombineMaskU\b/CombineMaskU$pixel_size/;
     s/\bFbComposeFunctions\b/FbComposeFunctions$pixel_size/;
 
-    print $_;
+    # Convert comp*_t values into the appropriate real types.
+    s/comp1_t/uint${size}_t/g;
+    s/comp2_t/uint${half_pixel_size}_t/g;
+    s/comp4_t/uint${pixel_size}_t/g;
+
+    print;
 }