[cairo-commit] 2 commits - test/Makefile.refs test/Makefile.sources test/reference test/stroke-pattern.c test/text-pattern.c
Adrian Johnson
ajohnson at kemper.freedesktop.org
Thu Sep 22 07:15:17 PDT 2011
dev/null |binary
test/Makefile.refs | 1
test/Makefile.sources | 1
test/reference/stroke-pattern.ref.png |binary
test/reference/text-pattern.ref.png |binary
test/stroke-pattern.c | 68 ++++++++++++++++++++++++++++++++++
test/text-pattern.c | 22 +++++++----
7 files changed, 85 insertions(+), 7 deletions(-)
New commits:
commit d43f6d74599984162cad5a4b522c4b70596056f5
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Thu Sep 22 23:16:53 2011 +0930
test: make text-pattern draw with both opaque and translucent patterns
Poppler renders the translucent PDF output of this test correctly with
cairo 1.10.2 but fails with current git.
diff --git a/test/reference/text-pattern.ref.png b/test/reference/text-pattern.ref.png
index 272ee1a..df438a5 100644
Binary files a/test/reference/text-pattern.ref.png and b/test/reference/text-pattern.ref.png differ
diff --git a/test/reference/text-pattern.rgb24.ref.png b/test/reference/text-pattern.rgb24.ref.png
deleted file mode 100644
index 99e9e7d..0000000
Binary files a/test/reference/text-pattern.rgb24.ref.png and /dev/null differ
diff --git a/test/text-pattern.c b/test/text-pattern.c
index 6508b5e..60267d6 100644
--- a/test/text-pattern.c
+++ b/test/text-pattern.c
@@ -25,11 +25,12 @@
#include "cairo-test.h"
-#define IMAGE_WIDTH 64
+#define IMAGE_WIDTH 128
#define IMAGE_HEIGHT 64
-static cairo_test_status_t
-draw (cairo_t *cr, int width, int height)
+
+static void
+draw_text_pattern (cairo_t *cr, double alpha)
{
cairo_pattern_t *pat;
@@ -37,11 +38,9 @@ draw (cairo_t *cr, int width, int height)
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
- cairo_scale (cr, width, height);
-
pat = cairo_pattern_create_linear (0.0, 0.0, 1, 1);
- cairo_pattern_add_color_stop_rgba (pat, 1, 1, 0, 0, 1);
- cairo_pattern_add_color_stop_rgba (pat, 0, 0, 0, 1, 1);
+ cairo_pattern_add_color_stop_rgba (pat, 1, 1, 0, 0, alpha);
+ cairo_pattern_add_color_stop_rgba (pat, 0, 0, 0, 1, alpha);
cairo_set_source (cr, pat);
/* test rectangle - make sure the gradient is set correctly */
@@ -53,6 +52,15 @@ draw (cairo_t *cr, int width, int height)
cairo_show_text (cr, "cairo");
cairo_pattern_destroy (pat);
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_scale (cr, width/2, height);
+ draw_text_pattern (cr, 1.0);
+ cairo_translate (cr, 1, 0);
+ draw_text_pattern (cr, 0.5);
return CAIRO_TEST_SUCCESS;
}
commit b30b0c14cba102a9e4f5f04226fbdbecc2268a77
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Thu Sep 22 22:43:07 2011 +0930
test: Add stroke-pattern
Poppler renders the PDF output of this test correctly with cairo 1.10.2 but fails with current git.
Commenting out the cairo_translate makes the PDF output render correctly with current git.
diff --git a/test/Makefile.refs b/test/Makefile.refs
index bae5edb..1abb533 100644
--- a/test/Makefile.refs
+++ b/test/Makefile.refs
@@ -2496,6 +2496,7 @@ REFERENCE_IMAGES = \
reference/stroke-open-box.ref.png \
reference/stroke-open-box.traps.argb32.ref.png \
reference/stroke-open-box.traps.rgb24.ref.png \
+ reference/stroke-pattern.ref.png \
reference/subsurface-image-repeat.base.argb32.ref.png \
reference/subsurface-image-repeat.base.rgb24.ref.png \
reference/subsurface-image-repeat.image16.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 1919e01..b7d2165 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -291,6 +291,7 @@ test_sources = \
source-clip-scale.c \
source-surface-scale-paint.c \
spline-decomposition.c \
+ stroke-pattern.c \
subsurface.c \
subsurface-image-repeat.c \
subsurface-repeat.c \
diff --git a/test/reference/stroke-pattern.ref.png b/test/reference/stroke-pattern.ref.png
new file mode 100644
index 0000000..61ea33e
Binary files /dev/null and b/test/reference/stroke-pattern.ref.png differ
diff --git a/test/stroke-pattern.c b/test/stroke-pattern.c
new file mode 100644
index 0000000..01e1019
--- /dev/null
+++ b/test/stroke-pattern.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2011 Adrian Johnson
+ *
+ * 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: Adrian Johnson <ajohnson at redneon.com>
+ */
+
+#include "cairo-test.h"
+
+#define IMAGE_WIDTH 80
+#define IMAGE_HEIGHT 80
+
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *pattern;
+
+ cairo_test_paint_checkered (cr);
+
+ cairo_scale (cr, 0.3, 0.3);
+ cairo_translate (cr, 50, 50);
+
+ pattern = cairo_pattern_create_linear (70, 100, 130, 100);
+ cairo_pattern_add_color_stop_rgba (pattern, 0, 1, 0, 0, 1.0);
+ cairo_pattern_add_color_stop_rgba (pattern, 1, 0, 1, 0, 0.5);
+
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
+ cairo_set_source (cr, pattern);
+
+ cairo_move_to(cr, 20, 20);
+ cairo_curve_to(cr,
+ 130, 0,
+ 70, 200,
+ 180, 180);
+ cairo_set_line_width (cr, 20);
+ cairo_stroke (cr);
+
+ cairo_pattern_destroy (pattern);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (stroke_pattern,
+ "Patterned stroke",
+ "stroke, pattern", /* keywords */
+ NULL, /* requirements */
+ IMAGE_WIDTH, IMAGE_HEIGHT,
+ NULL, draw)
More information about the cairo-commit
mailing list