[cairo-commit] 2 commits - test/clip-group-shapes-aligned-rectangles.ref.png test/clip-group-shapes.c test/clip-group-shapes-circles.ref.png test/clip-group-shapes-unaligned-rectangles.ref.png test/Makefile.sources test/surface-pattern-scale-down-extend.c test/surface-pattern-scale-down-extend-none.ref.png test/surface-pattern-scale-down-extend-pad.ref.png test/surface-pattern-scale-down-extend-reflect.ref.png test/surface-pattern-scale-down-extend-repeat.ref.png
M. Joonas Pihlaja
joonas at kemper.freedesktop.org
Sat Feb 27 07:48:59 PST 2010
test/Makefile.sources | 2
test/clip-group-shapes-aligned-rectangles.ref.png |binary
test/clip-group-shapes-circles.ref.png |binary
test/clip-group-shapes-unaligned-rectangles.ref.png |binary
test/clip-group-shapes.c | 189 +++++++++++++++++
test/surface-pattern-scale-down-extend-none.ref.png |binary
test/surface-pattern-scale-down-extend-pad.ref.png |binary
test/surface-pattern-scale-down-extend-reflect.ref.png |binary
test/surface-pattern-scale-down-extend-repeat.ref.png |binary
test/surface-pattern-scale-down-extend.c | 107 +++++++++
10 files changed, 298 insertions(+)
New commits:
commit 260d7f8ace9dea8ff6b3a70f481e433cf399a3d2
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date: Sat Feb 27 17:41:28 2010 +0200
test: Test downscaling and extending a surface pattern.
Franz Schmid reported a regression in 1.9.6 when downscaling
and using EXTEND_REPEAT for an image surface pattern. This
patch adds such tests for every extend mode.
diff --git a/test/Makefile.sources b/test/Makefile.sources
index ef5253b..c770db6 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -226,6 +226,7 @@ test_sources = \
surface-pattern-big-scale-down.c \
surface-pattern-operator.c \
surface-pattern-scale-down.c \
+ surface-pattern-scale-down-extend.c \
surface-pattern-scale-up.c \
text-antialias-gray.c \
text-antialias-none.c \
diff --git a/test/surface-pattern-scale-down-extend-none.ref.png b/test/surface-pattern-scale-down-extend-none.ref.png
new file mode 100644
index 0000000..9df14cc
Binary files /dev/null and b/test/surface-pattern-scale-down-extend-none.ref.png differ
diff --git a/test/surface-pattern-scale-down-extend-pad.ref.png b/test/surface-pattern-scale-down-extend-pad.ref.png
new file mode 100644
index 0000000..2ee9419
Binary files /dev/null and b/test/surface-pattern-scale-down-extend-pad.ref.png differ
diff --git a/test/surface-pattern-scale-down-extend-reflect.ref.png b/test/surface-pattern-scale-down-extend-reflect.ref.png
new file mode 100644
index 0000000..f2e93a7
Binary files /dev/null and b/test/surface-pattern-scale-down-extend-reflect.ref.png differ
diff --git a/test/surface-pattern-scale-down-extend-repeat.ref.png b/test/surface-pattern-scale-down-extend-repeat.ref.png
new file mode 100644
index 0000000..c5cff0f
Binary files /dev/null and b/test/surface-pattern-scale-down-extend-repeat.ref.png differ
diff --git a/test/surface-pattern-scale-down-extend.c b/test/surface-pattern-scale-down-extend.c
new file mode 100644
index 0000000..8033861
--- /dev/null
+++ b/test/surface-pattern-scale-down-extend.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright © 2010 M Joonas Pihlaja
+ *
+ * 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: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
+ */
+#include "cairo-test.h"
+
+/* Test that we can simultaneously downscale and extend a surface
+ * pattern. Reported by Franz Schmid to the cairo mailing list as a
+ * regression in 1.9.6:
+ *
+ * http://lists.cairographics.org/archives/cairo/2010-February/019492.html
+ */
+
+static cairo_test_status_t
+draw_with_extend (cairo_t *cr, int w, int h, cairo_extend_t extend)
+{
+ cairo_pattern_t *pattern;
+ cairo_set_source_rgb (cr, 1,1,1);
+ cairo_paint (cr);
+
+ cairo_push_group_with_content (cr, CAIRO_CONTENT_COLOR); {
+ /* A two by two checkerboard with black, red and yellow
+ * cells. */
+ cairo_set_source_rgb (cr, 1,0,0);
+ cairo_rectangle (cr, w/2, 0, w-w/2, h/2);
+ cairo_fill (cr);
+ cairo_set_source_rgb (cr, 1,1,0);
+ cairo_rectangle (cr, 0, h/2, w/2, h-h/2);
+ cairo_fill (cr);
+ }
+ pattern = cairo_pop_group (cr);
+ cairo_pattern_set_extend(pattern, extend);
+
+ cairo_scale (cr, 0.5, 0.5);
+ cairo_set_source (cr, pattern);
+ cairo_paint (cr);
+
+ cairo_pattern_destroy (pattern);
+ return CAIRO_TEST_SUCCESS;
+}
+
+static cairo_test_status_t
+draw_repeat (cairo_t *cr, int w, int h)
+{
+ return draw_with_extend (cr, w, h, CAIRO_EXTEND_REPEAT);
+}
+static cairo_test_status_t
+draw_none (cairo_t *cr, int w, int h)
+{
+ return draw_with_extend (cr, w, h, CAIRO_EXTEND_NONE);
+}
+static cairo_test_status_t
+draw_reflect (cairo_t *cr, int w, int h)
+{
+ return draw_with_extend (cr, w, h, CAIRO_EXTEND_REFLECT);
+}
+static cairo_test_status_t
+draw_pad (cairo_t *cr, int w, int h)
+{
+ return draw_with_extend (cr, w, h, CAIRO_EXTEND_PAD);
+}
+
+CAIRO_TEST (surface_pattern_scale_down_extend_repeat,
+ "Test interaction of downscaling a surface pattern and extend-repeat",
+ "pattern, transform, extend", /* keywords */
+ NULL, /* requirements */
+ 100, 100,
+ NULL, draw_repeat)
+CAIRO_TEST (surface_pattern_scale_down_extend_none,
+ "Test interaction of downscaling a surface pattern and extend-none",
+ "pattern, transform, extend", /* keywords */
+ NULL, /* requirements */
+ 100, 100,
+ NULL, draw_none)
+CAIRO_TEST (surface_pattern_scale_down_extend_reflect,
+ "Test interaction of downscaling a surface pattern and extend-reflect",
+ "pattern, transform, extend", /* keywords */
+ NULL, /* requirements */
+ 100, 100,
+ NULL, draw_reflect)
+CAIRO_TEST (surface_pattern_scale_down_extend_pad,
+ "Test interaction of downscaling a surface pattern and extend-pad",
+ "pattern, transform, extend", /* keywords */
+ NULL, /* requirements */
+ 100, 100,
+ NULL, draw_pad)
commit ebadc2ed0810d9941a2f44586016073fea90115b
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date: Sat Feb 27 03:24:55 2010 +0200
test: Add tests covering more clip fast paths in groups.
The clip-group-shapes-* tests check that it doesn't
matter whether the clip path is set before or after
pushing a group using specific types of clip paths
(aligned/unaligned rectangles and general paths.)
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 0f524e1..ef5253b 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -25,6 +25,7 @@ test_sources = \
clip-fill-rule.c \
clip-fill-rule-pixel-aligned.c \
clip-fill-unbounded.c \
+ clip-group-shapes.c \
clip-image.c \
clip-nesting.c \
clip-operator.c \
diff --git a/test/clip-group-shapes-aligned-rectangles.ref.png b/test/clip-group-shapes-aligned-rectangles.ref.png
new file mode 100644
index 0000000..cba7507
Binary files /dev/null and b/test/clip-group-shapes-aligned-rectangles.ref.png differ
diff --git a/test/clip-group-shapes-circles.ref.png b/test/clip-group-shapes-circles.ref.png
new file mode 100644
index 0000000..064cc58
Binary files /dev/null and b/test/clip-group-shapes-circles.ref.png differ
diff --git a/test/clip-group-shapes-unaligned-rectangles.ref.png b/test/clip-group-shapes-unaligned-rectangles.ref.png
new file mode 100644
index 0000000..2ad4118
Binary files /dev/null and b/test/clip-group-shapes-unaligned-rectangles.ref.png differ
diff --git a/test/clip-group-shapes.c b/test/clip-group-shapes.c
new file mode 100644
index 0000000..72eff9f
--- /dev/null
+++ b/test/clip-group-shapes.c
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2010 M Joonas Pihlaja
+ *
+ * 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: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
+ */
+#include "cairo-test.h"
+
+/* Tests specific clipping fast paths and their interaction with
+ * groups: It shouldn't matter if the clip is set before or after
+ * pushing a group.
+ *
+ * There's some overlap with the following tests, but they test for
+ * different things:
+ *
+ * group-clip.c (tests preserving paths), clipped-group.c (tests
+ * clipping the same thing different ways), clip-push-group (tests
+ * for a specific bug).
+ */
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+
+#define GENERATE_REF 0
+
+/* For determining whether we establish the clip path before or after
+ * pushing a group. */
+enum {
+ CLIP_OUTSIDE_GROUP,
+ CLIP_INSIDE_GROUP
+};
+
+typedef void (*clipper_t)(cairo_t *cr, int w, int h);
+
+static cairo_test_status_t
+clip_and_paint (cairo_t *cr,
+ int w, int h,
+ clipper_t do_clip,
+ int clip_where)
+{
+ cairo_save (cr); {
+ if (GENERATE_REF) {
+ do_clip (cr, w, h);
+ cairo_paint (cr);
+ }
+ else {
+ if (clip_where == CLIP_OUTSIDE_GROUP)
+ do_clip (cr, w, h);
+ cairo_push_group (cr); {
+ if (clip_where == CLIP_INSIDE_GROUP)
+ do_clip (cr, w, h);
+ cairo_paint (cr);
+ }
+ cairo_pop_group_to_source (cr);
+ cairo_paint (cr);
+ }
+ }
+ cairo_restore (cr);
+ return CAIRO_TEST_SUCCESS;
+}
+
+static cairo_test_status_t
+run_clip_test (cairo_t *cr, int w, int h, clipper_t do_clip)
+{
+ cairo_set_source_rgb (cr, 1,1,1);
+ cairo_paint (cr);
+ cairo_set_source_rgb (cr, 1,0,0);
+
+ /* Left. */
+ clip_and_paint (cr, w/2, h, do_clip, CLIP_OUTSIDE_GROUP);
+
+ /* Right */
+ cairo_translate(cr, w/2, 0);
+ clip_and_paint (cr, w/2, h, do_clip, CLIP_INSIDE_GROUP);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+static void
+clip_aligned_rectangles (cairo_t *cr, int w, int h)
+{
+ int x1 = 0.2 * w;
+ int y1 = 0.2 * h;
+ int x2 = 0.8 * w;
+ int y2 = 0.8 * h;
+
+ cairo_rectangle (cr, x1, y1, w, h);
+ cairo_clip (cr);
+
+ cairo_rectangle (cr, x2, y2, -w, -h);
+ cairo_clip (cr);
+}
+
+static void
+clip_unaligned_rectangles (cairo_t *cr, int w, int h)
+{
+ /* This clip stresses the antialiased edges produced by an
+ * unaligned rectangular clip. The edges should be produced by
+ * compositing red on white with alpha = 0.5 on the sides, and with
+ * alpha = 0.25 in the corners. */
+ int x1 = 0.2 * w;
+ int y1 = 0.2 * h;
+ int x2 = 0.8 * w;
+ int y2 = 0.8 * h;
+
+ cairo_rectangle (cr, x1+0.5, y1+0.5, w, h);
+ cairo_clip (cr);
+
+ cairo_rectangle (cr, x2+0.5, y2+0.5, -w, -h);
+ w = x2 - x1;
+ h = y2 - y1;
+ cairo_rectangle (cr, x2, y1+1, -w+1, h-1);
+ cairo_clip (cr);
+}
+
+static void
+clip_circles (cairo_t *cr, int w, int h)
+{
+ int x1 = 0.5 * w;
+ int y1 = 0.5 * h;
+ int x2 = 0.75 * w;
+ int y2 = 0.75 * h;
+ int r = 0.4*MIN(w,h);
+
+ cairo_arc (cr, x1, y1, r, 0, 6.28);
+ cairo_close_path (cr);
+ cairo_clip (cr);
+
+ cairo_arc (cr, x2, y2, r, 0, 6.28);
+ cairo_close_path (cr);
+ cairo_clip (cr);
+}
+
+static cairo_test_status_t
+draw_aligned_rectangles (cairo_t *cr, int width, int height)
+{
+ return run_clip_test (cr, width, height, clip_aligned_rectangles);
+}
+
+static cairo_test_status_t
+draw_unaligned_rectangles (cairo_t *cr, int width, int height)
+{
+ return run_clip_test (cr, width, height, clip_unaligned_rectangles);
+}
+
+static cairo_test_status_t
+draw_circles (cairo_t *cr, int width, int height)
+{
+ return run_clip_test (cr, width, height, clip_circles);
+}
+
+CAIRO_TEST (clip_group_shapes_aligned_rectangles,
+ "Test clip and group interaction with aligned rectangle clips",
+ "clip", /* keywords */
+ NULL, /* requirements */
+ 200, 100,
+ NULL, draw_aligned_rectangles)
+
+CAIRO_TEST (clip_group_shapes_unaligned_rectangles,
+ "Test clip and group interaction with unaligned rectangle clips",
+ "clip", /* keywords */
+ "target=raster", /* requirements */
+ 200, 100,
+ NULL, draw_unaligned_rectangles)
+
+CAIRO_TEST (clip_group_shapes_circles,
+ "Test clip and group interaction with circular clips",
+ "clip", /* keywords */
+ NULL, /* requirements */
+ 200, 100,
+ NULL, draw_circles)
More information about the cairo-commit
mailing list