Reindent and reformat pixman-combine.h.template
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Mon, 13 Jul 2009 05:17:53 +0000 (01:17 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Mon, 13 Jul 2009 23:56:25 +0000 (19:56 -0400)
pixman/pixman-combine.h.template

index 302d36a..2b4bb60 100644 (file)
  * Helper macros.
  */
 
-#define MUL_UNc(a,b,t) ( (t) = (a) * (b) + ONE_HALF, ( ( ( (t)>>G_SHIFT ) + (t) )>>G_SHIFT ) )
-#define DIV_UNc(a,b)    (((comp2_t) (a) * MASK) / (b))
-#define ADD_UNc(x,y,t) (                                                       \
-       (t) = x + y,                                                    \
-       (comp4_t) (comp1_t) ((t) | (0 - ((t) >> G_SHIFT))))
+#define MUL_UNc(a, b, t)                                               \
+    ((t) = (a) * (b) + ONE_HALF, ((((t) >> G_SHIFT ) + (t) ) >> G_SHIFT ))
 
-#define DIV_ONE_UNc(x)      (((x) + ONE_HALF + (((x) + ONE_HALF) >> G_SHIFT)) >> G_SHIFT)
+#define DIV_UNc(a, b)                                                  \
+    (((comp2_t) (a) * MASK) / (b))
+
+#define ADD_UNc(x, y, t)                                    \
+    ((t) = x + y,                                           \
+     (comp4_t) (comp1_t) ((t) | (0 - ((t) >> G_SHIFT))))
+
+#define DIV_ONE_UNc(x)                                                 \
+    (((x) + ONE_HALF + (((x) + ONE_HALF) >> G_SHIFT)) >> G_SHIFT)
 
 /*
-  The methods below use some tricks to be able to do two color
-  components at the same time.
-*/
* The methods below use some tricks to be able to do two color
* components at the same time.
+ */
 
 /*
-  x_c = (x_c * a) / 255
-*/
-#define UNcx4_MUL_UNc(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;                                                         \
+ * x_c = (x_c * a) / 255
+ */
+#define UNcx4_MUL_UNc(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_c
-*/
-#define UNcx4_MUL_UNc_ADD_UNcx4(x, a, y) do {                                      \
-        /* multiply and divide: trunc((i + 128)*257/65536) */           \
-        comp4_t t = ((x & RB_MASK) * a) + RB_ONE_HALF;                  \
-        t = (t + ((t >> COMPONENT_SIZE) & RB_MASK)) >> COMPONENT_SIZE;  \
-        t &= RB_MASK;                                                   \
-                                                                        \
-        /* add */                                                       \
-        t += y & RB_MASK;                                               \
-                                                                        \
-        /* saturate */                                                  \
-        t |= RB_MASK_PLUS_ONE - ((t >> COMPONENT_SIZE) & RB_MASK);      \
-        t &= RB_MASK;                                                   \
-                                                                        \
-        /* multiply and divide */                                       \
-        x = (((x >> COMPONENT_SIZE) & RB_MASK) * a) + RB_ONE_HALF;      \
-        x = (x + ((x >> COMPONENT_SIZE) & RB_MASK)) >> COMPONENT_SIZE;  \
-        x &= RB_MASK;                                                   \
-                                                                        \
-        /* add */                                                       \
-        x += (y >> COMPONENT_SIZE) & RB_MASK;                           \
-                                                                        \
-        /* saturate */                                                  \
-        x |= RB_MASK_PLUS_ONE - ((x >> COMPONENT_SIZE) & RB_MASK);      \
-        x &= RB_MASK;                                                   \
-                                                                        \
-        /* recombine */                                                 \
-        x <<= COMPONENT_SIZE;                                           \
-        x += t;                                                         \
+ * x_c = (x_c * a) / 255 + y_c
+ */
+#define UNcx4_MUL_UNc_ADD_UNcx4(x, a, y)                               \
+    do                                                                 \
+    {                                                                  \
+       /* multiply and divide: trunc((i + 128)*257/65536) */           \
+       comp4_t t = ((x & RB_MASK) * a) + RB_ONE_HALF;                  \
+       t = (t + ((t >> COMPONENT_SIZE) & RB_MASK)) >> COMPONENT_SIZE;  \
+       t &= RB_MASK;                                                   \
+                                                                        \
+       /* add */                                                       \
+       t += y & RB_MASK;                                               \
+                                                                        \
+       /* saturate */                                                  \
+       t |= RB_MASK_PLUS_ONE - ((t >> COMPONENT_SIZE) & RB_MASK);      \
+       t &= RB_MASK;                                                   \
+                                                                        \
+       /* multiply and divide */                                       \
+       x = (((x >> COMPONENT_SIZE) & RB_MASK) * a) + RB_ONE_HALF;      \
+       x = (x + ((x >> COMPONENT_SIZE) & RB_MASK)) >> COMPONENT_SIZE;  \
+       x &= RB_MASK;                                                   \
+                                                                        \
+       /* add */                                                       \
+       x += (y >> COMPONENT_SIZE) & RB_MASK;                           \
+                                                                        \
+       /* saturate */                                                  \
+       x |= RB_MASK_PLUS_ONE - ((x >> COMPONENT_SIZE) & RB_MASK);      \
+       x &= RB_MASK;                                                   \
+                                                                        \
+       /* recombine */                                                 \
+       x <<= COMPONENT_SIZE;                                           \
+       x += t;                                                         \
     } while (0)
 
 /*
-  x_c = (x_c * a + y_c * b) / 255
-*/
-#define UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc(x, a, y, b) do {                                   \
-        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 >>= R_SHIFT;                                                  \
-                                                                        \
-        t |= r << R_SHIFT;                                              \
-        t |= RB_MASK_PLUS_ONE - ((t >> G_SHIFT) & RB_MASK);             \
-        t &= RB_MASK;                                                   \
-        t <<= G_SHIFT;                                                  \
-                                                                        \
-        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 << R_SHIFT;                                              \
-        x |= RB_MASK_PLUS_ONE - ((x >> G_SHIFT) & RB_MASK);             \
-        x &= RB_MASK;                                                   \
-        x |= t;                                                         \
+ * x_c = (x_c * a + y_c * b) / 255
+ */
+#define UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc(x, a, y, b)                    \
+    do                                                                 \
+    {                                                                  \
+       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 >>= R_SHIFT;                                                  \
+                                                                        \
+       t |= r << R_SHIFT;                                              \
+       t |= RB_MASK_PLUS_ONE - ((t >> G_SHIFT) & RB_MASK);             \
+       t &= RB_MASK;                                                   \
+       t <<= G_SHIFT;                                                  \
+                                                                        \
+       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 << R_SHIFT;                                              \
+       x |= RB_MASK_PLUS_ONE - ((x >> G_SHIFT) & RB_MASK);             \
+       x &= RB_MASK;                                                   \
+       x |= t;                                                         \
     } while (0)
 
 /*
-  x_c = (x_c * a_c) / 255
-*/
-#define UNcx4_MUL_UNcx4(x, a) do {                                           \
-        comp4_t t;                                                      \
-        comp4_t r = (x & MASK) * (a & 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 & R_MASK) * (a >> A_SHIFT);                             \
-        t += RB_ONE_HALF;                                               \
-        t = t + ((t >> G_SHIFT) & RB_MASK);                             \
-        x = r | (t & AG_MASK);                                          \
+ * x_c = (x_c * a_c) / 255
+ */
+#define UNcx4_MUL_UNcx4(x, a)                                          \
+    do                                                                 \
+    {                                                                  \
+       comp4_t t;                                                      \
+       comp4_t r = (x & MASK) * (a & 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 & R_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_c) / 255 + y_c
-*/
-#define UNcx4_MUL_UNcx4_ADD_UNcx4(x, a, y) do {                                     \
-        comp4_t t;                                                      \
-        comp4_t r = (x & MASK) * (a & 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;                                                   \
-        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 & R_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);                                         \
+ * x_c = (x_c * a_c) / 255 + y_c
+ */
+#define UNcx4_MUL_UNcx4_ADD_UNcx4(x, a, y)                             \
+    do                                                                 \
+    {                                                                  \
+       comp4_t t;                                                      \
+       comp4_t r = (x & MASK) * (a & 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;                                                   \
+       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 & R_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 UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc(x, a, y, b) do {                                  \
-        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 >>= R_SHIFT;                                                  \
-                                                                        \
-        t |= r << R_SHIFT;                                              \
-        t |= RB_MASK_PLUS_ONE - ((t >> G_SHIFT) & RB_MASK);             \
-        t &= RB_MASK;                                                   \
-        t <<= G_SHIFT;                                                  \
-                                                                        \
-        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 << R_SHIFT;                                              \
-        x |= RB_MASK_PLUS_ONE - ((x >> G_SHIFT) & RB_MASK);             \
-        x &= RB_MASK;                                                   \
-        x |= t;                                                         \
+ * x_c = (x_c * a_c + y_c * b) / 255
+ */
+#define UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc(x, a, y, b)                  \
+    do                                                                 \
+    {                                                                  \
+       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 >>= R_SHIFT;                                                  \
+                                                                       \
+       t |= r << R_SHIFT;                                              \
+       t |= RB_MASK_PLUS_ONE - ((t >> G_SHIFT) & RB_MASK);             \
+       t &= RB_MASK;                                                   \
+       t <<= G_SHIFT;                                                  \
+                                                                       \
+       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 << R_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 UNcx4_ADD_UNcx4(x, y) do {                                            \
-        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;                                                          \
+   x_c = min(x_c + y_c, 255)
+ */
+#define UNcx4_ADD_UNcx4(x, y)                                          \
+    do                                                                 \
+    {                                                                  \
+       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)
-