[cairo-commit] 5 commits - perf/cairo-perf-trace.c perf/stroke.c src/cairo-path-fixed.c src/cairo-path-fixed-private.h test/degenerate-rel-curve-to.c test/degenerate-rel-curve-to.ps.xfail.png test/degenerate-rel-curve-to.ref.png test/Makefile.am test/Makefile.sources
Chris Wilson
ickle at kemper.freedesktop.org
Wed Jul 29 08:25:38 PDT 2009
perf/cairo-perf-trace.c | 4 -
perf/stroke.c | 36 ++++++++++
src/cairo-path-fixed-private.h | 1
src/cairo-path-fixed.c | 15 ++--
test/Makefile.am | 2
test/Makefile.sources | 1
test/degenerate-rel-curve-to.c | 99 ++++++++++++++++++++++++++++++
test/degenerate-rel-curve-to.ps.xfail.png |binary
test/degenerate-rel-curve-to.ref.png |binary
9 files changed, 147 insertions(+), 11 deletions(-)
New commits:
commit 8c6ecfe6488dff93090d5d0a2d814466804bc7de
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Jul 29 16:17:36 2009 +0100
[perf] Remove the warning about failing to open a directory
The warning is repeated in the error message if we fail to find any
traces, and now that we search a path it is likely that some elements do
not exist. Thus we annoy the user with irrelevant, non-fatal warnings.
Still looking for suggestions for the most appropriate home for the system
wide cairo-traces dir...
diff --git a/perf/cairo-perf-trace.c b/perf/cairo-perf-trace.c
index abe9b1e..a7bfbba 100644
--- a/perf/cairo-perf-trace.c
+++ b/perf/cairo-perf-trace.c
@@ -655,10 +655,8 @@ cairo_perf_trace_dir (cairo_perf_t *perf,
int num_traces = 0;
dir = opendir (dirname);
- if (dir == NULL) {
- fprintf (stderr, "Failed to open directory '%s'\n", dirname);
+ if (dir == NULL)
return 0;
- }
while ((de = readdir (dir)) != NULL) {
char *trace;
commit 8c1aed17ca5dafb00175ac413d56760a3ef012f9
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Jul 29 13:24:19 2009 +0100
[perf] Add another stroking micro-benchmark
The original stroke only contains a single subpath. Self-intersection
removal particularly affects strokes with multiple curved segments, so add
a path that encompasses both straight edges and rounded corners.
diff --git a/perf/stroke.c b/perf/stroke.c
index 7b3990d..b360226 100644
--- a/perf/stroke.c
+++ b/perf/stroke.c
@@ -44,6 +44,41 @@ do_stroke (cairo_t *cr, int width, int height)
return cairo_perf_timer_elapsed ();
}
+static void
+rounded_rectangle (cairo_t *cr,
+ double x, double y, double w, double h,
+ double radius)
+{
+ cairo_move_to (cr, x+radius, y);
+ cairo_arc (cr, x+w-radius, y+radius, radius, M_PI + M_PI / 2, M_PI * 2 );
+ cairo_arc (cr, x+w-radius, y+h-radius, radius, 0, M_PI / 2 );
+ cairo_arc (cr, x+radius, y+h-radius, radius, M_PI/2, M_PI );
+ cairo_arc (cr, x+radius, y+radius, radius, M_PI, 270 * M_PI / 180);
+}
+
+static cairo_perf_ticks_t
+do_strokes (cairo_t *cr, int width, int height)
+{
+ /* a pair of overlapping rectangles */
+ rounded_rectangle (cr,
+ 2, 2, width/2. + 10, height/2. + 10,
+ 10);
+ rounded_rectangle (cr,
+ width/2. - 10, height/2. - 10,
+ width - 2, height - 2,
+ 10);
+
+ cairo_set_line_width (cr, 2.);
+
+ cairo_perf_timer_start ();
+
+ cairo_stroke (cr);
+
+ cairo_perf_timer_stop ();
+
+ return cairo_perf_timer_elapsed ();
+}
+
void
stroke (cairo_perf_t *perf, cairo_t *cr, int width, int height)
{
@@ -51,4 +86,5 @@ stroke (cairo_perf_t *perf, cairo_t *cr, int width, int height)
return;
cairo_perf_cover_sources_and_operators (perf, "stroke", do_stroke);
+ cairo_perf_cover_sources_and_operators (perf, "strokes", do_strokes);
}
commit 71f5649846aa8e9e2178e7caf69ab47554f86c4d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Jul 29 15:36:25 2009 +0100
[path] Fix iter to handle circular list of buffers
When switching the path over to use the circularly linked list, 73f801,
I missed updating the path iterator.
diff --git a/src/cairo-path-fixed-private.h b/src/cairo-path-fixed-private.h
index 1ef7cdd..f25a45e 100644
--- a/src/cairo-path-fixed-private.h
+++ b/src/cairo-path-fixed-private.h
@@ -112,6 +112,7 @@ _cairo_path_fixed_equal (const cairo_path_fixed_t *a,
const cairo_path_fixed_t *b);
typedef struct _cairo_path_fixed_iter {
+ const cairo_path_buf_t *first;
const cairo_path_buf_t *buf;
unsigned int n_op;
unsigned int n_point;
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index 8b5d5c5..921c79e 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -1143,7 +1143,7 @@ void
_cairo_path_fixed_iter_init (cairo_path_fixed_iter_t *iter,
const cairo_path_fixed_t *path)
{
- iter->buf = cairo_path_head (path);
+ iter->first = iter->buf = cairo_path_head (path);
iter->n_op = 0;
iter->n_point = 0;
}
@@ -1153,11 +1153,16 @@ _cairo_path_fixed_iter_next_op (cairo_path_fixed_iter_t *iter)
{
if (++iter->n_op >= iter->buf->num_ops) {
iter->buf = cairo_path_buf_next (iter->buf);
+ if (iter->buf == iter->first) {
+ iter->buf = NULL;
+ return FALSE;
+ }
+
iter->n_op = 0;
iter->n_point = 0;
}
- return iter->buf != NULL;
+ return TRUE;
}
cairo_bool_t
commit acfcf4a31b3370ca7bbdd522fad9ddc483df3472
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Jul 29 16:10:04 2009 +0100
[path] Remove the broken rel-curve-to as line-to
As pointed out by Andrea, and now tested by test/degenerate-rel-curve-to,
this attempt at removing degenerate curve-to was broken.
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index 6ed717c..8b5d5c5 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -522,12 +522,6 @@ _cairo_path_fixed_rel_curve_to (cairo_path_fixed_t *path,
if (unlikely (! path->has_current_point))
return _cairo_error (CAIRO_STATUS_NO_CURRENT_POINT);
- if (dx2 == 0 && dy2 == 0) {
- return _cairo_path_fixed_line_to (path,
- path->current_point.x,
- path->current_point.y);
- }
-
return _cairo_path_fixed_curve_to (path,
path->current_point.x + dx0,
path->current_point.y + dy0,
commit 81d3e15e6ca7b7c1a07fdfb6d03c43484ce9f502
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Jul 29 16:07:17 2009 +0100
[test] Yet another bug in curve-to as line-to.
Andrea Canciani (ranma42) found another instance of my broken 'degenerate'
curve-to as line-to optimisation. All I can say is when I do something
wrong, at least I'm consistent!
This test case highlights the bug in the rel-curve-to path.
diff --git a/test/Makefile.am b/test/Makefile.am
index 7a04e5e..8ef31ca 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -306,6 +306,8 @@ REFERENCE_IMAGES = \
degenerate-pen.ps3.ref.png \
degenerate-pen.quartz.ref.png \
degenerate-pen.ref.png \
+ degenerate-rel-curve-to.ref.png \
+ degenerate-rel-curve-to.ps.xfail.png \
device-offset-fractional.gl.xfail.png \
device-offset-fractional.pdf.argb32.ref.png \
device-offset-fractional.pdf.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index ec7be36..dd71856 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -49,6 +49,7 @@ test_sources = \
degenerate-dash.c \
degenerate-path.c \
degenerate-pen.c \
+ degenerate-rel-curve-to.c \
device-offset.c \
device-offset-fractional.c \
device-offset-positive.c \
diff --git a/test/degenerate-rel-curve-to.c b/test/degenerate-rel-curve-to.c
new file mode 100644
index 0000000..d7c0523
--- /dev/null
+++ b/test/degenerate-rel-curve-to.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ * Copyright © 2009 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
+ * 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 at cworth.org>
+ * Chris Wilson <chris at chris-wilson.co.uk>
+ */
+
+#include "cairo-test.h"
+
+#define SIZE 30
+
+/* Another attempt at avoiding unnecessary splines was made, where
+ * a curve-to that ended on the same point as it began were discarded.
+ * The same bug was made to rel-curve-to as well, hence this test.
+ */
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
+ cairo_paint (cr);
+
+ cairo_set_line_width (cr, 1.0);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
+ cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL);
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */
+
+ /* entirely degenerate */
+ cairo_move_to (cr, 2.5, 2.5);
+ cairo_rel_curve_to (cr,
+ 0., 0.,
+ 0., 0.,
+ 0., 0.);
+ cairo_stroke (cr);
+
+ /* horizontal */
+ cairo_move_to (cr, 5.5, 2.5);
+ cairo_rel_curve_to (cr,
+ 10., 0.,
+ -10., 0.,
+ 0., 0.);
+ cairo_stroke (cr);
+
+ /* vertical */
+ cairo_move_to (cr, 5.5, 2.5);
+ cairo_rel_curve_to (cr,
+ 0., 10.,
+ 0., -10.,
+ 0., 0.);
+ cairo_stroke (cr);
+
+ cairo_translate (cr, 15, 0);
+
+ /* horizontal/vertical */
+ cairo_move_to (cr, 5.5, 0.5);
+ cairo_rel_curve_to (cr,
+ -6., 0.,
+ 0., 10.,
+ 0., 0.);
+
+ cairo_translate (cr, 10, 0);
+
+ /* vertical/horizontal */
+ cairo_move_to (cr, 5.5, 0.0);
+ cairo_rel_curve_to (cr,
+ 0., 11.,
+ 5., 0.,
+ 0., 0.);
+ cairo_stroke (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (degenerate_rel_curve_to,
+ "Test optimization treating degenerate rel-curve-to as line-to",
+ "path", /* keywords */
+ NULL, /* requirements */
+ 40,
+ 5,
+ NULL, draw)
diff --git a/test/degenerate-rel-curve-to.ps.xfail.png b/test/degenerate-rel-curve-to.ps.xfail.png
new file mode 100644
index 0000000..a8e221e
Binary files /dev/null and b/test/degenerate-rel-curve-to.ps.xfail.png differ
diff --git a/test/degenerate-rel-curve-to.ref.png b/test/degenerate-rel-curve-to.ref.png
new file mode 100644
index 0000000..5f5275e
Binary files /dev/null and b/test/degenerate-rel-curve-to.ref.png differ
More information about the cairo-commit
mailing list