unswitch red and blue
authorBenjamin Otte <otte@gnome.org>
Sun, 12 Oct 2008 22:05:40 +0000 (00:05 +0200)
committerBenjamin Otte <otte@gnome.org>
Sun, 12 Oct 2008 22:05:40 +0000 (00:05 +0200)
The previous code assumed a color format of ABGR when naming the
variables. The true color format is ARGB. This did not cause any bugs
because no functions rely on the order of colors so far. This patch
renames the variables just to avoid confusion.

pixman/combine.h.inc
pixman/combine.inc
pixman/combine.pl

index 8c70cb7..4261e83 100644 (file)
@@ -3,12 +3,12 @@
 #define MASK
 #define ONE_HALF
 
-#define G_SHIFT
-#define B_SHIFT
 #define A_SHIFT
-#define G_MASK
-#define B_MASK
+#define R_SHIFT
+#define G_SHIFT
 #define A_MASK
+#define R_MASK
+#define G_MASK
 
 #define RB_MASK
 #define AG_MASK
                                                                         \
         t = (x & G_MASK) * a + (y & G_MASK) * b;                        \
         t += (t >> G_SHIFT) + (ONE_HALF << G_SHIFT);                    \
-        t >>= B_SHIFT;                                                  \
+        t >>= R_SHIFT;                                                  \
                                                                         \
-        t |= r << B_SHIFT;                                              \
+        t |= r << R_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 = ((x >> R_SHIFT) & MASK) * a +                               \
+            ((y >> R_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 |= r << R_SHIFT;                                              \
         x |= RB_MASK_PLUS_ONE - ((x >> G_SHIFT) & RB_MASK);             \
         x &= RB_MASK;                                                   \
         x |= t;                                                         \
 #define FbByteMulC(x, a) do {                                           \
         comp4_t t;                                                      \
         comp4_t r = (x & MASK) * (a & MASK);                            \
-        r |= (x & B_MASK) * ((a >> B_SHIFT) & MASK);                    \
+        r |= (x & R_MASK) * ((a >> R_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 |= (x & R_MASK) * (a >> A_SHIFT);                             \
         t += RB_ONE_HALF;                                               \
         t = t + ((t >> G_SHIFT) & RB_MASK);                             \
         x = r | (t & AG_MASK);                                          \
 #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 |= (x & R_MASK) * ((a >> R_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 |= (x & R_MASK) * (a >> A_SHIFT);                             \
         t += RB_ONE_HALF;                                               \
         t = (t + ((t >> G_SHIFT) & RB_MASK)) >> G_SHIFT;                \
         t &= RB_MASK;                                                   \
                                                                         \
         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_SHIFT;                                                  \
                                                                         \
-        t |= r << B_SHIFT;                                              \
+        t |= r << R_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 = ((x >> R_SHIFT) & MASK) * ((a >> R_SHIFT) & MASK) +         \
+            ((y >> R_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 |= r << R_SHIFT;                                              \
         x |= RB_MASK_PLUS_ONE - ((x >> G_SHIFT) & RB_MASK);             \
         x &= RB_MASK;                                                   \
         x |= t;                                                         \
index 9f88dee..bcf7d5d 100644 (file)
@@ -353,7 +353,7 @@ fbCombineDisjointGeneralU (comp4_t *dest, const comp4_t *src, int width, comp1_t
         }
         m = FbGen (s,d,0,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);
+        o = FbGen (s,d,R_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;
@@ -467,7 +467,7 @@ fbCombineConjointGeneralU (comp4_t *dest, const comp4_t *src, int width, comp1_t
         }
         m = FbGen (s,d,0,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);
+        o = FbGen (s,d,R_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;
@@ -554,7 +554,7 @@ fbCombineMaskC (comp4_t *src, comp4_t *mask)
     {
        x = x >> A_SHIFT;
        x |= x << G_SHIFT;
-       x |= x << B_SHIFT;
+       x |= x << R_SHIFT;
        *(mask) = x;
        return;
     }
@@ -602,7 +602,7 @@ fbCombineMaskAlphaC (const comp4_t *src, comp4_t *mask)
     {
        x = x >> A_SHIFT;
        x |= x << G_SHIFT;
-       x |= x << B_SHIFT;
+       x |= x << R_SHIFT;
        *(mask) = x;
        return;
     }
@@ -885,7 +885,7 @@ fbCombineSaturateC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
        fbCombineMaskC (&s, &m);
 
         sa = (m >> A_SHIFT);
-        sr = (m >> B_SHIFT) & MASK;
+        sr = (m >> R_SHIFT) & MASK;
         sg = (m >> G_SHIFT) & MASK;
         sb =  m             & MASK;
         da = ~d >> A_SHIFT;
@@ -901,9 +901,9 @@ fbCombineSaturateC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width)
             n = FbGen (s, d, G_SHIFT, (da << G_SHIFT) / sg, MASK, t, u, v);
 
         if (sr <= da)
-            o = Add(s,d,B_SHIFT,t);
+            o = Add(s,d,R_SHIFT,t);
         else
-            o = FbGen (s, d, B_SHIFT, (da << G_SHIFT) / sr, MASK, t, u, v);
+            o = FbGen (s, d, R_SHIFT, (da << G_SHIFT) / sr, MASK, t, u, v);
 
         if (sa <= da)
             p = Add(s,d,A_SHIFT,t);
@@ -943,14 +943,14 @@ fbCombineDisjointGeneralC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width
         case CombineAOut:
             m = (comp4_t)fbCombineDisjointOutPart ((comp1_t) (sa >> 0), da);
             n = (comp4_t)fbCombineDisjointOutPart ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
-            o = (comp4_t)fbCombineDisjointOutPart ((comp1_t) (sa >> B_SHIFT), da) << B_SHIFT;
+            o = (comp4_t)fbCombineDisjointOutPart ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT;
             p = (comp4_t)fbCombineDisjointOutPart ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
             Fa = m|n|o|p;
             break;
         case CombineAIn:
             m = (comp4_t)fbCombineDisjointInPart ((comp1_t) (sa >> 0), da);
             n = (comp4_t)fbCombineDisjointInPart ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
-            o = (comp4_t)fbCombineDisjointInPart ((comp1_t) (sa >> B_SHIFT), da) << B_SHIFT;
+            o = (comp4_t)fbCombineDisjointInPart ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT;
             p = (comp4_t)fbCombineDisjointInPart ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
             Fa = m|n|o|p;
             break;
@@ -966,14 +966,14 @@ fbCombineDisjointGeneralC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width
         case CombineBOut:
             m = (comp4_t)fbCombineDisjointOutPart (da, (comp1_t) (sa >> 0));
             n = (comp4_t)fbCombineDisjointOutPart (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
-            o = (comp4_t)fbCombineDisjointOutPart (da, (comp1_t) (sa >> B_SHIFT)) << B_SHIFT;
+            o = (comp4_t)fbCombineDisjointOutPart (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT;
             p = (comp4_t)fbCombineDisjointOutPart (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
             Fb = m|n|o|p;
             break;
         case CombineBIn:
             m = (comp4_t)fbCombineDisjointInPart (da, (comp1_t) (sa >> 0));
             n = (comp4_t)fbCombineDisjointInPart (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
-            o = (comp4_t)fbCombineDisjointInPart (da, (comp1_t) (sa >> B_SHIFT)) << B_SHIFT;
+            o = (comp4_t)fbCombineDisjointInPart (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT;
             p = (comp4_t)fbCombineDisjointInPart (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
             Fb = m|n|o|p;
             break;
@@ -983,7 +983,7 @@ fbCombineDisjointGeneralC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width
         }
         m = FbGen (s,d,0,GetComp(Fa,0),GetComp(Fb,0),t, u, v);
         n = FbGen (s,d,G_SHIFT,GetComp(Fa,G_SHIFT),GetComp(Fb,G_SHIFT),t, u, v);
-        o = FbGen (s,d,B_SHIFT,GetComp(Fa,B_SHIFT),GetComp(Fb,B_SHIFT),t, u, v);
+        o = FbGen (s,d,R_SHIFT,GetComp(Fa,R_SHIFT),GetComp(Fb,R_SHIFT),t, u, v);
         p = FbGen (s,d,A_SHIFT,GetComp(Fa,A_SHIFT),GetComp(Fb,A_SHIFT),t, u, v);
         s = m|n|o|p;
        *(dest + i) = s;
@@ -1067,14 +1067,14 @@ fbCombineConjointGeneralC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width
         case CombineAOut:
             m = (comp4_t)fbCombineConjointOutPart ((comp1_t) (sa >> 0), da);
             n = (comp4_t)fbCombineConjointOutPart ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
-            o = (comp4_t)fbCombineConjointOutPart ((comp1_t) (sa >> B_SHIFT), da) << B_SHIFT;
+            o = (comp4_t)fbCombineConjointOutPart ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT;
             p = (comp4_t)fbCombineConjointOutPart ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
             Fa = m|n|o|p;
             break;
         case CombineAIn:
             m = (comp4_t)fbCombineConjointInPart ((comp1_t) (sa >> 0), da);
             n = (comp4_t)fbCombineConjointInPart ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
-            o = (comp4_t)fbCombineConjointInPart ((comp1_t) (sa >> B_SHIFT), da) << B_SHIFT;
+            o = (comp4_t)fbCombineConjointInPart ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT;
             p = (comp4_t)fbCombineConjointInPart ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
             Fa = m|n|o|p;
             break;
@@ -1090,14 +1090,14 @@ fbCombineConjointGeneralC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width
         case CombineBOut:
             m = (comp4_t)fbCombineConjointOutPart (da, (comp1_t) (sa >> 0));
             n = (comp4_t)fbCombineConjointOutPart (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
-            o = (comp4_t)fbCombineConjointOutPart (da, (comp1_t) (sa >> B_SHIFT)) << B_SHIFT;
+            o = (comp4_t)fbCombineConjointOutPart (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT;
             p = (comp4_t)fbCombineConjointOutPart (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
             Fb = m|n|o|p;
             break;
         case CombineBIn:
             m = (comp4_t)fbCombineConjointInPart (da, (comp1_t) (sa >> 0));
             n = (comp4_t)fbCombineConjointInPart (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
-            o = (comp4_t)fbCombineConjointInPart (da, (comp1_t) (sa >> B_SHIFT)) << B_SHIFT;
+            o = (comp4_t)fbCombineConjointInPart (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT;
             p = (comp4_t)fbCombineConjointInPart (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
             Fb = m|n|o|p;
             break;
@@ -1107,7 +1107,7 @@ fbCombineConjointGeneralC (comp4_t *dest, comp4_t *src, comp4_t *mask, int width
         }
         m = FbGen (s,d,0,GetComp(Fa,0),GetComp(Fb,0),t, u, v);
         n = FbGen (s,d,G_SHIFT,GetComp(Fa,G_SHIFT),GetComp(Fb,G_SHIFT),t, u, v);
-        o = FbGen (s,d,B_SHIFT,GetComp(Fa,B_SHIFT),GetComp(Fb,B_SHIFT),t, u, v);
+        o = FbGen (s,d,R_SHIFT,GetComp(Fa,R_SHIFT),GetComp(Fb,R_SHIFT),t, u, v);
         p = FbGen (s,d,A_SHIFT,GetComp(Fa,A_SHIFT),GetComp(Fb,A_SHIFT),t, u, v);
         s = m|n|o|p;
        *(dest + i) = s;
index f8df603..6d27423 100644 (file)
@@ -47,10 +47,10 @@ while (<STDIN>) {
 
     # Shifts and masks for green, blue, and alpha.
     s/#define G_SHIFT\b/$& $size/;
-    s/#define B_SHIFT\b/$& $size * 2/;
+    s/#define R_SHIFT\b/$& $size * 2/;
     s/#define A_SHIFT\b/$& $size * 3/;
     s/#define G_MASK\b/$& $g_mask/;
-    s/#define B_MASK\b/$& $b_mask/;
+    s/#define R_MASK\b/$& $b_mask/;
     s/#define A_MASK\b/$& $a_mask/;
 
     # Special values for dealing with red + blue at the same time.