[cairo-commit] test/.gitignore test/leaky-dashed-rectangle.c test/leaky-dashed-rectangle-ref.png test/Makefile.am
Chris Wilson
ickle at kemper.freedesktop.org
Tue Apr 29 07:21:35 PDT 2008
test/.gitignore | 1
test/Makefile.am | 2
test/leaky-dashed-rectangle-ref.png |binary
test/leaky-dashed-rectangle.c | 92 ++++++++++++++++++++++++++++++++++++
4 files changed, 95 insertions(+)
New commits:
commit 8742429c7958bb7f87595b1c018b4da7856b2f92
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Apr 29 15:19:40 2008 +0100
[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.
diff --git a/test/.gitignore b/test/.gitignore
index 8f09a96..f34494e 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -93,6 +93,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 11880cb..ec98a49 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -72,6 +72,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) \
@@ -441,6 +442,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 0000000..e432de2
Binary files /dev/null and b/test/leaky-dashed-rectangle-ref.png differ
diff --git a/test/leaky-dashed-rectangle.c b/test/leaky-dashed-rectangle.c
new file mode 100644
index 0000000..0d9e246
--- /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 at chris-wilson.co.uk>
+ * Franz Schmid <Franz.Schmid at altmuehlnet.de>
+ */
+
+/* Test case for bug reported by Franz Schmid <Franz.Schmid at 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);
+}
More information about the cairo-commit
mailing list