rename operator SUBTRACT to FLASH_SUBTRACT
authorBenjamin Otte <otte@gnome.org>
Sun, 23 Nov 2008 15:23:22 +0000 (16:23 +0100)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Tue, 23 Jun 2009 18:42:35 +0000 (14:42 -0400)
Also document it and move it out of the PDF blend modes to make clear
that it is not in any way related to PDF.

pixman/pixman-combine.c.template
pixman/pixman.h

index 78eac3d..a8b00bf 100644 (file)
@@ -691,72 +691,6 @@ PdfSeparableBlendMode (Exclusion)
 
 #undef PdfSeparableBlendMode
 
-#define Subtract(res, Color)                                           \
-    do {                                                               \
-      comp1_t dc, sc;                                                  \
-      dc = Color (d);                                                  \
-      sc = Color (s);                                                  \
-      if (sc >= dc)                                                    \
-       res = 0;                                                        \
-      else                                                             \
-       res = dc - sc;                                                  \
-    } while (0)
-
-static void
-fbCombineSubtractU (pixman_implementation_t *imp, pixman_op_t op,
-                   comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-       comp4_t d, s;
-       comp4_t r, g, b;
-
-       d = *(dest + i);
-       s = combineMask (src, mask, i);
-
-       Subtract (r, Red);
-       Subtract (g, Green);
-       Subtract (b, Blue);
-
-       *(dest + i) = (Alpha (d) << A_SHIFT)
-           | (r << R_SHIFT)
-           | (g << G_SHIFT)
-           | b;
-    }
-}
-
-static void
-fbCombineSubtractC (pixman_implementation_t *imp, pixman_op_t op,
-                   comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
-{
-    int i;
-
-    for (i = 0; i < width; ++i) {
-       comp4_t d, s, m;
-       comp4_t r, g, b;
-
-       d = *(dest + i);
-       s = combineMask (src, mask, i);
-       m = *(mask + i);
-
-       fbCombineMaskC (&s, &m);
-       m = ~m;
-       fbCombineMaskC (&d, &m);
-
-       Subtract (r, Red);
-       Subtract (g, Green);
-       Subtract (b, Blue);
-
-       *(dest + i) = (Alpha (d) << A_SHIFT)
-           | (r << R_SHIFT)
-           | (g << G_SHIFT)
-           | b;
-    }
-}
-
-#undef Subtract
-
 /*
  * PDF nonseperable blend modes are implemented using the following functions
  * to operate in HSL space, with Cmax, Cmid, Cmin referring to the max, mid 
@@ -794,7 +728,7 @@ fbCombineSubtractC (pixman_implementation_t *imp, pixman_op_t op,
 #define Sat(c) (Max (c) - Min (c))
 
 #define PdfNonSeparableBlendMode(name)             \
-static FASTCALL void                               \
+static void                                \
 fbCombine ## name ## U (pixman_implementation_t *imp, pixman_op_t op, \
                        comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width) \
 {                                                  \
@@ -1031,6 +965,79 @@ PdfNonSeparableBlendMode (HSLLuminosity)
 #undef Min
 #undef PdfNonSeparableBlendMode
 
+/*
+ * Flash Subtract:
+ * This is the only blend mode present in Adobe Flash that is not part of 
+ * the PDF specification. It has been reverse engineered from looking at 
+ * Flash files. Some information can be found at
+ * http://www.kaourantin.net/2005/09/some-word-on-blend-modes-in-flash.html
+ */
+#define Subtract(res, Color)                                           \
+    do {                                                               \
+      comp1_t dc, sc;                                                  \
+      dc = Color (d);                                                  \
+      sc = Color (s);                                                  \
+      if (sc >= dc)                                                    \
+       res = 0;                                                        \
+      else                                                             \
+       res = dc - sc;                                                  \
+    } while (0)
+
+static void
+fbCombineFlashSubtractU (pixman_implementation_t *imp, pixman_op_t op,
+                        comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
+{
+    int i;
+
+    for (i = 0; i < width; ++i) {
+       comp4_t d, s;
+       comp4_t r, g, b;
+
+       d = *(dest + i);
+       s = combineMask (src, mask, i);
+
+       Subtract (r, Red);
+       Subtract (g, Green);
+       Subtract (b, Blue);
+
+       *(dest + i) = (Alpha (d) << A_SHIFT)
+           | (r << R_SHIFT)
+           | (g << G_SHIFT)
+           | b;
+    }
+}
+
+static void
+fbCombineFlashSubtractC (pixman_implementation_t *imp, pixman_op_t op,
+                        comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
+{
+    int i;
+
+    for (i = 0; i < width; ++i) {
+       comp4_t d, s, m;
+       comp4_t r, g, b;
+
+       d = *(dest + i);
+       s = combineMask (src, mask, i);
+       m = *(mask + i);
+
+       fbCombineMaskC (&s, &m);
+       m = ~m;
+       fbCombineMaskC (&d, &m);
+
+       Subtract (r, Red);
+       Subtract (g, Green);
+       Subtract (b, Blue);
+
+       *(dest + i) = (Alpha (d) << A_SHIFT)
+           | (r << R_SHIFT)
+           | (g << G_SHIFT)
+           | b;
+    }
+}
+
+#undef Subtract
+
 /* Overlay
  *
  * All of the disjoint composing functions
@@ -2012,11 +2019,11 @@ _pixman_setup_combiner_functions_width (pixman_implementation_t *imp)
     imp->combine_width[PIXMAN_OP_SOFT_LIGHT] = fbCombineSoftLightU;
     imp->combine_width[PIXMAN_OP_DIFFERENCE] = fbCombineDifferenceU;
     imp->combine_width[PIXMAN_OP_EXCLUSION] = fbCombineExclusionU;
-    imp->combine_width[PIXMAN_OP_SUBTRACT] = fbCombineSubtractU;
     imp->combine_width[PIXMAN_OP_HSL_HUE] = fbCombineHSLHueU;
     imp->combine_width[PIXMAN_OP_HSL_SATURATION] = fbCombineHSLSaturationU;
     imp->combine_width[PIXMAN_OP_HSL_COLOR] = fbCombineHSLColorU;
     imp->combine_width[PIXMAN_OP_HSL_LUMINOSITY] = fbCombineHSLLuminosityU;
+    imp->combine_width[PIXMAN_OP_FLASH_SUBTRACT] = fbCombineFlashSubtractU;
 
     /* Component alpha combiners */
     imp->combine_width_ca[PIXMAN_OP_CLEAR] = fbCombineClearC;
@@ -2073,11 +2080,11 @@ _pixman_setup_combiner_functions_width (pixman_implementation_t *imp)
     imp->combine_width_ca[PIXMAN_OP_SOFT_LIGHT] = fbCombineSoftLightC;
     imp->combine_width_ca[PIXMAN_OP_DIFFERENCE] = fbCombineDifferenceC;
     imp->combine_width_ca[PIXMAN_OP_EXCLUSION] = fbCombineExclusionC;
-    imp->combine_width_ca[PIXMAN_OP_SUBTRACT] = fbCombineSubtractC;
     imp->combine_width_ca[PIXMAN_OP_HSL_HUE] = fbCombineHSLHueC;
     imp->combine_width_ca[PIXMAN_OP_HSL_SATURATION] = fbCombineHSLSaturationC;
     imp->combine_width_ca[PIXMAN_OP_HSL_COLOR] = fbCombineHSLColorC;
     imp->combine_width_ca[PIXMAN_OP_HSL_LUMINOSITY] = fbCombineHSLLuminosityC;
+    imp->combine_width_ca[PIXMAN_OP_FLASH_SUBTRACT] = fbCombineFlashSubtractC;
 }
 
 
index b9ecde0..93e3d11 100644 (file)
@@ -379,11 +379,11 @@ typedef enum
     PIXMAN_OP_SOFT_LIGHT                = 0x38,
     PIXMAN_OP_DIFFERENCE                = 0x39,
     PIXMAN_OP_EXCLUSION                 = 0x3a,
-    PIXMAN_OP_SUBTRACT                 = 0x3b,
-    PIXMAN_OP_HSL_HUE                  = 0x3c,
-    PIXMAN_OP_HSL_SATURATION           = 0x3d,
-    PIXMAN_OP_HSL_COLOR                        = 0x3e,
-    PIXMAN_OP_HSL_LUMINOSITY           = 0x3f,
+    PIXMAN_OP_HSL_HUE                  = 0x3b,
+    PIXMAN_OP_HSL_SATURATION           = 0x3c,
+    PIXMAN_OP_HSL_COLOR                        = 0x3d,
+    PIXMAN_OP_HSL_LUMINOSITY           = 0x3e,
+    PIXMAN_OP_FLASH_SUBTRACT           = 0x3f,
 
     PIXMAN_OP_NONE,
     PIXMAN_OP_LAST = PIXMAN_OP_NONE