[Pixman] [PATCH] Offset rendering in pixman_composite_trapezoids() by (x_dst, y_dst)

Søren Sandmann Pedersen sandmann at cs.au.dk
Thu Mar 31 11:39:01 PDT 2011


From: Søren Sandmann Pedersen <ssp at redhat.com>

Previously, this function would do coordinate calculations in such a
way that (x_dst, y_dst) would only affect the alignment of the source
image, but not of the traps, which would always be considered to be in
absolute destination coordinates. This is unlike the
pixman_image_composite() function which also registers the mask to the
destination.

This patch makes it so that traps are also offset by (x_dst, y_dst).

Also add a comment explaining how this function is supposed to
operate, and update tri-test.c and composite-trap-test.c to deal with
the new semantics.
---
 demos/tri-test.c            |    2 +-
 pixman/pixman-trap.c        |   23 +++++++++++++++++------
 test/composite-traps-test.c |    2 +-
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/demos/tri-test.c b/demos/tri-test.c
index ff4779e..a71869a 100644
--- a/demos/tri-test.c
+++ b/demos/tri-test.c
@@ -36,7 +36,7 @@ main (int argc, char **argv)
 				dest_img,
 				PIXMAN_a8,
 				200, 200,
-				35, 5,
+				-5, 5,
 				ARRAY_LENGTH (tris), tris);
     show_image (dest_img);
     
diff --git a/pixman/pixman-trap.c b/pixman/pixman-trap.c
index 2957a2b..c99f03e 100644
--- a/pixman/pixman-trap.c
+++ b/pixman/pixman-trap.c
@@ -387,6 +387,19 @@ pixman_rasterize_trapezoid (pixman_image_t *          image,
     }
 }
 
+/*
+ * pixman_composite_trapezoids()
+ *
+ * All the trapezoids are conceptually rendered to an infinitely big image.
+ * The (0, 0) coordinates of this image are then aligned with the (x, y)
+ * coordinates of the source image, and then both images are aligned with
+ * the (x, y) coordinates of the destination. Then, in principle, compositing
+ * of these three images takes place across the entire destination.
+ *
+ * FIXME: However, there is currently a bug, where we restrict this compositing
+ * to the bounding box of the trapezoids. This is incorrect for operators such
+ * as SRC and IN where blank source pixels do have an effect on the destination.
+ */
 PIXMAN_EXPORT void
 pixman_composite_trapezoids (pixman_op_t		op,
 			     pixman_image_t *		src,
@@ -419,14 +432,13 @@ pixman_composite_trapezoids (pixman_op_t		op,
 	    if (!pixman_trapezoid_valid (trap))
 		continue;
 	    
-	    pixman_rasterize_trapezoid (dst, trap, 0, 0);
+	    pixman_rasterize_trapezoid (dst, trap, x_dst, y_dst);
 	}
     }
     else
     {
 	pixman_image_t *tmp;
 	pixman_box32_t box;
-	int x_rel, y_rel;
 	
 	box.x1 = INT32_MAX;
 	box.y1 = INT32_MAX;
@@ -482,11 +494,10 @@ pixman_composite_trapezoids (pixman_op_t		op,
 	    pixman_rasterize_trapezoid (tmp, trap, - box.x1, - box.y1);
 	}
 	
-	x_rel = box.x1 + x_src - x_dst;
-	y_rel = box.y1 + y_src - y_dst;
-	
 	pixman_image_composite (op, src, tmp, dst,
-				x_rel, y_rel, 0, 0, box.x1, box.y1,
+				x_src + box.x1, y_src + box.y1,
+				0, 0,
+				x_dst + box.x1, y_dst + box.y1,
 				box.x2 - box.x1, box.y2 - box.y1);
 	
 	pixman_image_unref (tmp);
diff --git a/test/composite-traps-test.c b/test/composite-traps-test.c
index cf30281..fa6d8a9 100644
--- a/test/composite-traps-test.c
+++ b/test/composite-traps-test.c
@@ -252,6 +252,6 @@ test_composite (int      testnum,
 int
 main (int argc, const char *argv[])
 {
-    return fuzzer_test_main("composite traps", 40000, 0xA34F95C7,
+    return fuzzer_test_main("composite traps", 40000, 0xE3112106,
 			    test_composite, argc, argv);
 }
-- 
1.7.4



More information about the Pixman mailing list