pixman: Branch 'master' - 4 commits

Søren Sandmann Pedersen sandmann at kemper.freedesktop.org
Mon Sep 24 05:47:45 PDT 2012


 pixman/pixman-combine.c.template |   42 +++-----------
 pixman/pixman-image.c            |    4 -
 test/Makefile.sources            |    1 
 test/blitters-test.c             |    2 
 test/rotate-test.c               |  111 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 124 insertions(+), 36 deletions(-)

New commits:
commit f580c4c5b2a435ebe2751ce0dace6c42568557f8
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Fri Sep 21 16:52:16 2012 -0400

    pixman-combine.c.template: Formatting clean-ups
    
    Various formatting fixes, and removal of some obsolete comments about
    strength reduction of operators.

diff --git a/pixman/pixman-combine.c.template b/pixman/pixman-combine.c.template
index 50d2b0a..f405312 100644
--- a/pixman/pixman-combine.c.template
+++ b/pixman/pixman-combine.c.template
@@ -6,10 +6,9 @@
 #include <string.h>
 
 #include "pixman-private.h"
-
 #include "pixman-combine.h"
 
-/*** per channel helper functions ***/
+/* component alpha helper functions */
 
 static void
 combine_mask_ca (comp4_t *src, comp4_t *mask)
@@ -91,15 +90,11 @@ combine_mask_alpha_ca (const comp4_t *src, comp4_t *mask)
 /*
  * There are two ways of handling alpha -- either as a single unified value or
  * a separate value for each component, hence each macro must have two
- * versions.  The unified alpha version has a 'U' at the end of the name,
- * the component version has a 'C'.  Similarly, functions which deal with
+ * versions.  The unified alpha version has a 'u' at the end of the name,
+ * the component version has a 'ca'.  Similarly, functions which deal with
  * this difference will have two versions using the same convention.
  */
 
-/*
- * All of the composing functions
- */
-
 static force_inline comp4_t
 combine_mask (const comp4_t *src, const comp4_t *mask, int i)
 {
@@ -154,7 +149,9 @@ combine_src_u (pixman_implementation_t *imp,
     int i;
 
     if (!mask)
+    {
 	memcpy (dest, src, width * sizeof (comp4_t));
+    }
     else
     {
 	for (i = 0; i < width; ++i)
@@ -166,7 +163,6 @@ combine_src_u (pixman_implementation_t *imp,
     }
 }
 
-/* if the Src is opaque, call combine_src_u */
 static void
 combine_over_u (pixman_implementation_t *imp,
                 pixman_op_t              op,
@@ -188,7 +184,6 @@ combine_over_u (pixman_implementation_t *imp,
     }
 }
 
-/* if the Dst is opaque, this is a noop */
 static void
 combine_over_reverse_u (pixman_implementation_t *imp,
                         pixman_op_t              op,
@@ -209,7 +204,6 @@ combine_over_reverse_u (pixman_implementation_t *imp,
     }
 }
 
-/* if the Dst is opaque, call combine_src_u */
 static void
 combine_in_u (pixman_implementation_t *imp,
               pixman_op_t              op,
@@ -229,7 +223,6 @@ combine_in_u (pixman_implementation_t *imp,
     }
 }
 
-/* if the Src is opaque, this is a noop */
 static void
 combine_in_reverse_u (pixman_implementation_t *imp,
                       pixman_op_t              op,
@@ -250,7 +243,6 @@ combine_in_reverse_u (pixman_implementation_t *imp,
     }
 }
 
-/* if the Dst is opaque, call combine_clear */
 static void
 combine_out_u (pixman_implementation_t *imp,
                pixman_op_t              op,
@@ -270,7 +262,6 @@ combine_out_u (pixman_implementation_t *imp,
     }
 }
 
-/* if the Src is opaque, call combine_clear */
 static void
 combine_out_reverse_u (pixman_implementation_t *imp,
                        pixman_op_t              op,
@@ -291,9 +282,6 @@ combine_out_reverse_u (pixman_implementation_t *imp,
     }
 }
 
-/* if the Src is opaque, call combine_in_u */
-/* if the Dst is opaque, call combine_over_u */
-/* if both the Src and Dst are opaque, call combine_src_u */
 static void
 combine_atop_u (pixman_implementation_t *imp,
                 pixman_op_t              op,
@@ -316,9 +304,6 @@ combine_atop_u (pixman_implementation_t *imp,
     }
 }
 
-/* if the Src is opaque, call combine_over_reverse_u */
-/* if the Dst is opaque, call combine_in_reverse_u */
-/* if both the Src and Dst are opaque, call combine_dst_u */
 static void
 combine_atop_reverse_u (pixman_implementation_t *imp,
                         pixman_op_t              op,
@@ -341,9 +326,6 @@ combine_atop_reverse_u (pixman_implementation_t *imp,
     }
 }
 
-/* if the Src is opaque, call combine_over_u */
-/* if the Dst is opaque, call combine_over_reverse_u */
-/* if both the Src and Dst are opaque, call combine_clear */
 static void
 combine_xor_u (pixman_implementation_t *imp,
                pixman_op_t              op,
@@ -385,9 +367,6 @@ combine_add_u (pixman_implementation_t *imp,
     }
 }
 
-/* if the Src is opaque, call combine_add_u */
-/* if the Dst is opaque, call combine_add_u */
-/* if both the Src and Dst are opaque, call combine_add_u */
 static void
 combine_saturate_u (pixman_implementation_t *imp,
                     pixman_op_t              op,
@@ -444,7 +423,6 @@ combine_saturate_u (pixman_implementation_t *imp,
  * Multiply
  * B(Dca, ad, Sca, as) = Dca.Sca
  */
-
 static void
 combine_multiply_u (pixman_implementation_t *imp,
                     pixman_op_t              op,
@@ -1579,9 +1557,8 @@ combine_conjoint_xor_u (pixman_implementation_t *imp,
     combine_conjoint_general_u (dest, src, mask, width, COMBINE_XOR);
 }
 
-/************************************************************************/
-/*********************** Per Channel functions **************************/
-/************************************************************************/
+
+/* Component alpha combiners */
 
 static void
 combine_clear_ca (pixman_implementation_t *imp,
@@ -2458,4 +2435,3 @@ _pixman_setup_combiner_functions_width (pixman_implementation_t *imp)
     imp->combine_width_ca[PIXMAN_OP_HSL_COLOR] = combine_dst;
     imp->combine_width_ca[PIXMAN_OP_HSL_LUMINOSITY] = combine_dst;
 }
-
commit 58f8704664d1f8c812a85b929a50818f213a8438
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Thu Sep 20 21:43:24 2012 -0400

    Fix bugs in pixman-image.c
    
    In the checks for whether the transforms are rotation matrices "-1"
    and "1" were used instead of the correct -pixman_fixed_1 and
    pixman_fixed_1.
    
    Fixes test suite failure for rotate-test.

diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 15597bd..d9c3034 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -301,9 +301,9 @@ compute_image_info (pixman_image_t *image)
 		pixman_fixed_t m01 = image->common.transform->matrix[0][1];
 		pixman_fixed_t m10 = image->common.transform->matrix[1][0];
 
-		if (m01 == -1 && m10 == 1)
+		if (m01 == -pixman_fixed_1 && m10 == pixman_fixed_1)
 		    flags |= FAST_PATH_ROTATE_90_TRANSFORM;
-		else if (m01 == 1 && m10 == -1)
+		else if (m01 == pixman_fixed_1 && m10 == -pixman_fixed_1)
 		    flags |= FAST_PATH_ROTATE_270_TRANSFORM;
 	    }
 	}
commit 550dfc5e7ecd5b099c1009d77c56cb91a62caeb1
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Thu Sep 20 18:41:33 2012 -0400

    Add rotate-test.c test program
    
    This program exercises a bug in pixman-image.c where "-1" and "1" were
    used instead of the correct "- pixman_fixed_1" and "pixman_fixed_1".
    
    With the fast implementation enabled:
    
         % ./rotate-test
         rotate test failed! (checksum=35A01AAB, expected 03A24D51)
    
    Without it:
    
         % env PIXMAN_DISABLE=fast ./rotate-test
         pixman: Disabled fast implementation
         rotate test passed (checksum=03A24D51)
    
    V2: The first version didn't have lcg_srand (testnum) in test_transform().

diff --git a/test/Makefile.sources b/test/Makefile.sources
index fad8c6f..3e37e32 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -5,6 +5,7 @@ TESTPROGRAMS =			\
 	region-test		\
 	region-translate-test	\
 	fetch-test		\
+	rotate-test		\
 	oob-test		\
 	trap-crasher		\
 	alpha-loop		\
diff --git a/test/rotate-test.c b/test/rotate-test.c
new file mode 100644
index 0000000..bc44281
--- /dev/null
+++ b/test/rotate-test.c
@@ -0,0 +1,111 @@
+#include <stdlib.h>
+#include "utils.h"
+
+#define WIDTH	32
+#define HEIGHT	32
+
+static const pixman_format_code_t formats[] =
+{
+    PIXMAN_a8r8g8b8,
+    PIXMAN_a8b8g8r8,
+    PIXMAN_x8r8g8b8,
+    PIXMAN_x8b8g8r8,
+    PIXMAN_r5g6b5,
+    PIXMAN_b5g6r5,
+    PIXMAN_a8,
+    PIXMAN_a1,
+};
+
+static const pixman_op_t ops[] =
+{
+    PIXMAN_OP_OVER,
+    PIXMAN_OP_SRC,
+    PIXMAN_OP_ADD,
+};
+
+#define TRANSFORM(v00, v01, v10, v11)					\
+    { { { v00, v01, WIDTH * pixman_fixed_1 / 2 },			\
+        { v10, v11, HEIGHT * pixman_fixed_1 / 2 },			\
+	{ 0, 0, pixman_fixed_1 } } }
+
+#define F1 pixman_fixed_1
+
+static const pixman_transform_t transforms[] =
+{
+    TRANSFORM (0, -1, 1, 0),		/* wrong 90 degree rotation */
+    TRANSFORM (0, 1, -1, 0),		/* wrong 270 degree rotation */
+    TRANSFORM (1, 0, 0, 1),		/* wrong identity */
+    TRANSFORM (-1, 0, 0, -1),		/* wrong 180 degree rotation */
+    TRANSFORM (0, -F1, F1, 0),		/* correct 90 degree rotation */
+    TRANSFORM (0, F1, -F1, 0),		/* correct 270 degree rotation */
+    TRANSFORM (F1, 0, 0, F1),		/* correct identity */
+    TRANSFORM (-F1, 0, 0, -F1),		/* correct 180 degree rotation */
+};
+
+#define RANDOM_FORMAT()							\
+    (formats[lcg_rand_n (ARRAY_LENGTH (formats))])
+
+#define RANDOM_OP()							\
+    (ops[lcg_rand_n (ARRAY_LENGTH (ops))])
+
+#define RANDOM_TRANSFORM()						\
+    (&(transforms[lcg_rand_n (ARRAY_LENGTH (transforms))]))
+
+static void
+on_destroy (pixman_image_t *image, void *data)
+{
+    free (data);
+}
+
+static pixman_image_t *
+make_image (void)
+{
+    pixman_format_code_t format = RANDOM_FORMAT();
+    uint32_t *bytes = malloc (WIDTH * HEIGHT * 4);
+    pixman_image_t *image;
+    int i;
+
+    for (i = 0; i < WIDTH * HEIGHT * 4; ++i)
+	((uint8_t *)bytes)[i] = lcg_rand_n (256);
+
+    image = pixman_image_create_bits (
+	format, WIDTH, HEIGHT, bytes, WIDTH * 4);
+
+    pixman_image_set_transform (image, RANDOM_TRANSFORM());
+    pixman_image_set_destroy_function (image, on_destroy, bytes);
+    pixman_image_set_repeat (image, PIXMAN_REPEAT_NORMAL);
+    
+    return image;
+}
+
+static uint32_t
+test_transform (int testnum, int verbose)
+{
+    pixman_image_t *src, *dest;
+    uint32_t crc;
+
+    lcg_srand (testnum);
+    
+    src = make_image ();
+    dest = make_image ();
+
+    pixman_image_composite (RANDOM_OP(),
+			    src, NULL, dest,
+			    0, 0, 0, 0, WIDTH / 2, HEIGHT / 2,
+			    WIDTH, HEIGHT);
+
+    crc = compute_crc32_for_image (0, dest);
+
+    pixman_image_unref (src);
+    pixman_image_unref (dest);
+
+    return crc;
+}
+
+int
+main (int argc, const char *argv[])
+{
+    return fuzzer_test_main ("rotate", 15000,
+			     0x03A24D51,
+			     test_transform, argc, argv);
+}
commit 2ab77c97a5a3a816d6383bdc3b6c8bdceb0383b7
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Wed Sep 19 12:04:11 2012 -0400

    Fix bugs in component alpha combiners for separable PDF operators
    
    In general, the component alpha version of an operator is supposed to
    do this:
    
           - multiply source with mask in all channels
           - multiply mask with source alpha in all channels
           - compute the regular operator in all channels using the
             mask value whenever source alpha is called for
    
    The first two steps are usually accomplished with the function
    combine_mask_ca(), but for operators where source alpha is not used,
    such as SRC, ADD and OUT, the simpler function
    combine_mask_value_ca(), which doesn't compute the new mask values,
    can be used.
    
    However, the PDF blend modes generally *do* make use of source alpha,
    so they can't use combine_mask_value_ca() as they do now. They have to
    use combine_mask_ca().
    
    This patch fixes this in combine_multiply_ca() and the CA combiners
    generated by PDF_SEPARABLE_BLEND_MODE.

diff --git a/pixman/pixman-combine.c.template b/pixman/pixman-combine.c.template
index cd008d9..50d2b0a 100644
--- a/pixman/pixman-combine.c.template
+++ b/pixman/pixman-combine.c.template
@@ -489,7 +489,7 @@ combine_multiply_ca (pixman_implementation_t *imp,
 	comp4_t r = d;
 	comp4_t dest_ia = ALPHA_c (~d);
 
-	combine_mask_value_ca (&s, &m);
+	combine_mask_ca (&s, &m);
 
 	UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (r, ~m, s, dest_ia);
 	UNcx4_MUL_UNcx4 (d, s);
@@ -546,7 +546,7 @@ combine_multiply_ca (pixman_implementation_t *imp,
 	    comp1_t ida = ~da;						\
 	    comp4_t result;						\
             								\
-	    combine_mask_value_ca (&s, &m);				\
+	    combine_mask_ca (&s, &m);					\
             								\
 	    result = d;							\
 	    UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (result, ~m, s, ida);     \
diff --git a/test/blitters-test.c b/test/blitters-test.c
index 6a3cc86..8c46cef 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -395,6 +395,6 @@ main (int argc, const char *argv[])
     }
 
     return fuzzer_test_main("blitters", 2000000,
-			    0xA364B5BF,
+			    0x3E1DD2E8,
 			    test_composite, argc, argv);
 }


More information about the xorg-commit mailing list