[PATCH rendercheck] modify color expected outside of the triangles

Free Electron frielectron at gmail.com
Sun May 5 11:10:41 PDT 2013


pixman_composite_trapezoids() in pixman >= 0.27.4 composite across
the entire destination. This changes the color that t_triangles
test is expecting outside of the triangles. For operators such as
ADD or OVER this doesn't matter since a zero source has no effect
on the destination. But for operators such as SRC or IN, it does
matter. Hence modify color expected outside of the triangles for
such operators.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=64246

Signed-off-by: Free Electron <frielectron at gmail.com>
---
 rendercheck.h |  1 +
 t_triangles.c | 56 +++++++++++++++++++++++++++++--------------
 tests.c       | 76 +++++++++++++++++++++++++++++------------------------------
 3 files changed, 77 insertions(+), 56 deletions(-)

diff --git a/rendercheck.h b/rendercheck.h
index 92ce789..96e727b 100644
--- a/rendercheck.h
+++ b/rendercheck.h
@@ -65,6 +65,7 @@ typedef struct _picture_info {
 struct op_info {
 	int op;
 	char *name;
+	Bool zeroSrcHasNoEffect;
 	Bool disabled;
 };
 
diff --git a/t_triangles.c b/t_triangles.c
index 207b7b0..2b063cb 100644
--- a/t_triangles.c
+++ b/t_triangles.c
@@ -32,6 +32,8 @@
 #define TEST_WIDTH	10
 #define TEST_HEIGHT	10
 
+static color4d blackColor;
+
 /* Test basic functionality of the triangle operations.  We don't care that much
  * probably (nobody has used them yet), but we can trivially test by filling
  * doing two triangles that will exactly cover the rectangle from 2,2 to 4,4.
@@ -41,7 +43,7 @@ triangles_test(Display *dpy, picture_info *win, picture_info *dst, int op,
     picture_info *src_color, picture_info *dst_color)
 {
 	XTriangle triangles[2];
-	color4d tdst, tsrc;
+	color4d tdst, tin, tout;
 	int x, y;
 	Bool success = TRUE;
 	XImage *image;
@@ -71,11 +73,17 @@ triangles_test(Display *dpy, picture_info *win, picture_info *dst, int op,
 
 	/* Color expected outside of the triangles */
 	tdst = dst_color->color;
-	color_correct(dst, &tdst);
+	if (!ops[op].zeroSrcHasNoEffect) {
+		tout = blackColor;
+	} else {
+		tout = tdst;
+	}
+	color_correct(dst, &tout);
 
 	/* Color expected inside of the triangles */
-	do_composite(ops[op].op, &src_color->color, NULL, &tdst, &tsrc, FALSE);
-	color_correct(dst, &tsrc);
+	color_correct(dst, &tdst);
+	do_composite(ops[op].op, &src_color->color, NULL, &tdst, &tin, FALSE);
+	color_correct(dst, &tin);
 
 	image = XGetImage(dpy, dst->d,
 			  0, 0, 5, 5,
@@ -86,9 +94,9 @@ triangles_test(Display *dpy, picture_info *win, picture_info *dst, int op,
 		color4d expected, tested;
 
 		if (x >= 2 && x < 4 && y >= 2 && y < 4) {
-			expected = tsrc;
+			expected = tin;
 		} else {
-			expected = tdst;
+			expected = tout;
 		}
 
 		get_pixel_from_image(image, dst, x, y, &tested);
@@ -118,7 +126,7 @@ trifan_test(Display *dpy, picture_info *win, picture_info *dst, int op,
     picture_info *src_color, picture_info *dst_color)
 {
 	XPointFixed points[4];
-	color4d tdst, tsrc;
+	color4d tdst, tin, tout;
 	int x, y;
 	Bool success = TRUE;
 	XImage *image;
@@ -143,11 +151,17 @@ trifan_test(Display *dpy, picture_info *win, picture_info *dst, int op,
 
 	/* Color expected outside of the triangles */
 	tdst = dst_color->color;
-	color_correct(dst, &tdst);
+	if (!ops[op].zeroSrcHasNoEffect) {
+		tout = blackColor;
+	} else {
+		tout = tdst;
+	}
+	color_correct(dst, &tout);
 
 	/* Color expected inside of the triangles */
-	do_composite(ops[op].op, &src_color->color, NULL, &tdst, &tsrc, FALSE);
-	color_correct(dst, &tsrc);
+	color_correct(dst, &tdst);
+	do_composite(ops[op].op, &src_color->color, NULL, &tdst, &tin, FALSE);
+	color_correct(dst, &tin);
 
 	image = XGetImage(dpy, dst->d,
 			  0, 0, 5, 5,
@@ -158,9 +172,9 @@ trifan_test(Display *dpy, picture_info *win, picture_info *dst, int op,
 		color4d expected, tested;
 
 		if (x >= 2 && x < 4 && y >= 2 && y < 4) {
-			expected = tsrc;
+			expected = tin;
 		} else {
-			expected = tdst;
+			expected = tout;
 		}
 
 		get_pixel_from_image(image, dst, x, y, &tested);
@@ -190,7 +204,7 @@ tristrip_test(Display *dpy, picture_info *win, picture_info *dst, int op,
     picture_info *src_color, picture_info *dst_color)
 {
 	XPointFixed points[4];
-	color4d tdst, tsrc;
+	color4d tdst, tin, tout;
 	int x, y;
 	Bool success = TRUE;
 	XImage *image;
@@ -215,11 +229,17 @@ tristrip_test(Display *dpy, picture_info *win, picture_info *dst, int op,
 
 	/* Color expected outside of the triangles */
 	tdst = dst_color->color;
-	color_correct(dst, &tdst);
+	if (!ops[op].zeroSrcHasNoEffect) {
+		tout = blackColor;
+	} else {
+		tout = tdst;
+	}
+	color_correct(dst, &tout);
 
 	/* Color expected inside of the triangles */
-	do_composite(ops[op].op, &src_color->color, NULL, &tdst, &tsrc, FALSE);
-	color_correct(dst, &tsrc);
+	color_correct(dst, &tdst);
+	do_composite(ops[op].op, &src_color->color, NULL, &tdst, &tin, FALSE);
+	color_correct(dst, &tin);
 
 	image = XGetImage(dpy, dst->d,
 			  0, 0, 5, 5,
@@ -230,9 +250,9 @@ tristrip_test(Display *dpy, picture_info *win, picture_info *dst, int op,
 		color4d expected, tested;
 
 		if (x >= 2 && x < 4 && y >= 2 && y < 4) {
-			expected = tsrc;
+			expected = tin;
 		} else {
-			expected = tdst;
+			expected = tout;
 		}
 
 		get_pixel_from_image(image, dst, x, y, &tested);
diff --git a/tests.c b/tests.c
index aacd14d..018a1f7 100644
--- a/tests.c
+++ b/tests.c
@@ -49,44 +49,44 @@ picture_info *argb32white, *argb32red, *argb32green, *argb32blue;
 int num_colors = sizeof(colors) / sizeof(colors[0]);
 
 struct op_info ops[] = {
-	{PictOpClear, "Clear"},
-	{PictOpSrc, "Src"},
-	{PictOpDst, "Dst"},
-	{PictOpOver, "Over"},
-	{PictOpOverReverse, "OverReverse"},
-	{PictOpIn, "In"},
-	{PictOpInReverse, "InReverse"},
-	{PictOpOut, "Out"},
-	{PictOpOutReverse, "OutReverse"},
-	{PictOpAtop, "Atop"},
-	{PictOpAtopReverse, "AtopReverse"},
-	{PictOpXor, "Xor"},
-	{PictOpAdd, "Add"},
-	{PictOpSaturate, "Saturate"},
-	{PictOpDisjointClear, "DisjointClear"},
-	{PictOpDisjointSrc, "DisjointSrc"},
-	{PictOpDisjointDst, "DisjointDst"},
-	{PictOpDisjointOver, "DisjointOver"},
-	{PictOpDisjointOverReverse, "DisjointOverReverse"},
-	{PictOpDisjointIn, "DisjointIn"},
-	{PictOpDisjointInReverse, "DisjointInReverse"},
-	{PictOpDisjointOut, "DisjointOut"},
-	{PictOpDisjointOutReverse, "DisjointOutReverse"},
-	{PictOpDisjointAtop, "DisjointAtop"},
-	{PictOpDisjointAtopReverse, "DisjointAtopReverse"},
-	{PictOpDisjointXor, "DisjointXor"},
-	{PictOpConjointClear, "ConjointClear"},
-	{PictOpConjointSrc, "ConjointSrc"},
-	{PictOpConjointDst, "ConjointDst"},
-	{PictOpConjointOver, "ConjointOver"},
-	{PictOpConjointOverReverse, "ConjointOverReverse"},
-	{PictOpConjointIn, "ConjointIn"},
-	{PictOpConjointInReverse, "ConjointInReverse"},
-	{PictOpConjointOut, "ConjointOut"},
-	{PictOpConjointOutReverse, "ConjointOutReverse"},
-	{PictOpConjointAtop, "ConjointAtop"},
-	{PictOpConjointAtopReverse, "ConjointAtopReverse"},
-	{PictOpConjointXor, "ConjointXor"},
+	{PictOpClear, "Clear", FALSE},
+	{PictOpSrc, "Src", FALSE},
+	{PictOpDst, "Dst", TRUE},
+	{PictOpOver, "Over", TRUE},
+	{PictOpOverReverse, "OverReverse", TRUE},
+	{PictOpIn, "In", FALSE},
+	{PictOpInReverse, "InReverse", FALSE},
+	{PictOpOut, "Out", FALSE},
+	{PictOpOutReverse, "OutReverse", TRUE},
+	{PictOpAtop, "Atop", TRUE},
+	{PictOpAtopReverse, "AtopReverse", FALSE},
+	{PictOpXor, "Xor", TRUE},
+	{PictOpAdd, "Add", TRUE},
+	{PictOpSaturate, "Saturate", TRUE},
+	{PictOpDisjointClear, "DisjointClear", FALSE},
+	{PictOpDisjointSrc, "DisjointSrc", FALSE},
+	{PictOpDisjointDst, "DisjointDst", TRUE},
+	{PictOpDisjointOver, "DisjointOver", TRUE},
+	{PictOpDisjointOverReverse, "DisjointOverReverse", TRUE},
+	{PictOpDisjointIn, "DisjointIn", FALSE},
+	{PictOpDisjointInReverse, "DisjointInReverse", FALSE},
+	{PictOpDisjointOut, "DisjointOut", FALSE},
+	{PictOpDisjointOutReverse, "DisjointOutReverse", TRUE},
+	{PictOpDisjointAtop, "DisjointAtop", TRUE},
+	{PictOpDisjointAtopReverse, "DisjointAtopReverse", FALSE},
+	{PictOpDisjointXor, "DisjointXor", TRUE},
+	{PictOpConjointClear, "ConjointClear", FALSE},
+	{PictOpConjointSrc, "ConjointSrc", FALSE},
+	{PictOpConjointDst, "ConjointDst", TRUE},
+	{PictOpConjointOver, "ConjointOver", TRUE},
+	{PictOpConjointOverReverse, "ConjointOverReverse", TRUE},
+	{PictOpConjointIn, "ConjointIn", FALSE},
+	{PictOpConjointInReverse, "ConjointInReverse", FALSE},
+	{PictOpConjointOut, "ConjointOut", FALSE},
+	{PictOpConjointOutReverse, "ConjointOutReverse", TRUE},
+	{PictOpConjointAtop, "ConjointAtop", TRUE},
+	{PictOpConjointAtopReverse, "ConjointAtopReverse", FALSE},
+	{PictOpConjointXor, "ConjointXor", TRUE},
 };
 
 int num_ops = sizeof(ops) / sizeof(ops[0]);
-- 
1.8.1.2



More information about the xorg-devel mailing list