pixman: Branch 'master' - 8 commits

Søren Sandmann Pedersen sandmann at kemper.freedesktop.org
Mon Oct 11 09:13:36 PDT 2010


 pixman/pixman-combine.c.template |   45 +++---
 test/Makefile.am                 |    4 
 test/alphamap.c                  |   16 ++
 test/blitters-test.c             |    2 
 test/composite.c                 |  261 ++++++++++++++++++++-------------------
 5 files changed, 180 insertions(+), 148 deletions(-)

New commits:
commit e46be417cebac984a858da05e61d924889695c9e
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Fri Oct 8 07:44:20 2010 -0400

    Plug leak in the alphamap test.
    
    The images are being created with non-NULL data, so we have to free it
    outselves. This is important because the Cygwin tinderbox is running
    out of memory and produces this:
    
        mmap failed on 20000 1507328
        mmap failed on 40000 1507328
        mmap failed on 20000 1507328
        mmap failed on 40000 1507328
        mmap failed on 40000 1507328
        mmap failed on 40000 1507328
    
    http://tinderbox.x.org/builds/2010-10-05-0014/logs/pixman/#check

diff --git a/test/alphamap.c b/test/alphamap.c
index 09de387..6013e63 100644
--- a/test/alphamap.c
+++ b/test/alphamap.c
@@ -45,15 +45,29 @@ format_name (pixman_format_code_t format)
     return "<unknown - bug in alphamap.c>";
 }
 
+static void
+on_destroy (pixman_image_t *image, void *data)
+{
+    uint32_t *bits = pixman_image_get_data (image);
+
+    fence_free (bits);
+}
+
 static pixman_image_t *
 make_image (pixman_format_code_t format)
 {
     uint32_t *bits;
     uint8_t bpp = PIXMAN_FORMAT_BPP (format) / 8;
+    pixman_image_t *image;
 
     bits = (uint32_t *)make_random_bytes (WIDTH * HEIGHT * bpp);
 
-    return pixman_image_create_bits (format, WIDTH, HEIGHT, bits, WIDTH * bpp);
+    image = pixman_image_create_bits (format, WIDTH, HEIGHT, bits, WIDTH * bpp);
+
+    if (image && bits)
+	pixman_image_set_destroy_function (image, on_destroy, NULL);
+
+    return image;
 }
 
 static pixman_image_t *
commit 6ed7164de5f74b752d85834b53e89810f1d0a560
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Wed Oct 6 02:40:39 2010 -0400

    Add no-op combiners for DST and the CA versions of the HSL operators.
    
    We already exit early for DST, but for the HSL operators with
    component alpha, we crash at the moment. Fix that by adding a dummy
    combine_dst() function.

diff --git a/pixman/pixman-combine.c.template b/pixman/pixman-combine.c.template
index 0d3b95d..56dfb43 100644
--- a/pixman/pixman-combine.c.template
+++ b/pixman/pixman-combine.c.template
@@ -133,6 +133,17 @@ combine_clear (pixman_implementation_t *imp,
 }
 
 static void
+combine_dst (pixman_implementation_t *imp,
+	     pixman_op_t	      op,
+	     comp4_t *		      dest,
+	     const comp4_t *	      src,
+	     const comp4_t *          mask,
+	     int		      width)
+{
+    return;
+}
+
+static void
 combine_src_u (pixman_implementation_t *imp,
                pixman_op_t              op,
                comp4_t *                dest,
@@ -2310,7 +2321,7 @@ _pixman_setup_combiner_functions_width (pixman_implementation_t *imp)
     /* Unified alpha */
     imp->combine_width[PIXMAN_OP_CLEAR] = combine_clear;
     imp->combine_width[PIXMAN_OP_SRC] = combine_src_u;
-    /* dest */
+    imp->combine_width[PIXMAN_OP_DST] = combine_dst;
     imp->combine_width[PIXMAN_OP_OVER] = combine_over_u;
     imp->combine_width[PIXMAN_OP_OVER_REVERSE] = combine_over_reverse_u;
     imp->combine_width[PIXMAN_OP_IN] = combine_in_u;
@@ -2326,7 +2337,7 @@ _pixman_setup_combiner_functions_width (pixman_implementation_t *imp)
     /* Disjoint, unified */
     imp->combine_width[PIXMAN_OP_DISJOINT_CLEAR] = combine_clear;
     imp->combine_width[PIXMAN_OP_DISJOINT_SRC] = combine_src_u;
-    /* dest */
+    imp->combine_width[PIXMAN_OP_DISJOINT_DST] = combine_dst;
     imp->combine_width[PIXMAN_OP_DISJOINT_OVER] = combine_disjoint_over_u;
     imp->combine_width[PIXMAN_OP_DISJOINT_OVER_REVERSE] = combine_saturate_u;
     imp->combine_width[PIXMAN_OP_DISJOINT_IN] = combine_disjoint_in_u;
@@ -2340,7 +2351,7 @@ _pixman_setup_combiner_functions_width (pixman_implementation_t *imp)
     /* Conjoint, unified */
     imp->combine_width[PIXMAN_OP_CONJOINT_CLEAR] = combine_clear;
     imp->combine_width[PIXMAN_OP_CONJOINT_SRC] = combine_src_u;
-    /* dest */
+    imp->combine_width[PIXMAN_OP_CONJOINT_DST] = combine_dst;
     imp->combine_width[PIXMAN_OP_CONJOINT_OVER] = combine_conjoint_over_u;
     imp->combine_width[PIXMAN_OP_CONJOINT_OVER_REVERSE] = combine_conjoint_over_reverse_u;
     imp->combine_width[PIXMAN_OP_CONJOINT_IN] = combine_conjoint_in_u;
@@ -2386,7 +2397,7 @@ _pixman_setup_combiner_functions_width (pixman_implementation_t *imp)
     /* Disjoint CA */
     imp->combine_width_ca[PIXMAN_OP_DISJOINT_CLEAR] = combine_clear_ca;
     imp->combine_width_ca[PIXMAN_OP_DISJOINT_SRC] = combine_src_ca;
-    /* dest */
+    imp->combine_width_ca[PIXMAN_OP_DISJOINT_DST] = combine_dst;
     imp->combine_width_ca[PIXMAN_OP_DISJOINT_OVER] = combine_disjoint_over_ca;
     imp->combine_width_ca[PIXMAN_OP_DISJOINT_OVER_REVERSE] = combine_saturate_ca;
     imp->combine_width_ca[PIXMAN_OP_DISJOINT_IN] = combine_disjoint_in_ca;
@@ -2400,7 +2411,7 @@ _pixman_setup_combiner_functions_width (pixman_implementation_t *imp)
     /* Conjoint CA */
     imp->combine_width_ca[PIXMAN_OP_CONJOINT_CLEAR] = combine_clear_ca;
     imp->combine_width_ca[PIXMAN_OP_CONJOINT_SRC] = combine_src_ca;
-    /* dest */
+    imp->combine_width_ca[PIXMAN_OP_CONJOINT_DST] = combine_dst;
     imp->combine_width_ca[PIXMAN_OP_CONJOINT_OVER] = combine_conjoint_over_ca;
     imp->combine_width_ca[PIXMAN_OP_CONJOINT_OVER_REVERSE] = combine_conjoint_over_reverse_ca;
     imp->combine_width_ca[PIXMAN_OP_CONJOINT_IN] = combine_conjoint_in_ca;
@@ -2423,10 +2434,10 @@ _pixman_setup_combiner_functions_width (pixman_implementation_t *imp)
     imp->combine_width_ca[PIXMAN_OP_DIFFERENCE] = combine_difference_ca;
     imp->combine_width_ca[PIXMAN_OP_EXCLUSION] = combine_exclusion_ca;
 
-    /* It is not clear that these make sense, so leave them out for now */
-    imp->combine_width_ca[PIXMAN_OP_HSL_HUE] = NULL;
-    imp->combine_width_ca[PIXMAN_OP_HSL_SATURATION] = NULL;
-    imp->combine_width_ca[PIXMAN_OP_HSL_COLOR] = NULL;
-    imp->combine_width_ca[PIXMAN_OP_HSL_LUMINOSITY] = NULL;
+    /* It is not clear that these make sense, so make them noops for now */
+    imp->combine_width_ca[PIXMAN_OP_HSL_HUE] = combine_dst;
+    imp->combine_width_ca[PIXMAN_OP_HSL_SATURATION] = combine_dst;
+    imp->combine_width_ca[PIXMAN_OP_HSL_COLOR] = combine_dst;
+    imp->combine_width_ca[PIXMAN_OP_HSL_LUMINOSITY] = combine_dst;
 }
 
commit 233b27257b63ecd502c6392e5ef3a7f736f14365
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Tue Oct 5 11:05:25 2010 -0400

    test: Add some more colors to the color table in composite.c
    
    Specifically, add transparent black and superluminescent white with
    alpha = 0.

diff --git a/test/composite.c b/test/composite.c
index 216046f..5cdc521 100644
--- a/test/composite.c
+++ b/test/composite.c
@@ -54,10 +54,12 @@ struct format_t
 static const color_t colors[] =
 {
     { 1.0, 1.0, 1.0, 1.0 },
+    { 1.0, 1.0, 1.0, 0.0 },
+    { 0.0, 0.0, 0.0, 1.0 },
+    { 0.0, 0.0, 0.0, 0.0 },
     { 1.0, 0.0, 0.0, 1.0 },
     { 0.0, 1.0, 0.0, 1.0 },
     { 0.0, 0.0, 1.0, 1.0 },
-    { 0.0, 0.0, 0.0, 1.0 },
     { 0.5, 0.0, 0.0, 0.5 },
 };
 
commit 3f7da59352b604bd6974230d0b149e8e7da77b5c
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Tue Oct 5 09:49:45 2010 -0400

    test: Parallize composite.c with OpenMP
    
    Each test uses the test number as the random number seed; if it
    didn't, all the threads would run the same tests since they would all
    start from the same seed.

diff --git a/test/composite.c b/test/composite.c
index 3a06c09..216046f 100644
--- a/test/composite.c
+++ b/test/composite.c
@@ -891,15 +891,17 @@ main (int argc, char **argv)
 	    return -1;
 	}
     }
-    
+
+#ifdef USE_OPENMP
+#   pragma omp parallel for default(none) shared(result) shared(argv) 
+#endif
     for (i = 1; i <= N_TESTS; ++i)
     {
-	if (!run_test (i))
+	if (!result && !run_test (i))
 	{
 	    printf ("Test %d failed.\n", i);
-	    
+
 	    result = i;
-	    break;
 	}
     }
     
commit a10ccc9f303ca6b4577afe68cc6b2d8840de5a27
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Sun Mar 7 11:26:16 2010 -0500

    test: Change composite so that it tests randomly generated images
    
    Previously this test would try to exhaustively test all combinations
    of formats and operators, which meant that it would take hours to run.
    Instead, generate images randomly and test compositing those.
    
    Cc: chris at chris-wilson.co.uk

diff --git a/test/Makefile.am b/test/Makefile.am
index 119ba15..5d2a26a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -23,7 +23,6 @@ TESTPROGRAMS =			\
 
 a1_trap_test_LDADD = $(TEST_LDADD)
 fetch_test_LDADD = $(TEST_LDADD)
-composite_LDADD = $(TEST_LDADD)
 gradient_crash_test_LDADD = $(TEST_LDADD)
 trap_crasher_LDADD = $(TEST_LDADD)
 oob_test_LDADD = $(TEST_LDADD)
@@ -49,6 +48,9 @@ alphamap_SOURCES = alphamap.c utils.c utils.h
 alpha_loop_LDADD = $(TEST_LDADD)
 alpha_loop_SOURCES = alpha-loop.c utils.c utils.h
 
+composite_LDADD = $(TEST_LDADD)
+composite_SOURCES = composite.c utils.c utils.h
+
 # GTK using test programs
 
 if HAVE_GTK
diff --git a/test/composite.c b/test/composite.c
index 227d269..3a06c09 100644
--- a/test/composite.c
+++ b/test/composite.c
@@ -22,15 +22,14 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-
+#define PIXMAN_USE_INTERNAL_API
 #include <pixman.h>
 #include <stdio.h>
 #include <stdlib.h> /* abort() */
 #include <math.h>
 #include <config.h>
-
-#define FALSE 0
-#define TRUE !FALSE
+#include <time.h>
+#include "utils.h"
 
 #define ARRAY_LENGTH(A) ((int) (sizeof (A) / sizeof ((A) [0])))
 #define min(a,b) ((a) <= (b) ? (a) : (b))
@@ -52,9 +51,8 @@ struct format_t
     const char *name;
 };
 
-static color_t colors[] =
+static const color_t colors[] =
 {
-    /* these are premultiplied in main() */
     { 1.0, 1.0, 1.0, 1.0 },
     { 1.0, 0.0, 0.0, 1.0 },
     { 0.0, 1.0, 0.0, 1.0 },
@@ -84,6 +82,17 @@ compute_pixman_color (const color_t *color,
     out->alpha = _color_double_to_short (color->a);
 }
 
+#define REPEAT 0x01000000
+#define FLAGS  0xff000000
+
+static const int sizes[] =
+{
+    0,
+    1,
+    1 | REPEAT,
+    10
+};
+
 static const format_t formats[] =
 {
 #define P(x) { PIXMAN_##x, #x }
@@ -694,6 +703,11 @@ composite_test (image_t *dst,
     color_correct (dst->format->format, &expected);
 
     diff = eval_diff (&expected, &result, dst->format->format);
+
+    /* FIXME: We should find out what deviation is acceptable. 3.0
+     * is clearly absurd for 2 bit formats for example. On the other
+     * hand currently 1.0 does not work.
+     */
     if (diff > 3.0)
     {
 	char buf[40];
@@ -711,7 +725,7 @@ composite_test (image_t *dst,
 		result.r, result.g, result.b, result.a,
 		*(unsigned long *) pixman_image_get_data (dst->image),
 		expected.r, expected.g, expected.b, expected.a);
-	
+
 	if (mask != NULL)
 	{
 	    printf ("src color: %.2f %.2f %.2f %.2f\n"
@@ -745,9 +759,6 @@ composite_test (image_t *dst,
     return success;
 }
 
-#define REPEAT 0x01000000
-#define FLAGS  0xff000000
-
 static void
 image_init (image_t *info,
 	    int color,
@@ -760,7 +771,7 @@ image_init (image_t *info,
     compute_pixman_color (info->color, &fill);
 
     info->format = &formats[format];
-    info->size = size & ~FLAGS;
+    info->size = sizes[size] & ~FLAGS;
     info->repeat = PIXMAN_REPEAT_NONE;
 
     if (info->size)
@@ -794,103 +805,103 @@ image_fini (image_t *info)
     pixman_image_unref (info->image);
 }
 
-int
-main (void)
+static int
+random_size (void)
+{
+    return lcg_rand_n (ARRAY_LENGTH (sizes));
+}
+
+static int
+random_color (void)
+{
+    return lcg_rand_n (ARRAY_LENGTH (colors));
+}
+
+static int
+random_format (void)
 {
-    pixman_bool_t ok, group_ok = TRUE, ca;
-    int i, d, m, s;
-    int tests_passed = 0, tests_total = 0;
-    int sizes[] = { 1, 1 | REPEAT, 10 };
-    int num_tests;
+    return lcg_rand_n (ARRAY_LENGTH (formats));
+}
+
+static pixman_bool_t
+run_test (uint32_t seed)
+{
+    image_t src, mask, dst;
+    const operator_t *op;
+    int ca;
+    int ok;
+
+    lcg_srand (seed);
+    
+    image_init (&dst, random_color(), random_format(), 1);
+    image_init (&src, random_color(), random_format(), random_size());
+    image_init (&mask, random_color(), random_format(), random_size());
+
+    op = &(operators [lcg_rand_n (ARRAY_LENGTH (operators))]);
+
+    ca = lcg_rand_n (3);
 
-    for (i = 0; i < ARRAY_LENGTH (colors); i++)
+    switch (ca)
     {
-	colors[i].r *= colors[i].a;
-	colors[i].g *= colors[i].a;
-	colors[i].b *= colors[i].a;
+    case 0:
+	ok = composite_test (&dst, op, &src, NULL, FALSE);
+	break;
+    case 1:
+	ok = composite_test (&dst, op, &src, &mask, FALSE);
+	break;
+    case 2:
+	ok = composite_test (&dst, op, &src, &mask,
+			     mask.size? TRUE : FALSE);
+	break;
+    default:
+	ok = FALSE;
+	break;
     }
 
-    num_tests = ARRAY_LENGTH (colors) * ARRAY_LENGTH (formats);
+    image_fini (&src);
+    image_fini (&mask);
+    image_fini (&dst);
 
-    for (d = 0; d < num_tests; d++)
-    {
-	image_t dst;
+    return ok;
+}
 
-	image_init (
-	    &dst, d / ARRAY_LENGTH (formats), d % ARRAY_LENGTH (formats), 1);
+int
+main (int argc, char **argv)
+{
+#define N_TESTS (8 * 1024 * 1024)
+    int result = 0;
+    int i;
 
+    if (argc > 1)
+    {
+	char *end;
+	
+	i = strtol (argv[1], &end, 0);
 
-	for (s = -ARRAY_LENGTH (colors);
-	     s < ARRAY_LENGTH (sizes) * num_tests;
-	     s++)
+	if (end != argv[1])
 	{
-	    image_t src;
-
-	    if (s < 0)
-	    {
-		image_init (&src, -s - 1, 0, 0);
-	    }
+	    if (!run_test (i))
+		return 1;
 	    else
-	    {
-		image_init (&src,
-			    s / ARRAY_LENGTH (sizes) / ARRAY_LENGTH (formats),
-			    s / ARRAY_LENGTH (sizes) % ARRAY_LENGTH (formats),
-			    sizes[s % ARRAY_LENGTH (sizes)]);
-	    }
-
-	    for (m = -ARRAY_LENGTH (colors);
-		 m < ARRAY_LENGTH (sizes) * num_tests;
-		 m++)
-	    {
-		image_t mask;
-
-		if (m < 0)
-		{
-		    image_init (&mask, -m - 1, 0, 0);
-		}
-		else
-		{
-		    image_init (
-			&mask,
-			m / ARRAY_LENGTH (sizes) / ARRAY_LENGTH (formats),
-			m / ARRAY_LENGTH (sizes) % ARRAY_LENGTH (formats),
-			sizes[m % ARRAY_LENGTH (sizes)]);
-		}
-
-		for (ca = -1; ca <= 1; ca++)
-		{
-		    for (i = 0; i < ARRAY_LENGTH (operators); i++)
-		    {
-			const operator_t *op = &operators[i];
-
-			switch (ca)
-			{
-			case -1:
-			    ok = composite_test (&dst, op, &src, NULL, FALSE);
-			    break;
-			case 0:
-			    ok = composite_test (&dst, op, &src, &mask, FALSE);
-			    break;
-			case 1:
-			    ok = composite_test (&dst, op, &src, &mask,
-						 mask.size? TRUE : FALSE);
-			    break;
-                        default:
-			    ok = FALSE; /* Silence GCC */
-                            break;
-			}
-			group_ok = group_ok && ok;
-			tests_passed += ok;
-			tests_total++;
-		    }
-		}
-
-		image_fini (&mask);
-	    }
-	    image_fini (&src);
+		return 0;
+	}
+	else
+	{
+	    printf ("Usage:\n\n   %s <number>\n\n", argv[0]);
+	    return -1;
 	}
-	image_fini (&dst);
     }
-
-    return group_ok == FALSE;
+    
+    for (i = 1; i <= N_TESTS; ++i)
+    {
+	if (!run_test (i))
+	{
+	    printf ("Test %d failed.\n", i);
+	    
+	    result = i;
+	    break;
+	}
+    }
+    
+    return result;
 }
commit 55e4065cbbc5ffe2ce1986b51ef63e8a0b50fccb
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Sun Mar 7 11:24:30 2010 -0500

    test: Fix eval_diff() so that it provides useful error values.
    
    Previously, this function would evaluate the error under the
    assumption that the format was 565 or wider. This patch changes it to
    take the actual format into account.
    
    With that fixed, we can turn on testing for the rest of the formats.
    
    Cc: chris at chris-wilson.co.uk

diff --git a/test/composite.c b/test/composite.c
index c0c6371..227d269 100644
--- a/test/composite.c
+++ b/test/composite.c
@@ -88,7 +88,7 @@ static const format_t formats[] =
 {
 #define P(x) { PIXMAN_##x, #x }
 
-    /* 32bpp formats */
+    /* 32 bpp formats */
     P(a8r8g8b8),
     P(x8r8g8b8),
     P(a8b8g8r8),
@@ -97,30 +97,18 @@ static const format_t formats[] =
     P(b8g8r8x8),
     P(x2r10g10b10),
     P(x2b10g10r10),
+    P(a2r10g10b10),
+    P(a2b10g10r10),
 
-    /* 24bpp formats */
+    /* 24 bpp formats */
     P(r8g8b8),
     P(b8g8r8),
     P(r5g6b5),
     P(b5g6r5),
 
-    /* 16bpp formats */
+    /* 16 bpp formats */
     P(x1r5g5b5),
     P(x1b5g5r5),
-
-    /* 8bpp formats */
-    P(a8),
-
-#if 0
-    /* XXX: and here the errors begin!
-     *
-     * The formats below all have channels with 4 bits or less, and
-     * the eval_diff code doesn't deal correctly with that.
-     */
-    P(a2r10g10b10),
-    P(a2b10g10r10),
-
-    /* 16bpp formats */
     P(a1r5g5b5),
     P(a1b5g5r5),
     P(a4b4g4r4),
@@ -128,24 +116,23 @@ static const format_t formats[] =
     P(a4r4g4b4),
     P(x4r4g4b4),
 
-    /* 8bpp formats */
+    /* 8 bpp formats */
+    P(a8),
     P(r3g3b2),
     P(b2g3r3),
     P(a2r2g2b2),
     P(a2b2g2r2),
-
     P(x4a4),
 
-    /* 4bpp formats */
+    /* 4 bpp formats */
     P(a4),
     P(r1g2b1),
     P(b1g2r1),
     P(a1r1g1b1),
     P(a1b1g1r1),
 
-    /* 1bpp formats */
+    /* 1 bpp formats */
     P(a1)
-#endif
 #undef P
 };
 
@@ -604,18 +591,15 @@ get_pixel (pixman_image_t *image,
 }
 
 static double
-eval_diff (color_t *expected, color_t *test)
+eval_diff (color_t *expected, color_t *test, pixman_format_code_t format)
 {
     double rscale, gscale, bscale, ascale;
     double rdiff, gdiff, bdiff, adiff;
 
-    /* XXX: Need to be provided mask shifts so we can produce useful error
-     * values.
-     */
-    rscale = 1.0 * (1 << 5);
-    gscale = 1.0 * (1 << 6);
-    bscale = 1.0 * (1 << 5);
-    ascale = 1.0 * 32;
+    rscale = 1.0 * ((1 << PIXMAN_FORMAT_R (format)) - 1);
+    gscale = 1.0 * ((1 << PIXMAN_FORMAT_G (format)) - 1);
+    bscale = 1.0 * ((1 << PIXMAN_FORMAT_B (format)) - 1);
+    ascale = 1.0 * ((1 << PIXMAN_FORMAT_A (format)) - 1);
 
     rdiff = fabs (test->r - expected->r) * rscale;
     bdiff = fabs (test->g - expected->g) * gscale;
@@ -709,7 +693,7 @@ composite_test (image_t *dst,
 		  &expected, component_alpha);
     color_correct (dst->format->format, &expected);
 
-    diff = eval_diff (&expected, &result);
+    diff = eval_diff (&expected, &result, dst->format->format);
     if (diff > 3.0)
     {
 	char buf[40];
commit fe411cf2ac4d5b26a319b906dee87e0cc69d2ad6
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Sun Mar 7 10:31:04 2010 -0500

    test: Fix bug in color_correct() in composite.c
    
    This function was using the number of bits in a channel as if it were
    a mask, which lead to many spurious errors. With that fixed, we can
    turn on testing for all formats where all channels have 5 or more
    bits.
    
    Cc: chris at chris-wilson.co.uk

diff --git a/test/composite.c b/test/composite.c
index b530a20..c0c6371 100644
--- a/test/composite.c
+++ b/test/composite.c
@@ -1,6 +1,8 @@
 /*
  * Copyright © 2005 Eric Anholt
  * Copyright © 2009 Chris Wilson
+ * Copyright © 2010 Soeren Sandmann
+ * Copyright © 2010 Red Hat, Inc.
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -85,7 +87,6 @@ compute_pixman_color (const color_t *color,
 static const format_t formats[] =
 {
 #define P(x) { PIXMAN_##x, #x }
-    P(a8),
 
     /* 32bpp formats */
     P(a8r8g8b8),
@@ -94,33 +95,40 @@ static const format_t formats[] =
     P(x8b8g8r8),
     P(b8g8r8a8),
     P(b8g8r8x8),
-
-    /* XXX: and here the errors begin! */
-#if 0
     P(x2r10g10b10),
-    P(a2r10g10b10),
     P(x2b10g10r10),
-    P(a2b10g10r10),
 
     /* 24bpp formats */
     P(r8g8b8),
     P(b8g8r8),
-
-    /* 16bpp formats */
     P(r5g6b5),
     P(b5g6r5),
 
-    P(a1r5g5b5),
+    /* 16bpp formats */
     P(x1r5g5b5),
-    P(a1b5g5r5),
     P(x1b5g5r5),
-    P(a4r4g4b4),
-    P(x4r4g4b4),
+
+    /* 8bpp formats */
+    P(a8),
+
+#if 0
+    /* XXX: and here the errors begin!
+     *
+     * The formats below all have channels with 4 bits or less, and
+     * the eval_diff code doesn't deal correctly with that.
+     */
+    P(a2r10g10b10),
+    P(a2b10g10r10),
+
+    /* 16bpp formats */
+    P(a1r5g5b5),
+    P(a1b5g5r5),
     P(a4b4g4r4),
     P(x4b4g4r4),
+    P(a4r4g4b4),
+    P(x4r4g4b4),
 
     /* 8bpp formats */
-    P(a8),
     P(r3g3b2),
     P(b2g3r3),
     P(a2r2g2b2),
@@ -482,8 +490,9 @@ static void
 color_correct (pixman_format_code_t format,
 	       color_t *color)
 {
-#define round_pix(pix, mask) \
-    ((int)((pix) * (mask) + .5) / (double) (mask))
+#define MASK(x) ((1 << (x)) - 1)
+#define round_pix(pix, m)						\
+    ((int)((pix) * (MASK(m)) + .5) / (double) (MASK(m)))
 
     if (PIXMAN_FORMAT_R (format) == 0)
     {
@@ -504,6 +513,7 @@ color_correct (pixman_format_code_t format,
 	color->a = round_pix (color->a, PIXMAN_FORMAT_A (format));
 
 #undef round_pix
+#undef MASK
 }
 
 static void
commit 4e89a5b7f3b039fcc86dff7fb8bec79884c913e8
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Tue Oct 5 11:08:42 2010 -0400

    Remove broken optimizations in combine_disjoint_over_u()
    
    The first broken optimization is that it checks "a != 0x00" where it
    should check "s != 0x00". The other is that it skips the computation
    when alpha is 0xff. That is wrong because in the formula:
    
         min (1, (1 - Aa)/Ab)
    
    the render specification states that if Ab is 0, the quotient is
    defined to positive infinity. That is the case even if (1 - Aa) is 0.

diff --git a/pixman/pixman-combine.c.template b/pixman/pixman-combine.c.template
index c129980..0d3b95d 100644
--- a/pixman/pixman-combine.c.template
+++ b/pixman/pixman-combine.c.template
@@ -1296,17 +1296,13 @@ combine_disjoint_over_u (pixman_implementation_t *imp,
 	comp4_t s = combine_mask (src, mask, i);
 	comp2_t a = s >> A_SHIFT;
 
-	if (a != 0x00)
+	if (s != 0x00)
 	{
-	    if (a != MASK)
-	    {
-		comp4_t d = *(dest + i);
-		a = combine_disjoint_out_part (d >> A_SHIFT, a);
-		UNcx4_MUL_UNc_ADD_UNcx4 (d, a, s);
-		s = d;
-	    }
+	    comp4_t d = *(dest + i);
+	    a = combine_disjoint_out_part (d >> A_SHIFT, a);
+	    UNcx4_MUL_UNc_ADD_UNcx4 (d, a, s);
 
-	    *(dest + i) = s;
+	    *(dest + i) = d;
 	}
     }
 }
diff --git a/test/blitters-test.c b/test/blitters-test.c
index 7ba80eb..77a26dd 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -465,6 +465,6 @@ main (int argc, const char *argv[])
     }
 
     return fuzzer_test_main("blitters", 2000000,
-			    0x217CF14A,
+			    0x1DB8BDF8,
 			    test_composite, argc, argv);
 }


More information about the xorg-commit mailing list