[PATCH 1/2] Add unaligned boxes to "operator-source" test

Uli Schlachter psychon at znc.in
Mon Mar 21 10:42:27 PDT 2011


TODO: New ref images, I don't have the right fonts for this.

This reveals a bug in the image backend. This was originally reported here:
http://lists.cairographics.org/archives/cairo/2011-March/021827.html

Signed-off-by: Uli Schlachter <psychon at znc.in>
---
 test/operator-source.c |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/test/operator-source.c b/test/operator-source.c
index d734167..598da1c 100644
--- a/test/operator-source.c
+++ b/test/operator-source.c
@@ -22,6 +22,7 @@
  *
  * Authors: Kristian Høgsberg <krh at redhat.com>
  *          Owen Taylor <otaylor at redhat.com>
+ *          Uli Schlachter <psychon at znc.in>
  */
 
 #include <math.h>
@@ -145,12 +146,16 @@ draw_polygon (cairo_t *cr, int x, int y)
 }
 
 static void
-draw_rects (cairo_t *cr, int x, int y)
+draw_rects (cairo_t *cr, int x, int y, double offset)
 {
-    double block_width = (int)(0.33 * WIDTH + 0.5);
-    double block_height = (int)(0.33 * HEIGHT + 0.5);
+    double block_width = (int)(0.33 * WIDTH + 0.5) - offset/3;
+    double block_height = (int)(0.33 * HEIGHT + 0.5) - offset/3;
     int i, j;
 
+    /* Center the drawing in the used area */
+    x += offset/2;
+    y += offset/2;
+
     for (i = 0; i < 3; i++)
 	for (j = 0; j < 3; j++)
 	    if ((i + j) % 2 == 0)
@@ -161,6 +166,18 @@ draw_rects (cairo_t *cr, int x, int y)
     cairo_fill (cr);
 }
 
+static void
+draw_aligned_rects (cairo_t *cr, int x, int y)
+{
+    draw_rects (cr, x, y, 0);
+}
+
+static void
+draw_unaligned_rects (cairo_t *cr, int x, int y)
+{
+    draw_rects (cr, x, y, 1.2);
+}
+
 static void (* const pattern_funcs[])(cairo_t *cr, int x, int y) = {
     set_solid_pattern,
     set_translucent_pattern,
@@ -172,7 +189,8 @@ static void (* const draw_funcs[])(cairo_t *cr, int x, int y) = {
     draw_mask,
     draw_glyphs,
     draw_polygon,
-    draw_rects
+    draw_aligned_rects,
+    draw_unaligned_rects
 };
 
 #define IMAGE_WIDTH (ARRAY_LENGTH (pattern_funcs) * (WIDTH + PAD) + PAD)
-- 
1.7.2.3


--------------000300070308020509030106
Content-Type: text/x-diff;
 name="0002-image-Don-t-use-the-fast-path-if-it-s-wrong.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0002-image-Don-t-use-the-fast-path-if-it-s-wrong.patch"



More information about the cairo mailing list