[cairo-commit] 3 commits - configure.in README src/cairo-pen.c test/degenerate-pen.c test/degenerate-pen-ps-argb32-ref.png test/degenerate-pen-ref.png test/.gitignore test/Makefile.am
Carl Worth
cworth at kemper.freedesktop.org
Tue Oct 30 17:18:28 PDT 2007
README | 7 +-
configure.in | 2
src/cairo-pen.c | 16 ++++-
test/.gitignore | 1
test/Makefile.am | 1
test/degenerate-pen-ps-argb32-ref.png |binary
test/degenerate-pen-ref.png |binary
test/degenerate-pen.c | 104 ++++++++++++++++++++++++++++++++++
8 files changed, 126 insertions(+), 5 deletions(-)
New commits:
commit 448c9314252bba779194d2b01950b8738b26fd13
Author: Carl Worth <cworth at cworth.org>
Date: Tue Oct 30 17:09:56 2007 -0700
Fix degenerate-pen test case by removing the triggering assertion
Instead we choose either the first or last pen vertex as
appropriate.
This makes the degenerate-pen pass stop failing on an
assertion, and passes for most backends. It's still failing
for the PDF backend, but that looks like a new, PDF-specific
bug.
diff --git a/src/cairo-pen.c b/src/cairo-pen.c
index 0f0dee8..6291763 100644
--- a/src/cairo-pen.c
+++ b/src/cairo-pen.c
@@ -323,7 +323,13 @@ _cairo_pen_find_active_cw_vertex_index (cairo_pen_t *pen,
break;
}
- assert (i < pen->num_vertices);
+ /* If the desired slope cannot be found between any of the pen
+ * vertices, then we must have a degenerate pen, (such as a pen
+ * that's been transformed to a line). In that case, we consider
+ * the first pen vertex as the appropriate clockwise vertex.
+ */
+ if (i == pen->num_vertices)
+ i = 0;
*active = i;
}
@@ -351,6 +357,14 @@ _cairo_pen_find_active_ccw_vertex_index (cairo_pen_t *pen,
break;
}
+ /* If the desired slope cannot be found between any of the pen
+ * vertices, then we must have a degenerate pen, (such as a pen
+ * that's been transformed to a line). In that case, we consider
+ * the last pen vertex as the appropriate counterclockwise vertex.
+ */
+ if (i < 0)
+ i = pen->num_vertices - 1;
+
*active = i;
}
commit 5e76f652842d36086f500735f67cfd1d2f3e3edf
Author: Carl Worth <cworth at cworth.org>
Date: Tue Oct 30 17:00:33 2007 -0700
Add degenerate-pen test case.
This demonstrates the assertion failure pointed out by
Benjamin Otte here:
[cairo] Assertion 'i < pen->num_vertices' failed in 1.4.10
http://lists.cairographics.org/archives/cairo/2007-August/011282.html
diff --git a/test/.gitignore b/test/.gitignore
index 0fc28e8..b75c7f2 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -36,6 +36,7 @@ dash-scale
dash-state
dash-zero-length
degenerate-path
+degenerate-pen
device-offset
device-offset-positive
extend-pad
diff --git a/test/Makefile.am b/test/Makefile.am
index 114ae78..3e207e8 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -29,6 +29,7 @@ dash-scale \
dash-zero-length \
dash-state \
degenerate-path \
+degenerate-pen \
device-offset \
device-offset-positive \
extend-pad \
diff --git a/test/degenerate-pen-ps-argb32-ref.png b/test/degenerate-pen-ps-argb32-ref.png
new file mode 100644
index 0000000..6117f0f
Binary files /dev/null and b/test/degenerate-pen-ps-argb32-ref.png differ
diff --git a/test/degenerate-pen-ref.png b/test/degenerate-pen-ref.png
new file mode 100644
index 0000000..0ad3325
Binary files /dev/null and b/test/degenerate-pen-ref.png differ
diff --git a/test/degenerate-pen.c b/test/degenerate-pen.c
new file mode 100644
index 0000000..21bc060
--- /dev/null
+++ b/test/degenerate-pen.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * 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: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-test.h"
+
+static cairo_test_draw_function_t draw;
+
+#define SIZE 20
+#define PAD 5
+#define WIDTH (PAD + 3 * (PAD + SIZE) + PAD)
+#define HEIGHT (PAD + SIZE + PAD)
+
+/* We're demonstrating here a bug originally reported by Benjamin Otte
+ * on the cairo mailing list here, (after he ran into this problem
+ * with various flash animations):
+ *
+ * [cairo] Assertion `i < pen->num_vertices' failed in 1.4.10
+ * http://lists.cairographics.org/archives/cairo/2007-August/011282.html
+ *
+ * The problem shows up with an extreme transformation matrix that
+ * collapses the pen to a single line, (which means that
+ * _cairo_slope_compare cannot handle adjacent vertices in the pen
+ * since they have parallel slope).
+ *
+ * This test case tests degenerate pens in several directions and uses
+ * round caps to force the stroking code to attempt to walk around the
+ * pen doing slope comparisons.
+ */
+
+cairo_test_t test = {
+ "degenerate-pen",
+ "Test round joins with a pen that's transformed to a line",
+ WIDTH, HEIGHT,
+ draw
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+
+ cairo_translate (cr, PAD, PAD);
+
+ /* First compress the pen to a vertical line. */
+ cairo_rectangle (cr, 0, 0, SIZE, SIZE);
+ cairo_save (cr);
+ {
+ cairo_scale (cr, 0.000001, 1.0);
+ cairo_stroke (cr);
+ }
+ cairo_restore (cr);
+
+ cairo_translate (cr, PAD + SIZE, 0);
+
+ /* Then compress the pen to a horizontal line. */
+ cairo_rectangle (cr, 0, 0, SIZE, SIZE);
+ cairo_save (cr);
+ {
+ cairo_scale (cr, 1.0, 0.000001);
+ cairo_stroke (cr);
+ }
+ cairo_restore (cr);
+
+ cairo_translate (cr, PAD + SIZE, 0);
+
+ /* Finally a line at an angle. */
+ cairo_rectangle (cr, 0, 0, SIZE, SIZE);
+ cairo_save (cr);
+ {
+ cairo_rotate (cr, M_PI / 4.0);
+ cairo_scale (cr, 0.000001, 1.0);
+ cairo_stroke (cr);
+ }
+ cairo_restore (cr);
+}
+
+int
+main (void)
+{
+ return cairo_test (&test);
+}
commit 53378301d42eabc1ebedca983092f522299bd18e
Author: Carl Worth <cworth at cworth.org>
Date: Tue Oct 30 13:13:29 2007 -0700
Update URLs for pixman to point to cairographics.org
diff --git a/README b/README
index bbf0663..b6881bf 100644
--- a/README
+++ b/README
@@ -65,9 +65,10 @@ each backend:
Surface backends:
- image backend
- -------------
- pixman git://git.freedesktop.org/git/pixman
+ image backend (required)
+ ------------------------
+ pixman http://cairographics.org/releases
+ or: git://git.cairographics.org/git/pixman
glitz backend
-------------
diff --git a/configure.in b/configure.in
index 59a7375..08d8e49 100644
--- a/configure.in
+++ b/configure.in
@@ -258,7 +258,7 @@ PIXMAN_VERSION="0.9.4"
PIXMAN_REQUIRES="pixman-1 >= $PIXMAN_VERSION"
PKG_CHECK_MODULES(pixman, $PIXMAN_REQUIRES, ,
[AC_MSG_ERROR([pixman >= $PIXMAN_VERSION is required
-(http://xorg.freedesktop.org/releases/individual/lib/pixman-$PIXMAN_VERSION.tar.gz)])])
+(http://cairographics.org/releases/)])])
CAIRO_REQUIRES="$PIXMAN_REQUIRES $CAIRO_REQUIRES"
CAIRO_CFLAGS="$pixman_CFLAGS $CAIRO_CFLAGS"
More information about the cairo-commit
mailing list