[cairo-commit] 2 commits - boilerplate/cairo-boilerplate-pdf.c boilerplate/cairo-boilerplate-ps.c boilerplate/cairo-boilerplate-svg.c boilerplate/cairo-boilerplate-win32-printing.c test/extend-pad-border.c test/extend-pad-border.ref.png test/extend-pad.c test/extend-pad.ref.png test/extend-pad-similar.c test/extend-pad-similar.ref.png test/Makefile.am

Chris Wilson ickle at kemper.freedesktop.org
Mon Nov 3 06:25:15 PST 2008


 boilerplate/cairo-boilerplate-pdf.c            |    2 
 boilerplate/cairo-boilerplate-ps.c             |    2 
 boilerplate/cairo-boilerplate-svg.c            |    2 
 boilerplate/cairo-boilerplate-win32-printing.c |    2 
 test/Makefile.am                               |   10 +-
 test/extend-pad-border.c                       |   95 +++++++++++++++++++++++++
 test/extend-pad-border.ref.png                 |binary
 test/extend-pad-similar.c                      |   82 +++++++++++++++++++++
 test/extend-pad-similar.ref.png                |binary
 test/extend-pad.c                              |   50 +++++--------
 test/extend-pad.ref.png                        |binary
 11 files changed, 207 insertions(+), 38 deletions(-)

New commits:
commit 43e2370b024f66d995c514fd53414d3d8588a481
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Nov 3 14:20:35 2008 +0000

    [test] Update extend-pad.
    
    extend-pad was not a clear demonstration of the EXTEND_PAD mode, so revamp
    it to show the filter extending a 4 pixel surface to cover the entire
    output. However, this hides a discrepancy with the vector surfaces that we
    cannot prevent the external renders from applying an interpolation to the
    border pixels, so we copy the original test to extend-pad-border to check
    the desired behaviour on boundary pixels.

diff --git a/test/Makefile.am b/test/Makefile.am
index 948716a..c2a87ee 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -51,6 +51,8 @@ test_sources = \
 	device-offset-positive.c			\
 	device-offset-scale.c				\
 	extend-pad.c					\
+	extend-pad-border.c				\
+	extend-pad-similar.c				\
 	extend-reflect.c				\
 	extend-reflect-similar.c			\
 	extend-repeat.c					\
@@ -439,6 +441,8 @@ REFERENCE_IMAGES = \
 	device-offset.rgb24.ref.png	\
 	device-offset-scale.ref.png	\
 	extend-pad.ref.png	\
+	extend-pad-border.ref.png	\
+	extend-pad-similar.ref.png	\
 	extend-reflect.ref.png	\
 	extend-reflect-similar.ref.png	\
 	extend-reflect-similar.ps2.ref.png	\
diff --git a/test/extend-pad-border.c b/test/extend-pad-border.c
new file mode 100644
index 0000000..79a81fc
--- /dev/null
+++ b/test/extend-pad-border.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Author: Behdad Esfahbod <behdad at behdad.org>
+ */
+
+#include <math.h>
+#include "cairo-test.h"
+#include <stdio.h>
+
+#define SIZE 90
+
+/* Check the border-pixels of an EXTEND_PAD image pattern */
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    cairo_surface_t *surface;
+    cairo_t * cr_surface;
+    int surface_size = (SIZE - 30) / 10;
+
+    cairo_set_source_rgba (cr, 0, 0, 0, 1);
+    cairo_rectangle (cr, 0, 0, SIZE, SIZE);
+    cairo_fill (cr);
+
+    /* Create an image surface with my favorite four colors in each
+     * quadrant. */
+    surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
+					  surface_size, surface_size);
+    cr_surface = cairo_create (surface);
+    cairo_surface_destroy (surface);
+
+    cairo_set_source_rgb (cr_surface, 1, 1, 1);
+    cairo_rectangle (cr_surface,
+		     0, 0,
+		     surface_size / 2, surface_size / 2);
+    cairo_fill (cr_surface);
+    cairo_set_source_rgb (cr_surface, 1, 0, 0);
+    cairo_rectangle (cr_surface,
+		     surface_size / 2, 0,
+		     surface_size / 2, surface_size / 2);
+    cairo_fill (cr_surface);
+    cairo_set_source_rgb (cr_surface, 0, 1, 0);
+    cairo_rectangle (cr_surface,
+		     0, surface_size / 2,
+		     surface_size / 2, surface_size / 2);
+    cairo_fill (cr_surface);
+    cairo_set_source_rgb (cr_surface, 0, 0, 1);
+    cairo_rectangle (cr_surface,
+		     surface_size / 2, surface_size / 2,
+		     surface_size / 2, surface_size / 2);
+    cairo_fill (cr_surface);
+
+    cairo_scale (cr, 10, 10);
+    cairo_set_source_surface (cr, cairo_get_target (cr_surface), 1.5, 1.5);
+    cairo_destroy (cr_surface);
+
+    /* Using EXTEND_REFLECT makes this test pass for image and xlib backends */
+    /*cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REFLECT);*/
+
+    cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_PAD);
+    cairo_rectangle (cr, 1.5, 1.5, 6, 6);
+    cairo_clip (cr);
+
+    cairo_paint (cr);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (extend_pad_border,
+	    "Test CAIRO_EXTEND_PAD for surface patterns",
+	    "XFAIL=!image,pdf,ps,svg extend", /* keywords */
+	    NULL, /* requirements */
+	    SIZE, SIZE,
+	    NULL, draw)
diff --git a/test/extend-pad-border.ref.png b/test/extend-pad-border.ref.png
new file mode 100644
index 0000000..9292f8b
Binary files /dev/null and b/test/extend-pad-border.ref.png differ
diff --git a/test/extend-pad-similar.c b/test/extend-pad-similar.c
new file mode 100644
index 0000000..357252a
--- /dev/null
+++ b/test/extend-pad-similar.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Author: Behdad Esfahbod <behdad at behdad.org>
+ */
+
+#include <math.h>
+#include "cairo-test.h"
+#include <stdio.h>
+
+#define SIZE 90
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    cairo_surface_t *surface;
+    cairo_t *cr_surface;
+
+    /* Create a 4-pixel similar surface with my favorite four colors in each
+     * quadrant. */
+    surface = cairo_surface_create_similar (cairo_get_group_target (cr),
+					    CAIRO_CONTENT_COLOR, 2, 2);
+    cr_surface = cairo_create (surface);
+    cairo_surface_destroy (surface);
+
+    /* upper-left = white */
+    cairo_set_source_rgb (cr_surface, 1, 1, 1);
+    cairo_rectangle (cr_surface, 0, 0, 1, 1);
+    cairo_fill (cr_surface);
+
+    /* upper-right = red */
+    cairo_set_source_rgb (cr_surface, 1, 0, 0);
+    cairo_rectangle (cr_surface, 1, 0, 1, 1);
+    cairo_fill (cr_surface);
+
+    /* lower-left = green */
+    cairo_set_source_rgb (cr_surface, 0, 1, 0);
+    cairo_rectangle (cr_surface, 0, 1, 1, 1);
+    cairo_fill (cr_surface);
+
+    /* lower-right = blue */
+    cairo_set_source_rgb (cr_surface, 0, 0, 1);
+    cairo_rectangle (cr_surface, 1, 1, 1, 1);
+    cairo_fill (cr_surface);
+
+    /* Now use extend pad to cover the entire surface with those 4 colors */
+    cairo_set_source_surface (cr, cairo_get_target (cr_surface),
+			      width/2  - 1,
+			      height/2 - 1);
+    cairo_destroy (cr_surface);
+    cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_PAD);
+    cairo_paint (cr);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (extend_pad_similar,
+	    "Test CAIRO_EXTEND_PAD for similar surface patterns",
+	    "extend", /* keywords */
+	    NULL, /* requirements */
+	    SIZE, SIZE,
+	    NULL, draw)
diff --git a/test/extend-pad-similar.ref.png b/test/extend-pad-similar.ref.png
new file mode 100644
index 0000000..82da7b6
Binary files /dev/null and b/test/extend-pad-similar.ref.png differ
diff --git a/test/extend-pad.c b/test/extend-pad.c
index ed4ffd0..15a2079 100644
--- a/test/extend-pad.c
+++ b/test/extend-pad.c
@@ -34,52 +34,40 @@ static cairo_test_status_t
 draw (cairo_t *cr, int width, int height)
 {
     cairo_surface_t *surface;
-    cairo_t * cr_surface;
-    int surface_size = (SIZE - 30) / 10;
+    cairo_t *cr_surface;
 
-    cairo_set_source_rgba (cr, 0, 0, 0, 1);
-    cairo_rectangle (cr, 0, 0, SIZE, SIZE);
-    cairo_fill (cr);
-
-    /* Create an image surface with my favorite four colors in each
+    /* Create a 4-pixel image surface with my favorite four colors in each
      * quadrant. */
-    surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
-					  surface_size, surface_size);
+    surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 2, 2);
     cr_surface = cairo_create (surface);
     cairo_surface_destroy (surface);
 
+    /* upper-left = white */
     cairo_set_source_rgb (cr_surface, 1, 1, 1);
-    cairo_rectangle (cr_surface,
-		     0, 0,
-		     surface_size / 2, surface_size / 2);
+    cairo_rectangle (cr_surface, 0, 0, 1, 1);
     cairo_fill (cr_surface);
+
+    /* upper-right = red */
     cairo_set_source_rgb (cr_surface, 1, 0, 0);
-    cairo_rectangle (cr_surface,
-		     surface_size / 2, 0,
-		     surface_size / 2, surface_size / 2);
+    cairo_rectangle (cr_surface, 1, 0, 1, 1);
     cairo_fill (cr_surface);
+
+    /* lower-left = green */
     cairo_set_source_rgb (cr_surface, 0, 1, 0);
-    cairo_rectangle (cr_surface,
-		     0, surface_size / 2,
-		     surface_size / 2, surface_size / 2);
+    cairo_rectangle (cr_surface, 0, 1, 1, 1);
     cairo_fill (cr_surface);
+
+    /* lower-right = blue */
     cairo_set_source_rgb (cr_surface, 0, 0, 1);
-    cairo_rectangle (cr_surface,
-		     surface_size / 2, surface_size / 2,
-		     surface_size / 2, surface_size / 2);
+    cairo_rectangle (cr_surface, 1, 1, 1, 1);
     cairo_fill (cr_surface);
 
-    cairo_scale (cr, 10, 10);
-    cairo_set_source_surface (cr, cairo_get_target (cr_surface), 1.5, 1.5);
+    /* Now use extend pad to cover the entire surface with those 4 colors */
+    cairo_set_source_surface (cr, cairo_get_target (cr_surface),
+			      width/2  - 1,
+			      height/2 - 1);
     cairo_destroy (cr_surface);
-
-    /* Using EXTEND_REFLECT makes this test pass for image and xlib backends */
-    /*cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REFLECT);*/
-
     cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_PAD);
-    cairo_rectangle (cr, 1.5, 1.5, 6, 6);
-    cairo_clip (cr);
-
     cairo_paint (cr);
 
     return CAIRO_TEST_SUCCESS;
@@ -87,7 +75,7 @@ draw (cairo_t *cr, int width, int height)
 
 CAIRO_TEST (extend_pad,
 	    "Test CAIRO_EXTEND_PAD for surface patterns",
-	    "XFAIL=!image,pdf,ps,svg extend", /* keywords */
+	    "extend", /* keywords */
 	    NULL, /* requirements */
 	    SIZE, SIZE,
 	    NULL, draw)
diff --git a/test/extend-pad.ref.png b/test/extend-pad.ref.png
index 9292f8b..82da7b6 100644
Binary files a/test/extend-pad.ref.png and b/test/extend-pad.ref.png differ
commit b3462c5616ae24fd391ad0872d2fbb98c6cd0c92
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Nov 3 13:10:42 2008 +0000

    [test] Convert a few residual '-out.*'
    
    Catch a few -out.* hiding in boilerplate.

diff --git a/boilerplate/cairo-boilerplate-pdf.c b/boilerplate/cairo-boilerplate-pdf.c
index 7000238..7e5e162 100644
--- a/boilerplate/cairo-boilerplate-pdf.c
+++ b/boilerplate/cairo-boilerplate-pdf.c
@@ -72,7 +72,7 @@ _cairo_boilerplate_pdf_create_surface (const char		 *name,
     ptc->width = width;
     ptc->height = height;
 
-    xasprintf (&ptc->filename, "%s-out.pdf", name);
+    xasprintf (&ptc->filename, "%s.out.pdf", name);
     xunlink (ptc->filename);
 
     surface = cairo_pdf_surface_create (ptc->filename, width, height);
diff --git a/boilerplate/cairo-boilerplate-ps.c b/boilerplate/cairo-boilerplate-ps.c
index b2e1e12..c3efcea 100644
--- a/boilerplate/cairo-boilerplate-ps.c
+++ b/boilerplate/cairo-boilerplate-ps.c
@@ -86,7 +86,7 @@ _cairo_boilerplate_ps_create_surface (const char		 *name,
 
     *closure = ptc = xmalloc (sizeof (ps_target_closure_t));
 
-    xasprintf (&ptc->filename, "%s-out.ps", name);
+    xasprintf (&ptc->filename, "%s.out.ps", name);
     xunlink (ptc->filename);
 
     ptc->level = level;
diff --git a/boilerplate/cairo-boilerplate-svg.c b/boilerplate/cairo-boilerplate-svg.c
index 195dc78..e6c1355 100644
--- a/boilerplate/cairo-boilerplate-svg.c
+++ b/boilerplate/cairo-boilerplate-svg.c
@@ -65,7 +65,7 @@ _cairo_boilerplate_svg_create_surface (const char		 *name,
     ptc->width = width;
     ptc->height = height;
 
-    xasprintf (&ptc->filename, "%s-out.svg", name);
+    xasprintf (&ptc->filename, "%s.out.svg", name);
     xunlink (ptc->filename);
 
     surface = cairo_svg_surface_create (ptc->filename, width, height);
diff --git a/boilerplate/cairo-boilerplate-win32-printing.c b/boilerplate/cairo-boilerplate-win32-printing.c
index a5f21ff..13a6551 100644
--- a/boilerplate/cairo-boilerplate-win32-printing.c
+++ b/boilerplate/cairo-boilerplate-win32-printing.c
@@ -181,7 +181,7 @@ _cairo_boilerplate_win32_printing_create_surface (const char              *name,
 
     *closure = ptc = xmalloc (sizeof (win32_target_closure_t));
 
-    xasprintf (&ptc->filename, "%s-out.ps", name);
+    xasprintf (&ptc->filename, "%s.out.ps", name);
     xunlink (ptc->filename);
 
     memset (&di, 0, sizeof (DOCINFO));
diff --git a/test/Makefile.am b/test/Makefile.am
index 02debdf..948716a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1225,12 +1225,12 @@ CLEANFILES +=					\
 # reality of portability was raised and it became....
 clean-local: clean-caches
 	rm -rf output
-	-${FIND} . -name '*-out.*'    -print | ${XARGS} ${RM}
+	-${FIND} . -name '*.out.*'    -print | ${XARGS} ${RM}
 	-${FIND} . -name '*.log'      -print | ${XARGS} ${RM}
 	-${FIND} . -name '*.[is]'     -print | ${XARGS} ${RM}
 clean-caches:
-	-${FIND} . -name '*-pass.*'   -print | ${XARGS} ${RM}
-	-${FIND} . -name '*-fail.*'   -print | ${XARGS} ${RM}
+	-${FIND} . -name '*.pass.*'   -print | ${XARGS} ${RM}
+	-${FIND} . -name '*.fail.*'   -print | ${XARGS} ${RM}
 
 # The following definitions both should work.
 #FAILED_TESTS = `grep -l '\<FAIL\>' $(test_sources:.c=.log) 2>/dev/null | sed -e 's/[.]log$$//' | xargs echo`


More information about the cairo-commit mailing list