pixman: Branch 'master' - 5 commits

Søren Sandmann Pedersen sandmann at kemper.freedesktop.org
Thu Dec 13 03:36:28 PST 2012


 demos/conical-test.c            |   38 +---------------------------
 demos/radial-test.c             |   12 ++++++++
 pixman/pixman-radial-gradient.c |    6 ++--
 test/utils.c                    |   54 ++++++++++++++++++++++++++++++++++++++++
 test/utils.h                    |    5 +++
 5 files changed, 75 insertions(+), 40 deletions(-)

New commits:
commit 526dc06e5694172abf979c03a5cf530207fe2d27
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Sat Dec 8 06:06:34 2012 -0500

    demos/radial-test: Add checkerboard to display the alpha channel

diff --git a/demos/radial-test.c b/demos/radial-test.c
index 203ad68..08a367c 100644
--- a/demos/radial-test.c
+++ b/demos/radial-test.c
@@ -147,6 +147,8 @@ main (int argc, char **argv)
 					 WIDTH, HEIGHT,
 					 NULL, 0);
 
+    draw_checkerboard (dest_img, 25, 0xffaaaaaa, 0xffbbbbbb);
+    
     pixman_transform_init_identity (&transform);
 
     /*
commit 6402b2aa0c2215a5add233b3c1bc2ae634d43aaf
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Sat Dec 8 06:46:38 2012 -0500

    demos/conical-test: Use the draw_checkerboard() utility function
    
    Instead of having its own copy.

diff --git a/demos/conical-test.c b/demos/conical-test.c
index 1e08e42..6b32430 100644
--- a/demos/conical-test.c
+++ b/demos/conical-test.c
@@ -46,40 +46,6 @@ create_conical (int index)
 	&c, pixman_double_to_fixed (angle), stops, NUM_STOPS);
 }
 
-#define CHECK_SIZE 25
-
-static void
-fill_checkerboard (pixman_image_t *image, int width, int height)
-{
-#define C1 0xaaaa
-#define C2 0x8888
-
-    pixman_color_t check1 = { C1, C1, C1, 0xffff };
-    pixman_color_t check2 = { C2, C2, C2, 0xffff };
-    pixman_image_t *c1, *c2;
-    int i, j;
-
-    c1 = pixman_image_create_solid_fill (&check1);
-    c2 = pixman_image_create_solid_fill (&check2);
-
-    for (j = 0; j < height; j += CHECK_SIZE)
-    {
-	for (i = 0; i < width; i += CHECK_SIZE)
-	{
-	    pixman_image_t *src;
-
-	    if ((((i / CHECK_SIZE) ^ (j / CHECK_SIZE)) & 1) == 0)
-		src = c1;
-	    else
-		src = c2;
-	    
-	    pixman_image_composite32 (PIXMAN_OP_SRC, src, NULL, image,
-				      0, 0, 0, 0, i, j,
-				      CHECK_SIZE, CHECK_SIZE);
-	}
-    }
-}
-
 int
 main (int argc, char **argv)
 {
@@ -92,8 +58,8 @@ main (int argc, char **argv)
     dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
 					 WIDTH, HEIGHT,
 					 NULL, 0);
-
-    fill_checkerboard (dest_img, WIDTH, HEIGHT);
+ 
+    draw_checkerboard (dest_img, 25, 0xffaaaaaa, 0xff888888);
 
     pixman_transform_init_identity (&transform);
 
commit e382e52d675a4ae86ed94ab1124ea7d98c3db75a
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Sat Dec 8 06:44:24 2012 -0500

    test/utils.[ch]: Add utility function to draw a checkerboard
    
    This is useful in demo programs to display the alpha channel.

diff --git a/test/utils.c b/test/utils.c
index 66c8dcb..08eaabb 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -548,6 +548,60 @@ write_png (pixman_image_t *image, const char *filename)
 
 #endif
 
+static void
+color8_to_color16 (uint32_t color8, pixman_color_t *color16)
+{
+    color16->alpha = ((color8 & 0xff000000) >> 24);
+    color16->red =   ((color8 & 0x00ff0000) >> 16);
+    color16->green = ((color8 & 0x0000ff00) >> 8);
+    color16->blue =  ((color8 & 0x000000ff) >> 0);
+
+    color16->alpha |= color16->alpha << 8;
+    color16->red   |= color16->red << 8;
+    color16->blue  |= color16->blue << 8;
+    color16->green |= color16->green << 8;
+}
+
+void
+draw_checkerboard (pixman_image_t *image,
+		   int check_size,
+		   uint32_t color1, uint32_t color2)
+{
+    pixman_color_t check1, check2;
+    pixman_image_t *c1, *c2;
+    int n_checks_x, n_checks_y;
+    int i, j;
+
+    color8_to_color16 (color1, &check1);
+    color8_to_color16 (color2, &check2);
+    
+    c1 = pixman_image_create_solid_fill (&check1);
+    c2 = pixman_image_create_solid_fill (&check2);
+
+    n_checks_x = (
+	pixman_image_get_width (image) + check_size - 1) / check_size;
+    n_checks_y = (
+	pixman_image_get_height (image) + check_size - 1) / check_size;
+
+    for (j = 0; j < n_checks_y; j++)
+    {
+	for (i = 0; i < n_checks_x; i++)
+	{
+	    pixman_image_t *src;
+
+	    if (((i ^ j) & 1))
+		src = c1;
+	    else
+		src = c2;
+
+	    pixman_image_composite32 (PIXMAN_OP_SRC, src, NULL, image,
+				      0, 0, 0, 0,
+				      i * check_size, j * check_size,
+				      check_size, check_size);
+	}
+    }
+}
+
 /*
  * A function, which can be used as a core part of the test programs,
  * intended to detect various problems with the help of fuzzing input
diff --git a/test/utils.h b/test/utils.h
index 78cf0d1..45b457e 100644
--- a/test/utils.h
+++ b/test/utils.h
@@ -124,6 +124,11 @@ a8r8g8b8_to_rgba_np (uint32_t *dst, uint32_t *src, int n_pixels);
 pixman_bool_t
 write_png (pixman_image_t *image, const char *filename);
 
+void
+draw_checkerboard (pixman_image_t *image,
+		   int check_size,
+		   uint32_t color1, uint32_t color2);
+
 /* A pair of macros which can help to detect corruption of
  * floating point registers after a function call. This may
  * happen if _mm_empty() call is forgotten in MMX/SSE2 fast
commit b0a6504122ba4f585fb60626ec71bf613fc64fae
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Fri Dec 7 19:51:19 2012 -0500

    radial: When comparing t to mindr, use >= rather than >
    
    Radial gradients are conceptually rendered as a sequence of circles
    generated by linearly extrapolating from the two circles given by the
    gradient specification. Any circles in that sequence that would end up
    with a negative radius are not drawn, a condition that is enforced by
    checking that t * dr is bigger than mindr:
    
         if (t * dr > mindr)
    
    However, it is legitimate for a circle to have radius exactly 0, so
    the test should use >= rather than >.
    
    This gets rid of the dots in demos/radial-test except for when the c2
    circle has radius 0 and a repeat mode of either NONE or NORMAL. Both
    those dots correspond to a t value of 1.0, which is outside the
    defined interval of [0.0, 1.0) and therefore subject to the repeat
    algorithm. As a result, in the NONE case, a value of 1.0 turns into
    transparent black. In the NORMAL case, 1.0 wraps around and becomes
    0.0 which is red, unlike 0.99 which is blue.
    
    Cc: ranma42 at gmail.com

diff --git a/pixman/pixman-radial-gradient.c b/pixman/pixman-radial-gradient.c
index 8d56246..6a21796 100644
--- a/pixman/pixman-radial-gradient.c
+++ b/pixman/pixman-radial-gradient.c
@@ -109,7 +109,7 @@ radial_compute_color (double                    a,
 	}
 	else
 	{
-	    if (t * dr > mindr)
+	    if (t * dr >= mindr)
 		return _pixman_gradient_walker_pixel (walker, t);
 	}
 
@@ -145,9 +145,9 @@ radial_compute_color (double                    a,
 	}
 	else
 	{
-	    if (t0 * dr > mindr)
+	    if (t0 * dr >= mindr)
 		return _pixman_gradient_walker_pixel (walker, t0);
-	    else if (t1 * dr > mindr)
+	    else if (t1 * dr >= mindr)
 		return _pixman_gradient_walker_pixel (walker, t1);
 	}
     }
commit 54aca22058e8f4daf999b37e5c5e6ddd8e67f811
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Fri Dec 7 19:43:53 2012 -0500

    demos/radial-test: Add zero-radius circles to demonstrate rendering bugs
    
    Add two new gradient columns, one where the start circle is has radius
    0 and one where the end circle has radius 0. All the new gradients
    except for one are rendered with a bright dot in the middle. In most
    but not all cases this is incorrect.
    
    Cc: ranma42 at gmail.com

diff --git a/demos/radial-test.c b/demos/radial-test.c
index e64f357..203ad68 100644
--- a/demos/radial-test.c
+++ b/demos/radial-test.c
@@ -1,7 +1,7 @@
 #include "../test/utils.h"
 #include "gtk-utils.h"
 
-#define NUM_GRADIENTS 7
+#define NUM_GRADIENTS 9
 #define NUM_STOPS 3
 #define NUM_REPEAT 4
 #define SIZE 128
@@ -28,6 +28,9 @@
  * centers (0, 0) and (1, 0), but with different radiuses. From left
  * to right:
  *
+ * - Degenerate start circle completely inside the end circle
+ *     0.00 -> 1.75; dr = 1.75 > 0; a = 1 - 1.75^2 < 0
+ *
  * - Small start circle completely inside the end circle
  *     0.25 -> 1.75; dr =  1.5 > 0; a = 1 - 1.50^2 < 0
  *
@@ -49,15 +52,20 @@
  * - Small end circle completely inside the start circle
  *     1.75 -> 0.25; dr = -1.5 > 0; a = 1 - 1.50^2 < 0
  *
+ * - Degenerate end circle completely inside the start circle
+ *     0.00 -> 1.75; dr = 1.75 > 0; a = 1 - 1.75^2 < 0
+ *
  */
 
 const static double radiuses[NUM_GRADIENTS] = {
+    0.00,
     0.25,
     0.50,
     0.50,
     1.00,
     1.00,
     1.50,
+    1.75,
     1.75
 };
 


More information about the xorg-commit mailing list