[cairo-commit] test/Makefile.am test/stroke-ctm-caps.c test/stroke-ctm-caps-quartz-ref.png test/stroke-ctm-caps-ref.png

Vladimir Vukicevic vladimir at kemper.freedesktop.org
Thu Mar 13 17:31:07 PDT 2008


 test/Makefile.am                    |    3 +
 test/stroke-ctm-caps-quartz-ref.png |binary
 test/stroke-ctm-caps-ref.png        |binary
 test/stroke-ctm-caps.c              |   86 ++++++++++++++++++++++++++++++++++++
 4 files changed, 89 insertions(+)

New commits:
commit 4cc93881d9603c90f1318b2eb822cf2c516ecf7d
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date:   Thu Mar 13 17:30:59 2008 -0700

    [test] Add testcase for previous stroker regression fix
    
    Add Adrian's original testcase for reproducing the stroker device
    vector issue.  (b4f518f917f5062537ee3c6a7a54180017b2c588)

diff --git a/test/Makefile.am b/test/Makefile.am
index b457f39..ce5f031 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -109,6 +109,7 @@ rgb24-ignore-alpha$(EXEEXT)				\
 rotate-image-surface-paint$(EXEEXT)			\
 scale-down-source-surface-paint$(EXEEXT)		\
 scale-source-surface-paint$(EXEEXT)			\
+stroke-ctm-caps$(EXEEXT)				\
 select-font-face$(EXEEXT)				\
 select-font-no-show-text$(EXEEXT)			\
 self-copy$(EXEEXT)					\
@@ -530,6 +531,8 @@ REFERENCE_IMAGES = \
 	scale-source-surface-paint-svg-argb32-ref.png	\
 	scale-source-surface-paint-svg-rgb24-ref.png	\
 	scale-source-surface-paint-pdf-rgb24-ref.png \
+	stroke-ctm-caps-ref.png \
+	stroke-ctm-caps-quartz-ref.png \
 	select-font-face-ref.png	\
 	select-font-face-ps-ref.png \
 	select-font-face-quartz-ref.png \
diff --git a/test/stroke-ctm-caps-quartz-ref.png b/test/stroke-ctm-caps-quartz-ref.png
new file mode 100644
index 0000000..45ea145
Binary files /dev/null and b/test/stroke-ctm-caps-quartz-ref.png differ
diff --git a/test/stroke-ctm-caps-ref.png b/test/stroke-ctm-caps-ref.png
new file mode 100644
index 0000000..f364357
Binary files /dev/null and b/test/stroke-ctm-caps-ref.png differ
diff --git a/test/stroke-ctm-caps.c b/test/stroke-ctm-caps.c
new file mode 100644
index 0000000..07a918e
--- /dev/null
+++ b/test/stroke-ctm-caps.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright © 2008 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"
+
+static cairo_test_draw_function_t draw;
+
+#define SIZE 100
+#define PAD 2
+#define WIDTH (PAD + SIZE + PAD)
+#define HEIGHT WIDTH
+
+/* This test is designed to test that PDF viewers use the correct
+ * alpha values in an Alpha SMasks. Some viewers use the color values
+ * instead of the alpha. The test draws a triangle and rectangle in a
+ * group then draws the group using cairo_mask(). The mask consists of
+ * a circle with the rgba (0.4, 0.4, 0.4, 0.8) and the background rgba
+ * (0.8, 0.8, 0.8, 0.4).
+ */
+
+cairo_test_t test = {
+    "stroke-ctm-caps",
+    "Test that the stroker correctly passes the device-space vector to the stroker for endcaps",
+    WIDTH, HEIGHT,
+    draw
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    cairo_set_source_rgb (cr, 1, 1, 1);
+    cairo_paint (cr);
+
+    /* flip the CTM, which most clearly shows the problem */
+    cairo_translate (cr, 0, HEIGHT);
+    cairo_scale (cr, 1, -1);
+
+    cairo_set_source_rgb (cr, 0, 0, 0);
+
+    cairo_set_line_width (cr, 10);
+    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+
+    cairo_move_to (cr, 20, 20);
+    cairo_line_to (cr, 20, 70);
+    cairo_stroke (cr);
+
+    cairo_move_to (cr, 40, 20);
+    cairo_line_to (cr, 70, 70);
+    cairo_stroke (cr);
+
+    cairo_move_to (cr, 60, 20);
+    cairo_line_to (cr, 90, 20);
+    cairo_stroke (cr);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+    return cairo_test (&test);
+}


More information about the cairo-commit mailing list