summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2005-09-27 12:51:00 +0000
committerCarl Worth <cworth@cworth.org>2005-09-27 12:51:00 +0000
commit4b1fca82a877df391b47638b3f00f1c44873c82c (patch)
treeaa419fb1da58538f8537f412895a059785ed62d3
parent031943b4e4553c4fcdf5ccd2eb2f8674fc385e83 (diff)
Note that bug #4409 (Dashes are missing initial caps) is now fixed.
Move face-flipping from inside _cairo_stroker_add_caps to new _cairo_stroker_add_leading_cap variant of _cairo_stoker_add_cap. Change to call _cairo_stroker_add_leading_cap or _cairo_stroker_add_trailing_cap as appropriate. Remove dash-caps-joins from the XFAIL list and add reference image.
-rw-r--r--ChangeLog21
-rw-r--r--src/cairo-path-stroke.c51
-rw-r--r--test/Makefile.am1
-rw-r--r--test/caps-joins-ref.pngbin0 -> 1262 bytes
-rw-r--r--test/caps-joins.c85
-rw-r--r--test/dash-caps-joins-ref.pngbin0 -> 2347 bytes
-rw-r--r--test/dash-caps-joins.c94
7 files changed, 235 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 4aaf9a029..5504f9c3f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
2005-09-27 Carl Worth <cworth@cworth.org>
+ * ROADMAP: Note that bug #4409 (Dashes are missing initial caps)
+ is now fixed.
+
+ * src/cairo-path-stroke.c: (_cairo_stroker_add_cap),
+ (_cairo_stroker_add_leading_cap),
+ (_cairo_stroker_add_trailing_cap),
+ (_cairo_stroker_add_caps): Move face-flipping from inside
+ _cairo_stroker_add_caps to new _cairo_stroker_add_leading_cap
+ variant of _cairo_stoker_add_cap.
+
+ * src/cairo-path-stroke.c: (_cairo_stroker_line_to_dashed): Change
+ to call _cairo_stroker_add_leading_cap or
+ _cairo_stroker_add_trailing_cap as appropriate.
+
+ * test/Makefile.am (XFAIL_TESTS):
+ * test/dash-caps-joins-ref.png:
+ * test/dash-caps-joins.c: (main): Remove dash-caps-joins from the
+ XFAIL list and add reference image.
+
+2005-09-27 Carl Worth <cworth@cworth.org>
+
* test/.cvsignore:
* test/Makefile.am:
* test/caps-joins-ref.png:
diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index 5bffcea8e..c701f0c49 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -341,7 +341,7 @@ _cairo_stroker_join (cairo_stroker_t *stroker, cairo_stroke_face_t *in, cairo_st
}
static cairo_status_t
-_cairo_stroker_cap (cairo_stroker_t *stroker, cairo_stroke_face_t *f)
+_cairo_stroker_add_cap (cairo_stroker_t *stroker, cairo_stroke_face_t *f)
{
cairo_status_t status;
cairo_gstate_t *gstate = stroker->gstate;
@@ -412,27 +412,46 @@ _cairo_stroker_cap (cairo_stroker_t *stroker, cairo_stroke_face_t *f)
}
static cairo_status_t
+_cairo_stroker_add_leading_cap (cairo_stroker_t *stroker,
+ cairo_stroke_face_t *face)
+{
+ cairo_stroke_face_t reversed;
+ cairo_point_t t;
+
+ reversed = *face;
+
+ /* The initial cap needs an outward facing vector. Reverse everything */
+ reversed.usr_vector.x = -reversed.usr_vector.x;
+ reversed.usr_vector.y = -reversed.usr_vector.y;
+ reversed.dev_vector.dx = -reversed.dev_vector.dx;
+ reversed.dev_vector.dy = -reversed.dev_vector.dy;
+ t = reversed.cw;
+ reversed.cw = reversed.ccw;
+ reversed.ccw = t;
+
+ return _cairo_stroker_add_cap (stroker, &reversed);
+}
+
+static cairo_status_t
+_cairo_stroker_add_trailing_cap (cairo_stroker_t *stroker,
+ cairo_stroke_face_t *face)
+{
+ return _cairo_stroker_add_cap (stroker, face);
+}
+
+static cairo_status_t
_cairo_stroker_add_caps (cairo_stroker_t *stroker)
{
cairo_status_t status;
if (stroker->has_first_face) {
- cairo_point_t t;
- /* The initial cap needs an outward facing vector. Reverse everything */
- stroker->first_face.usr_vector.x = -stroker->first_face.usr_vector.x;
- stroker->first_face.usr_vector.y = -stroker->first_face.usr_vector.y;
- stroker->first_face.dev_vector.dx = -stroker->first_face.dev_vector.dx;
- stroker->first_face.dev_vector.dy = -stroker->first_face.dev_vector.dy;
- t = stroker->first_face.cw;
- stroker->first_face.cw = stroker->first_face.ccw;
- stroker->first_face.ccw = t;
- status = _cairo_stroker_cap (stroker, &stroker->first_face);
+ status = _cairo_stroker_add_leading_cap (stroker, &stroker->first_face);
if (status)
return status;
}
if (stroker->has_current_face) {
- status = _cairo_stroker_cap (stroker, &stroker->current_face);
+ status = _cairo_stroker_add_trailing_cap (stroker, &stroker->current_face);
if (status)
return status;
}
@@ -673,7 +692,7 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point)
/*
* Not first dash in this segment, cap start
*/
- status = _cairo_stroker_cap (stroker, &sub_start);
+ status = _cairo_stroker_add_leading_cap (stroker, &sub_start);
if (status)
return status;
} else {
@@ -691,7 +710,7 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point)
stroker->first_face = sub_start;
stroker->has_first_face = 1;
} else {
- status = _cairo_stroker_cap (stroker, &sub_start);
+ status = _cairo_stroker_add_leading_cap (stroker, &sub_start);
if (status)
return status;
}
@@ -701,7 +720,7 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point)
/*
* Cap if not at end of segment
*/
- status = _cairo_stroker_cap (stroker, &sub_end);
+ status = _cairo_stroker_add_trailing_cap (stroker, &sub_end);
if (status)
return status;
} else {
@@ -719,7 +738,7 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point)
*/
if (first) {
if (stroker->has_current_face) {
- status = _cairo_stroker_cap (stroker, &stroker->current_face);
+ status = _cairo_stroker_add_trailing_cap (stroker, &stroker->current_face);
if (status)
return status;
}
diff --git a/test/Makefile.am b/test/Makefile.am
index cbb62bab0..eb2b9be4e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -150,7 +150,6 @@ rel-path-ref.png
# provide an explanation for the expected failure.
XFAIL_TESTS = \
a8-mask \
-dash-caps-joins \
filter-nearest-offset \
pixman-rotate \
self-intersecting \
diff --git a/test/caps-joins-ref.png b/test/caps-joins-ref.png
new file mode 100644
index 000000000..e7547cae4
--- /dev/null
+++ b/test/caps-joins-ref.png
Binary files differ
diff --git a/test/caps-joins.c b/test/caps-joins.c
new file mode 100644
index 000000000..7c5b1f0e2
--- /dev/null
+++ b/test/caps-joins.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * 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
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. 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: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+#define LINE_WIDTH 10.
+#define SIZE (5 * LINE_WIDTH)
+#define PAD (2 * LINE_WIDTH)
+
+cairo_test_t test = {
+ "caps-joins",
+ "Test caps and joins",
+ 3 * (PAD + SIZE) + PAD,
+ PAD + SIZE + PAD
+};
+
+static void
+make_path (cairo_t *cr)
+{
+ cairo_move_to (cr, 0., 0.);
+ cairo_rel_line_to (cr, 0., SIZE);
+ cairo_rel_line_to (cr, SIZE, 0.);
+ cairo_close_path (cr);
+
+ cairo_move_to (cr, 2 * LINE_WIDTH, 0.);
+ cairo_rel_line_to (cr, 3 * LINE_WIDTH, 0.);
+ cairo_rel_line_to (cr, 0., 3 * LINE_WIDTH);
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_set_line_width (cr, LINE_WIDTH);
+
+ cairo_translate (cr, PAD, PAD);
+
+ make_path (cr);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL);
+ cairo_stroke (cr);
+
+ cairo_translate (cr, SIZE + PAD, 0.);
+
+ make_path (cr);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+ cairo_stroke (cr);
+
+ cairo_translate (cr, SIZE + PAD, 0.);
+
+ make_path (cr);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+ cairo_stroke (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/dash-caps-joins-ref.png b/test/dash-caps-joins-ref.png
new file mode 100644
index 000000000..c44352bcd
--- /dev/null
+++ b/test/dash-caps-joins-ref.png
Binary files differ
diff --git a/test/dash-caps-joins.c b/test/dash-caps-joins.c
new file mode 100644
index 000000000..d0e68ecfc
--- /dev/null
+++ b/test/dash-caps-joins.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * 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
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. 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: Carl D. Worth <cworth@cworth.org>
+ */
+
+/* Test case for bug #4409:
+ *
+ * Dashes are missing initial caps
+ * https://bugs.freedesktop.org/show_bug.cgi?id=4409
+ */
+
+#include "cairo-test.h"
+
+#define LINE_WIDTH 10.
+#define SIZE (5 * LINE_WIDTH)
+#define PAD (2 * LINE_WIDTH)
+
+cairo_test_t test = {
+ "dash-caps-joins",
+ "Test caps and joins when dashing",
+ 3 * (PAD + SIZE) + PAD,
+ PAD + SIZE + PAD
+};
+
+static void
+make_path (cairo_t *cr)
+{
+ cairo_move_to (cr, 0., 0.);
+ cairo_rel_line_to (cr, 0., SIZE);
+ cairo_rel_line_to (cr, SIZE, 0.);
+ cairo_close_path (cr);
+
+ cairo_move_to (cr, 2 * LINE_WIDTH, 0.);
+ cairo_rel_line_to (cr, 3 * LINE_WIDTH, 0.);
+ cairo_rel_line_to (cr, 0., 3 * LINE_WIDTH);
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ double dash[] = {LINE_WIDTH, 1.5 * LINE_WIDTH};
+
+ cairo_set_line_width (cr, LINE_WIDTH);
+ cairo_set_dash (cr, dash, sizeof(dash)/sizeof(dash[0]), - 2 * LINE_WIDTH);
+
+ cairo_translate (cr, PAD, PAD);
+
+ make_path (cr);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL);
+ cairo_stroke (cr);
+
+ cairo_translate (cr, SIZE + PAD, 0.);
+
+ make_path (cr);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+ cairo_stroke (cr);
+
+ cairo_translate (cr, SIZE + PAD, 0.);
+
+ make_path (cr);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+ cairo_stroke (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}