pixman: Branch 'master' - 2 commits

Søren Sandmann Pedersen sandmann at kemper.freedesktop.org
Tue Jun 23 14:01:06 PDT 2009


 pixman/pixman-bits-image.c |    4 +--
 test/Makefile.am           |    4 +++
 test/convolution-test.c    |   47 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 2 deletions(-)

New commits:
commit c0047fbfd54d519698a0991111f2440dc8e081b9
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Tue Jun 23 16:55:53 2009 -0400

    Subtract x_off/y_off before conversion to integer.
    
    They are fixed-point values, not integers.
    
    Bug 22437, reported by Michel Dänzer.

diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index 797bf85..e5d0bd0 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -414,8 +414,8 @@ bits_image_fetch_convolution_pixels (bits_image_t *image,
 	    int32_t x, y, x1, x2, y1, y2;
 
 	    /* Subtract pixman_fixed_e to ensure that 0.5 rounds to 0, not 1 */
-	    x1 = pixman_fixed_to_int (coords[0] - pixman_fixed_e) - x_off;
-	    y1 = pixman_fixed_to_int (coords[1] - pixman_fixed_e) - y_off;
+	    x1 = pixman_fixed_to_int (coords[0] - pixman_fixed_e - x_off);
+	    y1 = pixman_fixed_to_int (coords[1] - pixman_fixed_e - y_off);
 	    x2 = x1 + cwidth;
 	    y2 = y1 + cheight;
 
commit 905856f43d38b5f2932d8b459e805e1c86b7a2f3
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Tue Jun 23 16:37:35 2009 -0400

    Add convolution-test.c program

diff --git a/test/Makefile.am b/test/Makefile.am
index 01d065b..2590617 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -25,6 +25,7 @@ TESTPROGRAMS +=			\
 	gradient-test		\
 	alpha-test		\
 	screen-test		\
+	convolution-test	\
 	trap-test
 
 noinst_PROGRAMS = $(TESTPROGRAMS)
@@ -52,5 +53,8 @@ trap_test_SOURCES = trap-test.c utils.c utils.h
 screen_test_LDADD = $(GTK_LDADD)
 screen_test_SOURCES = screen-test.c utils.c utils.h
 
+convolution_test_LDADD = $(GTK_LDADD)
+convolution_test_SOURCES = convolution-test.c utils.c utils.h
+
 endif
 
diff --git a/test/convolution-test.c b/test/convolution-test.c
new file mode 100644
index 0000000..8609d38
--- /dev/null
+++ b/test/convolution-test.c
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "pixman.h"
+#include "utils.h"
+
+int
+main (int argc, char **argv)
+{
+#define WIDTH 200
+#define HEIGHT 200
+
+#define d2f pixman_double_to_fixed
+    
+    uint32_t *src = malloc (WIDTH * HEIGHT * 4);
+    uint32_t *mask = malloc (WIDTH * HEIGHT * 4);
+    uint32_t *dest = malloc (WIDTH * HEIGHT * 4);
+    pixman_fixed_t convolution[] =
+    {
+	d2f (3), d2f (3),
+	d2f (0.5), d2f (0.5), d2f (0.5),
+	d2f (0.5), d2f (0.5), d2f (0.5),
+	d2f (0.5), d2f (0.5), d2f (0.5),
+    };
+    pixman_image_t *simg, *mimg, *dimg;
+
+    int i;
+
+    for (i = 0; i < WIDTH * HEIGHT; ++i)
+    {
+	src[i] = 0x7f007f00;
+	mask[i] = (i % 256) * 0x01000000;
+	dest[i] = 0;
+    }
+
+    simg = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, src, WIDTH * 4);
+    mimg = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, mask, WIDTH * 4);
+    dimg = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, dest, WIDTH * 4);
+
+    pixman_image_set_filter (mimg, PIXMAN_FILTER_CONVOLUTION,
+			     convolution, 11);
+
+    pixman_image_composite (PIXMAN_OP_OVER, simg, mimg, dimg, 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
+
+    show_image (dimg);
+    
+    return 0;
+}


More information about the xorg-commit mailing list