summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-04-29 15:19:40 +0100
committerCarl Worth <cworth@cworth.org>2008-06-19 17:28:25 -0700
commit90e0b7685fc329429cbf37c80442067468ef4492 (patch)
treebae2b8d9736cd7e5fec0ff451c2e2aebea92fa9b
parent05a8e303116a6a8d99ad14d7e12418f0b832a19e (diff)
downloadcairo-90e0b7685fc329429cbf37c80442067468ef4492.tar.gz
[test] Add test case for a leaky dashed rectangle.
Franz Schmid reported on the mailing list, http://lists.cairographics.org/archives/cairo/2008-April/013912.html, an issue with drawing a dashed rubber band in Scribus. The problem appears when segments of the dashed rectangle are outside the image, with the errant dash connecting the ends of the visible segments.
-rw-r--r--test/.gitignore1
-rw-r--r--test/Makefile.am2
-rw-r--r--test/leaky-dashed-rectangle-ref.pngbin0 -> 444 bytes
-rw-r--r--test/leaky-dashed-rectangle.c92
4 files changed, 95 insertions, 0 deletions
diff --git a/test/.gitignore b/test/.gitignore
index 9d2587ba6..b339d2cd2 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -92,6 +92,7 @@ in-fill-trapezoid
invalid-matrix
large-source
leaky-dash
+leaky-dashed-rectangle
leaky-polygon
line-width
line-width-scale
diff --git a/test/Makefile.am b/test/Makefile.am
index faf82f0dd..4e0340fe5 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -71,6 +71,7 @@ in-fill-trapezoid$(EXEEXT) \
invalid-matrix$(EXEEXT) \
large-source$(EXEEXT) \
leaky-dash$(EXEEXT) \
+leaky-dashed-rectangle$(EXEEXT) \
leaky-polygon$(EXEEXT) \
line-width$(EXEEXT) \
line-width-scale$(EXEEXT) \
@@ -433,6 +434,7 @@ REFERENCE_IMAGES = \
leaky-dash-ps-rgb24-ref.png \
leaky-dash-quartz-ref.png \
leaky-dash-ref.png \
+ leaky-dashed-rectangle-ref.png \
leaky-polygon-ref.png \
leaky-polygon-ps-ref.png \
linear-gradient-reflect-ref.png \
diff --git a/test/leaky-dashed-rectangle-ref.png b/test/leaky-dashed-rectangle-ref.png
new file mode 100644
index 000000000..e432de268
--- /dev/null
+++ b/test/leaky-dashed-rectangle-ref.png
Binary files differ
diff --git a/test/leaky-dashed-rectangle.c b/test/leaky-dashed-rectangle.c
new file mode 100644
index 000000000..0d9e2460b
--- /dev/null
+++ b/test/leaky-dashed-rectangle.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright © 2008 Chris Wilson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Chris Wilson not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Chris Wilson makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Chris Wilson <chris@chris-wilson.co.uk>
+ * Franz Schmid <Franz.Schmid@altmuehlnet.de>
+ */
+
+/* Test case for bug reported by Franz Schmid <Franz.Schmid@altmuehlnet.de>
+ * http://lists.cairographics.org/archives/cairo/2008-April/013912.html
+ */
+
+#include "cairo-test.h"
+
+#define WIDTH 60
+#define HEIGHT 60
+
+static cairo_test_draw_function_t draw;
+
+cairo_test_t test = {
+ "leaky-dashed-rectangle",
+ "Exercises bug in which a dashed stroke leaks in from outside the surface",
+ WIDTH, HEIGHT,
+ draw
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ const double dash[2] = {4, 2};
+
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_paint (cr);
+
+ cairo_set_source_rgb (cr, 0., 0., 0);
+
+ cairo_translate (cr, 0.5, .5);
+ cairo_set_line_width (cr, 1); /* This is vital to reproduce the bug. */
+
+ /* First check simple rectangles */
+ cairo_set_source_rgb (cr, 0., 0., 0);
+ cairo_rectangle (cr, -WIDTH/4, -HEIGHT/4, WIDTH, HEIGHT);
+ cairo_stroke (cr);
+ cairo_rectangle (cr, WIDTH+WIDTH/4, -HEIGHT/4, -WIDTH, HEIGHT);
+ cairo_stroke (cr);
+ cairo_rectangle (cr, -WIDTH/4, HEIGHT+HEIGHT/4, WIDTH, -HEIGHT);
+ cairo_stroke (cr);
+ cairo_rectangle (cr, WIDTH+WIDTH/4, HEIGHT+HEIGHT/4, -WIDTH, -HEIGHT);
+ cairo_stroke (cr);
+
+ cairo_set_dash (cr, dash, 2, 0);
+
+ /* And now dashed. */
+ cairo_set_source_rgb (cr, 1., 0., 0);
+ cairo_rectangle (cr, -WIDTH/4, -HEIGHT/4, WIDTH, HEIGHT);
+ cairo_stroke (cr);
+ cairo_set_source_rgb (cr, 0., 1., 0);
+ cairo_rectangle (cr, WIDTH+WIDTH/4, -HEIGHT/4, -WIDTH, HEIGHT);
+ cairo_stroke (cr);
+ cairo_set_source_rgb (cr, 0., 0., 1);
+ cairo_rectangle (cr, -WIDTH/4, HEIGHT+HEIGHT/4, WIDTH, -HEIGHT);
+ cairo_stroke (cr);
+ cairo_set_source_rgb (cr, 1., 1., 0);
+ cairo_rectangle (cr, WIDTH+WIDTH/4, HEIGHT+HEIGHT/4, -WIDTH, -HEIGHT);
+ cairo_stroke (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test);
+}