[cairo-commit] 5 commits - src/cairo-bentley-ottmann.c src/cairo-clip.c src/cairo-debug.c src/cairo-gl-surface.c src/cairo-image-surface.c src/cairoint.h src/cairo-path-bounds.c src/cairo-path.c src/cairo-path-fill.c src/cairo-path-fixed.c src/cairo-path-fixed-private.h src/cairo-path-in-fill.c src/cairo-path-stroke.c src/cairo-pdf-operators.c src/cairo-polygon.c src/cairo-qt-surface.cpp src/cairo-quartz-surface.c src/cairo-recording-surface.c src/cairo-scaled-font.c src/cairo-script-surface.c src/cairo-skia-surface.cpp src/cairo-surface-fallback.c src/cairo-svg-surface.c src/cairo-type1-fallback.c src/cairo-types-private.h src/cairo-vg-surface.c src/cairo-win32-printing-surface.c src/cairo-xcb-surface-render.c src/cairo-xml-surface.c src/drm
Andrea Canciani
ranma42 at kemper.freedesktop.org
Fri Dec 10 10:54:35 PST 2010
src/cairo-bentley-ottmann.c | 3 -
src/cairo-clip.c | 3 -
src/cairo-debug.c | 1
src/cairo-gl-surface.c | 6 --
src/cairo-image-surface.c | 6 --
src/cairo-path-bounds.c | 2
src/cairo-path-fill.c | 108 ++++++++++++++++---------------------
src/cairo-path-fixed-private.h | 1
src/cairo-path-fixed.c | 54 ++++--------------
src/cairo-path-in-fill.c | 1
src/cairo-path-stroke.c | 8 --
src/cairo-path.c | 22 -------
src/cairo-pdf-operators.c | 1
src/cairo-polygon.c | 105 ++---------------------------------
src/cairo-qt-surface.cpp | 1
src/cairo-quartz-surface.c | 1
src/cairo-recording-surface.c | 2
src/cairo-scaled-font.c | 2
src/cairo-script-surface.c | 1
src/cairo-skia-surface.cpp | 1
src/cairo-surface-fallback.c | 6 --
src/cairo-svg-surface.c | 1
src/cairo-type1-fallback.c | 1
src/cairo-types-private.h | 7 --
src/cairo-vg-surface.c | 1
src/cairo-win32-printing-surface.c | 1
src/cairo-xcb-surface-render.c | 6 --
src/cairo-xml-surface.c | 1
src/cairoint.h | 22 +------
src/drm/cairo-drm-i915-surface.c | 6 --
src/drm/cairo-drm-i965-surface.c | 6 --
31 files changed, 88 insertions(+), 299 deletions(-)
New commits:
commit 85a489f0f212d68c69dbe5807b379b874daef4d1
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Thu Dec 9 22:00:15 2010 +0100
polygon: Merge _cairo_polygon_init and _cairo_polygon_limit
_cairo_polygon_limit() had to be called immediately after
_cairo_polygon_init() (or never at all).
Merging the two calls is a simple way to enforce this rule.
diff --git a/src/cairo-bentley-ottmann.c b/src/cairo-bentley-ottmann.c
index b3819f2..d7b017a 100644
--- a/src/cairo-bentley-ottmann.c
+++ b/src/cairo-bentley-ottmann.c
@@ -1799,8 +1799,7 @@ _cairo_bentley_ottmann_tessellate_traps (cairo_traps_t *traps,
dump_traps (traps, "bo-traps-in.txt");
#endif
- _cairo_polygon_init (&polygon);
- _cairo_polygon_limit (&polygon, traps->limits, traps->num_limits);
+ _cairo_polygon_init (&polygon, traps->limits, traps->num_limits);
for (i = 0; i < traps->num_traps; i++) {
status = _cairo_polygon_add_line (&polygon,
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 5b5d66e..6bf679b 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -786,8 +786,7 @@ _rectilinear_clip_to_boxes (const cairo_path_fixed_t *path,
_cairo_traps_init (&traps);
_cairo_traps_limit (&traps, *boxes, *num_boxes);
- _cairo_polygon_init (&polygon);
- _cairo_polygon_limit (&polygon, *boxes, *num_boxes);
+ _cairo_polygon_init (&polygon, *boxes, *num_boxes);
status = _cairo_path_fixed_fill_rectilinear_to_traps (path,
fill_rule,
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index 278e642..9b4b2ac 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -1504,8 +1504,7 @@ _cairo_gl_surface_stroke (void *abstract_surface,
return status;
}
- _cairo_polygon_init (&polygon);
- _cairo_polygon_limit (&polygon, clip_boxes, num_boxes);
+ _cairo_polygon_init (&polygon, clip_boxes, num_boxes);
status = _cairo_path_fixed_stroke_to_polygon (path,
style,
@@ -1581,8 +1580,7 @@ _cairo_gl_surface_fill (void *abstract_surface,
return status;
}
- _cairo_polygon_init (&polygon);
- _cairo_polygon_limit (&polygon, clip_boxes, num_boxes);
+ _cairo_polygon_init (&polygon, clip_boxes, num_boxes);
status = _cairo_path_fixed_fill_to_polygon (path, tolerance, &polygon);
if (likely (status == CAIRO_STATUS_SUCCESS)) {
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 1ebadee..64d4e2d 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -3681,8 +3681,7 @@ _cairo_image_surface_stroke (void *abstract_surface,
if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
cairo_polygon_t polygon;
- _cairo_polygon_init (&polygon);
- _cairo_polygon_limit (&polygon, clip_boxes, num_boxes);
+ _cairo_polygon_init (&polygon, clip_boxes, num_boxes);
status = _cairo_path_fixed_stroke_to_polygon (path,
style,
@@ -3780,8 +3779,7 @@ _cairo_image_surface_fill (void *abstract_surface,
assert (! _cairo_path_fixed_fill_is_empty (path));
- _cairo_polygon_init (&polygon);
- _cairo_polygon_limit (&polygon, clip_boxes, num_boxes);
+ _cairo_polygon_init (&polygon, clip_boxes, num_boxes);
status = _cairo_path_fixed_fill_to_polygon (path, tolerance, &polygon);
if (likely (status == CAIRO_STATUS_SUCCESS)) {
diff --git a/src/cairo-path-fill.c b/src/cairo-path-fill.c
index 3a8e58a..6074a52 100644
--- a/src/cairo-path-fill.c
+++ b/src/cairo-path-fill.c
@@ -132,9 +132,7 @@ _cairo_path_fixed_fill_to_traps (const cairo_path_fixed_t *path,
if (_cairo_path_fixed_fill_is_empty (path))
return CAIRO_STATUS_SUCCESS;
- _cairo_polygon_init (&polygon);
- if (traps->num_limits)
- _cairo_polygon_limit (&polygon, traps->limits, traps->num_limits);
+ _cairo_polygon_init (&polygon, traps->limits, traps->num_limits);
status = _cairo_path_fixed_fill_to_polygon (path,
tolerance,
@@ -182,10 +180,11 @@ _cairo_path_fixed_fill_rectilinear_tessellate_to_region (const cairo_path_fixed_
}
/* path is not rectangular, try extracting clipped rectilinear edges */
- _cairo_polygon_init (&polygon);
if (extents != NULL) {
_cairo_box_from_rectangle (&box, extents);
- _cairo_polygon_limit (&polygon, &box, 1);
+ _cairo_polygon_init (&polygon, &box, 1);
+ } else {
+ _cairo_polygon_init (&polygon, NULL, 0);
}
/* tolerance will be ignored as the path is rectilinear */
@@ -390,11 +389,8 @@ _cairo_path_fixed_fill_rectilinear_tessellate_to_boxes (const cairo_path_fixed_t
cairo_polygon_t polygon;
cairo_status_t status;
- _cairo_polygon_init (&polygon);
- if (boxes->num_limits) {
- _cairo_polygon_limit (&polygon, boxes->limits, boxes->num_limits);
- boxes->num_limits = 0;
- }
+ _cairo_polygon_init (&polygon, boxes->limits, boxes->num_limits);
+ boxes->num_limits = 0;
/* tolerance will be ignored as the path is rectilinear */
status = _cairo_path_fixed_fill_to_polygon (path, 0., &polygon);
diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index 2b5e23a..d5ced0e 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -1407,9 +1407,7 @@ _cairo_path_fixed_stroke_to_traps (const cairo_path_fixed_t *path,
return status;
}
- _cairo_polygon_init (&polygon);
- if (traps->num_limits)
- _cairo_polygon_limit (&polygon, traps->limits, traps->num_limits);
+ _cairo_polygon_init (&polygon, traps->limits, traps->num_limits);
status = _cairo_path_fixed_stroke_to_polygon (path,
stroke_style,
diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c
index e5c4f96..c3f3631 100644
--- a/src/cairo-polygon.c
+++ b/src/cairo-polygon.c
@@ -1,3 +1,4 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
/* cairo - a vector graphics library with display and print output
*
* Copyright © 2002 University of Southern California
@@ -39,8 +40,12 @@
#include "cairo-error-private.h"
void
-_cairo_polygon_init (cairo_polygon_t *polygon)
+_cairo_polygon_init (cairo_polygon_t *polygon,
+ const cairo_box_t *limits,
+ int num_limits)
{
+ int n;
+
VG (VALGRIND_MAKE_MEM_UNDEFINED (polygon, sizeof (cairo_polygon_t)));
polygon->status = CAIRO_STATUS_SUCCESS;
@@ -50,18 +55,8 @@ _cairo_polygon_init (cairo_polygon_t *polygon)
polygon->edges = polygon->edges_embedded;
polygon->edges_size = ARRAY_LENGTH (polygon->edges_embedded);
- polygon->num_limits = 0;
-
polygon->extents.p1.x = polygon->extents.p1.y = INT32_MAX;
polygon->extents.p2.x = polygon->extents.p2.y = INT32_MIN;
-}
-
-void
-_cairo_polygon_limit (cairo_polygon_t *polygon,
- const cairo_box_t *limits,
- int num_limits)
-{
- int n;
polygon->limits = limits;
polygon->num_limits = num_limits;
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 61944c0..ca7a051 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -1067,8 +1067,7 @@ _cairo_surface_fallback_stroke (cairo_surface_t *surface,
if (unlikely (status))
return status;
- _cairo_polygon_init (&polygon);
- _cairo_polygon_limit (&polygon, clip_boxes, num_boxes);
+ _cairo_polygon_init (&polygon, clip_boxes, num_boxes);
_cairo_traps_init (&traps);
_cairo_traps_limit (&traps, clip_boxes, num_boxes);
@@ -1163,8 +1162,7 @@ _cairo_surface_fallback_fill (cairo_surface_t *surface,
_cairo_traps_init (&traps);
_cairo_traps_limit (&traps, clip_boxes, num_boxes);
- _cairo_polygon_init (&polygon);
- _cairo_polygon_limit (&polygon, clip_boxes, num_boxes);
+ _cairo_polygon_init (&polygon, clip_boxes, num_boxes);
if (_cairo_path_fixed_fill_is_empty (path))
goto DO_TRAPS;
diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index 1ec63ca..f712818 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -3382,8 +3382,7 @@ _cairo_xcb_surface_render_stroke_as_polygon (cairo_xcb_surface_t *dst,
cairo_polygon_t polygon;
cairo_status_t status;
- _cairo_polygon_init (&polygon);
- _cairo_polygon_limit (&polygon, clip_boxes, num_boxes);
+ _cairo_polygon_init (&polygon, clip_boxes, num_boxes);
status = _cairo_path_fixed_stroke_to_polygon (path,
stroke_style,
@@ -3582,8 +3581,7 @@ _cairo_xcb_surface_render_fill_as_polygon (cairo_xcb_surface_t *dst,
cairo_polygon_t polygon;
cairo_status_t status;
- _cairo_polygon_init (&polygon);
- _cairo_polygon_limit (&polygon, clip_boxes, num_boxes);
+ _cairo_polygon_init (&polygon, clip_boxes, num_boxes);
status = _cairo_path_fixed_fill_to_polygon (path, tolerance, &polygon);
if (likely (status == CAIRO_STATUS_SUCCESS)) {
diff --git a/src/cairoint.h b/src/cairoint.h
index 9125428..0ee4477 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1982,12 +1982,9 @@ _cairo_pen_find_active_ccw_vertex_index (const cairo_pen_t *pen,
/* cairo-polygon.c */
cairo_private void
-_cairo_polygon_init (cairo_polygon_t *polygon);
-
-cairo_private void
-_cairo_polygon_limit (cairo_polygon_t *polygon,
- const cairo_box_t *boxes,
- int num_boxes);
+_cairo_polygon_init (cairo_polygon_t *polygon,
+ const cairo_box_t *boxes,
+ int num_boxes);
cairo_private void
_cairo_polygon_fini (cairo_polygon_t *polygon);
diff --git a/src/drm/cairo-drm-i915-surface.c b/src/drm/cairo-drm-i915-surface.c
index 373e674..247d8ad 100644
--- a/src/drm/cairo-drm-i915-surface.c
+++ b/src/drm/cairo-drm-i915-surface.c
@@ -1938,8 +1938,7 @@ i915_surface_fill_with_alpha (void *abstract_dst,
goto CLEANUP_BOXES;
}
- _cairo_polygon_init (&info.polygon);
- _cairo_polygon_limit (&info.polygon, clip_boxes, num_boxes);
+ _cairo_polygon_init (&info.polygon, clip_boxes, num_boxes);
status = _cairo_path_fixed_fill_to_polygon (path, tolerance, &info.polygon);
if (unlikely (status))
@@ -2280,8 +2279,7 @@ i915_surface_stroke (void *abstract_dst,
goto CLEANUP_BOXES;
}
- _cairo_polygon_init (&info.polygon);
- _cairo_polygon_limit (&info.polygon, clip_boxes, num_boxes);
+ _cairo_polygon_init (&info.polygon, clip_boxes, num_boxes);
status = _cairo_path_fixed_stroke_to_polygon (path,
stroke_style,
diff --git a/src/drm/cairo-drm-i965-surface.c b/src/drm/cairo-drm-i965-surface.c
index c3618a3..3947836 100644
--- a/src/drm/cairo-drm-i965-surface.c
+++ b/src/drm/cairo-drm-i965-surface.c
@@ -1343,8 +1343,7 @@ i965_surface_stroke (void *abstract_dst,
goto CLEANUP_BOXES;
}
- _cairo_polygon_init (&info.polygon);
- _cairo_polygon_limit (&info.polygon, clip_boxes, num_boxes);
+ _cairo_polygon_init (&info.polygon, clip_boxes, num_boxes);
status = _cairo_path_fixed_stroke_to_polygon (path,
stroke_style,
@@ -1451,8 +1450,7 @@ i965_surface_fill (void *abstract_dst,
goto CLEANUP_BOXES;
}
- _cairo_polygon_init (&info.polygon);
- _cairo_polygon_limit (&info.polygon, clip_boxes, num_boxes);
+ _cairo_polygon_init (&info.polygon, clip_boxes, num_boxes);
status = _cairo_path_fixed_fill_to_polygon (path, tolerance, &info.polygon);
if (unlikely (status))
commit 75f34b595aead729b6f6a7017c8790d68dfa0326
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Thu Dec 9 22:00:10 2010 +0100
fill: Simplify path to polygon conversion
Using _cairo_path_fixed_interpret_flat() greatly simplifies the path
to polygon conversion (because it already converts curve_to's to
line_to's).
This commit also removes the optimization which merges two consecutive
lines if they have the same slope, because it's unlikely (since it
should already happen during path construction), it doesn't provide
better performance (at least not measurable with the currently
available cairo-traces) and bloats the code.
diff --git a/src/cairo-path-fill.c b/src/cairo-path-fill.c
index 845cdfc..3a8e58a 100644
--- a/src/cairo-path-fill.c
+++ b/src/cairo-path-fill.c
@@ -1,3 +1,4 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
/* cairo - a vector graphics library with display and print output
*
* Copyright © 2002 University of Southern California
@@ -41,67 +42,55 @@
#include "cairo-region-private.h"
typedef struct cairo_filler {
- double tolerance;
cairo_polygon_t *polygon;
+
+ cairo_point_t current_point;
+ cairo_point_t last_move_to;
} cairo_filler_t;
-static void
-_cairo_filler_init (cairo_filler_t *filler,
- double tolerance,
- cairo_polygon_t *polygon)
-{
- filler->tolerance = tolerance;
- filler->polygon = polygon;
-}
-
-static void
-_cairo_filler_fini (cairo_filler_t *filler)
-{
-}
static cairo_status_t
-_cairo_filler_move_to (void *closure,
+_cairo_filler_line_to (void *closure,
const cairo_point_t *point)
{
cairo_filler_t *filler = closure;
- cairo_polygon_t *polygon = filler->polygon;
+ cairo_status_t status;
+
+ status = _cairo_polygon_add_external_edge (filler->polygon,
+ &filler->current_point,
+ point);
+
+ filler->current_point = *point;
- return _cairo_polygon_close (polygon) ||
- _cairo_polygon_move_to (polygon, point);
+ return status;
}
static cairo_status_t
-_cairo_filler_line_to (void *closure,
- const cairo_point_t *point)
+_cairo_filler_close (void *closure)
{
cairo_filler_t *filler = closure;
- return _cairo_polygon_line_to (filler->polygon, point);
+
+ /* close the subpath */
+ return _cairo_filler_line_to (closure, &filler->last_move_to);
}
static cairo_status_t
-_cairo_filler_curve_to (void *closure,
- const cairo_point_t *b,
- const cairo_point_t *c,
- const cairo_point_t *d)
+_cairo_filler_move_to (void *closure,
+ const cairo_point_t *point)
{
cairo_filler_t *filler = closure;
- cairo_spline_t spline;
+ cairo_status_t status;
- if (! _cairo_spline_init (&spline,
- _cairo_filler_line_to, filler,
- &filler->polygon->current_point, b, c, d))
- {
- return _cairo_filler_line_to (closure, d);
- }
+ /* close current subpath */
+ status = _cairo_filler_close (closure);
+ if (unlikely (status))
+ return status;
- return _cairo_spline_decompose (&spline, filler->tolerance);
-}
+ /* make sure that the closure represents a degenerate path */
+ filler->current_point = *point;
+ filler->last_move_to = *point;
-static cairo_status_t
-_cairo_filler_close_path (void *closure)
-{
- cairo_filler_t *filler = closure;
- return _cairo_polygon_close (filler->polygon);
+ return CAIRO_STATUS_SUCCESS;
}
cairo_status_t
@@ -112,21 +101,23 @@ _cairo_path_fixed_fill_to_polygon (const cairo_path_fixed_t *path,
cairo_filler_t filler;
cairo_status_t status;
- _cairo_filler_init (&filler, tolerance, polygon);
+ filler.polygon = polygon;
- status = _cairo_path_fixed_interpret (path,
- _cairo_filler_move_to,
- _cairo_filler_line_to,
- _cairo_filler_curve_to,
- _cairo_filler_close_path,
- &filler);
+ /* make sure that the closure represents a degenerate path */
+ filler.current_point.x = 0;
+ filler.current_point.y = 0;
+ filler.last_move_to = filler.current_point;
+
+ status = _cairo_path_fixed_interpret_flat (path,
+ _cairo_filler_move_to,
+ _cairo_filler_line_to,
+ _cairo_filler_close,
+ &filler,
+ tolerance);
if (unlikely (status))
return status;
- status = _cairo_polygon_close (polygon);
- _cairo_filler_fini (&filler);
-
- return status;
+ return _cairo_filler_close (&filler);
}
cairo_status_t
diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c
index 64fef47..e5c4f96 100644
--- a/src/cairo-polygon.c
+++ b/src/cairo-polygon.c
@@ -37,7 +37,6 @@
#include "cairoint.h"
#include "cairo-error-private.h"
-#include "cairo-slope-private.h"
void
_cairo_polygon_init (cairo_polygon_t *polygon)
@@ -51,8 +50,6 @@ _cairo_polygon_init (cairo_polygon_t *polygon)
polygon->edges = polygon->edges_embedded;
polygon->edges_size = ARRAY_LENGTH (polygon->edges_embedded);
- polygon->has_current_point = FALSE;
- polygon->has_current_edge = FALSE;
polygon->num_limits = 0;
polygon->extents.p1.x = polygon->extents.p1.y = INT32_MAX;
@@ -408,88 +405,3 @@ _cairo_polygon_add_line (cairo_polygon_t *polygon,
return polygon->status;
}
-
-/* flattened path operations */
-
-cairo_status_t
-_cairo_polygon_move_to (cairo_polygon_t *polygon,
- const cairo_point_t *point)
-{
- if (polygon->has_current_edge) {
- _cairo_polygon_add_edge (polygon,
- &polygon->last_point,
- &polygon->current_point);
- polygon->has_current_edge = FALSE;
- }
-
- if (! polygon->has_current_point) {
- polygon->first_point = *point;
- polygon->has_current_point = TRUE;
- }
-
- polygon->current_point = *point;
- return polygon->status;
-}
-
-cairo_status_t
-_cairo_polygon_line_to (cairo_polygon_t *polygon,
- const cairo_point_t *point)
-{
- /* squash collinear edges */
- if (polygon->has_current_edge) {
- if (polygon->current_point.x != point->x ||
- polygon->current_point.y != point->y)
- {
- cairo_slope_t this;
-
- _cairo_slope_init (&this, &polygon->current_point, point);
- if (_cairo_slope_equal (&polygon->current_edge, &this)) {
- polygon->current_point = *point;
- return CAIRO_STATUS_SUCCESS;
- }
-
- _cairo_polygon_add_edge (polygon,
- &polygon->last_point,
- &polygon->current_point);
-
- polygon->last_point = polygon->current_point;
- polygon->current_edge = this;
- }
- } else if (polygon->has_current_point) {
- if (polygon->current_point.x != point->x ||
- polygon->current_point.y != point->y)
- {
- polygon->last_point = polygon->current_point;
- _cairo_slope_init (&polygon->current_edge,
- &polygon->last_point,
- point);
- polygon->has_current_edge = TRUE;
- }
- } else {
- polygon->first_point = *point;
- polygon->has_current_point = TRUE;
- }
-
- polygon->current_point = *point;
- return polygon->status;
-}
-
-cairo_status_t
-_cairo_polygon_close (cairo_polygon_t *polygon)
-{
- cairo_status_t status;
-
- if (polygon->has_current_point) {
- status = _cairo_polygon_line_to (polygon, &polygon->first_point);
- polygon->has_current_point = FALSE;
- }
-
- if (polygon->has_current_edge) {
- _cairo_polygon_add_edge (polygon,
- &polygon->last_point,
- &polygon->current_point);
- polygon->has_current_edge = FALSE;
- }
-
- return polygon->status;
-}
diff --git a/src/cairo-types-private.h b/src/cairo-types-private.h
index b5e76c7..85f5d51 100644
--- a/src/cairo-types-private.h
+++ b/src/cairo-types-private.h
@@ -288,13 +288,6 @@ typedef struct _cairo_edge {
typedef struct _cairo_polygon {
cairo_status_t status;
- cairo_point_t first_point;
- cairo_point_t last_point;
- cairo_point_t current_point;
- cairo_slope_t current_edge;
- cairo_bool_t has_current_point;
- cairo_bool_t has_current_edge;
-
cairo_box_t extents;
cairo_box_t limit;
const cairo_box_t *limits;
diff --git a/src/cairoint.h b/src/cairoint.h
index 8a0fcaa..9125428 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2003,17 +2003,6 @@ _cairo_polygon_add_external_edge (void *polygon,
const cairo_point_t *p1,
const cairo_point_t *p2);
-cairo_private cairo_status_t
-_cairo_polygon_move_to (cairo_polygon_t *polygon,
- const cairo_point_t *point);
-
-cairo_private cairo_status_t
-_cairo_polygon_line_to (cairo_polygon_t *polygon,
- const cairo_point_t *point);
-
-cairo_private cairo_status_t
-_cairo_polygon_close (cairo_polygon_t *polygon);
-
#define _cairo_polygon_status(P) ((cairo_polygon_t *) (P))->status
/* cairo-spline.c */
commit df453b7aca5ad7c4b796f150c8a90e78c1b96e04
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Thu Dec 9 22:00:06 2010 +0100
path: Remove support for inverse direction interpretation
The previous commit guarantees that paths are always interpreted in
the forward direction, so the code allowing both directions is not
needed anymore.
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index 2f2d901..66918a5 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -810,47 +810,26 @@ _cairo_path_fixed_interpret (const cairo_path_fixed_t *path,
cairo_path_fixed_close_path_func_t *close_path,
void *closure)
{
- const uint8_t num_args[] = {
- 1, /* cairo_path_move_to */
- 1, /* cairo_path_op_line_to */
- 3, /* cairo_path_op_curve_to */
- 0, /* cairo_path_op_close_path */
- };
+ const cairo_path_buf_t *buf;
cairo_status_t status;
- const cairo_path_buf_t *buf, *first;
- cairo_bool_t forward = TRUE;
- int step = forward ? 1 : -1;
-
- buf = first = forward ? cairo_path_head (path) : cairo_path_tail (path);
- do {
- cairo_point_t *points;
- int start, stop, i;
-
- if (forward) {
- start = 0;
- stop = buf->num_ops;
- points = buf->points;
- } else {
- start = buf->num_ops - 1;
- stop = -1;
- points = buf->points + buf->num_points;
- }
-
- for (i = start; i != stop; i += step) {
- cairo_path_op_t op = buf->op[i];
- if (! forward)
- points -= num_args[(int) op];
+ cairo_path_foreach_buf_start (buf, path) {
+ const cairo_point_t *points = buf->points;
+ unsigned int i;
- switch (op) {
+ for (i = 0; i < buf->num_ops; i++) {
+ switch (buf->op[i]) {
case CAIRO_PATH_OP_MOVE_TO:
status = (*move_to) (closure, &points[0]);
+ points += 1;
break;
case CAIRO_PATH_OP_LINE_TO:
status = (*line_to) (closure, &points[0]);
+ points += 1;
break;
case CAIRO_PATH_OP_CURVE_TO:
status = (*curve_to) (closure, &points[0], &points[1], &points[2]);
+ points += 3;
break;
default:
ASSERT_NOT_REACHED;
@@ -858,13 +837,11 @@ _cairo_path_fixed_interpret (const cairo_path_fixed_t *path,
status = (*close_path) (closure);
break;
}
+
if (unlikely (status))
return status;
-
- if (forward)
- points += num_args[(int) op];
}
- } while ((buf = forward ? cairo_path_buf_next (buf) : cairo_path_buf_prev (buf)) != first);
+ } cairo_path_foreach_buf_end (buf, path);
return CAIRO_STATUS_SUCCESS;
}
commit a8ae8759f51a283fc1d65b055eda8e401d9ccf2e
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Thu Dec 9 22:00:01 2010 +0100
path: Always interpret in forward direction
Path are always interpreted in forward direction, so the ability of
interpreting in the opposite direction (which is very unlikely to be
useful at all) can be removed.
diff --git a/src/cairo-debug.c b/src/cairo-debug.c
index e9e72b6..b8bdfd1 100644
--- a/src/cairo-debug.c
+++ b/src/cairo-debug.c
@@ -240,7 +240,6 @@ _cairo_debug_print_path (FILE *stream, cairo_path_fixed_t *path)
_cairo_fixed_to_double (path->extents.p2.y));
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_print_move_to,
_print_line_to,
_print_curve_to,
diff --git a/src/cairo-path-bounds.c b/src/cairo-path-bounds.c
index d17d9a2..204b982 100644
--- a/src/cairo-path-bounds.c
+++ b/src/cairo-path-bounds.c
@@ -106,7 +106,7 @@ _cairo_path_bounder_extents (const cairo_path_fixed_t *path,
cairo_status_t status;
bounder.has_extents = FALSE;
- status = _cairo_path_fixed_interpret (path, CAIRO_DIRECTION_FORWARD,
+ status = _cairo_path_fixed_interpret (path,
_cairo_path_bounder_move_to,
_cairo_path_bounder_line_to,
_cairo_path_bounder_curve_to,
diff --git a/src/cairo-path-fill.c b/src/cairo-path-fill.c
index 358c8b9..845cdfc 100644
--- a/src/cairo-path-fill.c
+++ b/src/cairo-path-fill.c
@@ -115,7 +115,6 @@ _cairo_path_fixed_fill_to_polygon (const cairo_path_fixed_t *path,
_cairo_filler_init (&filler, tolerance, polygon);
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_cairo_filler_move_to,
_cairo_filler_line_to,
_cairo_filler_curve_to,
diff --git a/src/cairo-path-fixed-private.h b/src/cairo-path-fixed-private.h
index 9fcd502..e24b1c7 100644
--- a/src/cairo-path-fixed-private.h
+++ b/src/cairo-path-fixed-private.h
@@ -109,7 +109,6 @@ _cairo_path_fixed_translate (cairo_path_fixed_t *path,
cairo_private cairo_status_t
_cairo_path_fixed_append (cairo_path_fixed_t *path,
const cairo_path_fixed_t *other,
- cairo_direction_t dir,
cairo_fixed_t tx,
cairo_fixed_t ty);
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index 3093f26..2f2d901 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -804,7 +804,6 @@ _cairo_path_buf_add_points (cairo_path_buf_t *buf,
cairo_status_t
_cairo_path_fixed_interpret (const cairo_path_fixed_t *path,
- cairo_direction_t dir,
cairo_path_fixed_move_to_func_t *move_to,
cairo_path_fixed_line_to_func_t *line_to,
cairo_path_fixed_curve_to_func_t *curve_to,
@@ -819,7 +818,7 @@ _cairo_path_fixed_interpret (const cairo_path_fixed_t *path,
};
cairo_status_t status;
const cairo_path_buf_t *buf, *first;
- cairo_bool_t forward = (dir == CAIRO_DIRECTION_FORWARD);
+ cairo_bool_t forward = TRUE;
int step = forward ? 1 : -1;
buf = first = forward ? cairo_path_head (path) : cairo_path_tail (path);
@@ -925,7 +924,6 @@ _append_close_path (void *abstract_closure)
cairo_status_t
_cairo_path_fixed_append (cairo_path_fixed_t *path,
const cairo_path_fixed_t *other,
- cairo_direction_t dir,
cairo_fixed_t tx,
cairo_fixed_t ty)
{
@@ -935,7 +933,7 @@ _cairo_path_fixed_append (cairo_path_fixed_t *path,
closure.offset.x = tx;
closure.offset.y = ty;
- return _cairo_path_fixed_interpret (other, dir,
+ return _cairo_path_fixed_interpret (other,
_append_move_to,
_append_line_to,
_append_curve_to,
@@ -1175,7 +1173,6 @@ _cpf_close_path (void *closure)
cairo_status_t
_cairo_path_fixed_interpret_flat (const cairo_path_fixed_t *path,
- cairo_direction_t dir,
cairo_path_fixed_move_to_func_t *move_to,
cairo_path_fixed_line_to_func_t *line_to,
cairo_path_fixed_close_path_func_t *close_path,
@@ -1185,7 +1182,7 @@ _cairo_path_fixed_interpret_flat (const cairo_path_fixed_t *path,
cpf_t flattener;
if (! path->has_curve_to) {
- return _cairo_path_fixed_interpret (path, dir,
+ return _cairo_path_fixed_interpret (path,
move_to,
line_to,
NULL,
@@ -1198,7 +1195,7 @@ _cairo_path_fixed_interpret_flat (const cairo_path_fixed_t *path,
flattener.line_to = line_to;
flattener.close_path = close_path;
flattener.closure = closure;
- return _cairo_path_fixed_interpret (path, dir,
+ return _cairo_path_fixed_interpret (path,
_cpf_move_to,
_cpf_line_to,
_cpf_curve_to,
diff --git a/src/cairo-path-in-fill.c b/src/cairo-path-in-fill.c
index a19784c..3738874 100644
--- a/src/cairo-path-in-fill.c
+++ b/src/cairo-path-in-fill.c
@@ -260,7 +260,6 @@ _cairo_path_fixed_in_fill (const cairo_path_fixed_t *path,
_cairo_in_fill_init (&in_fill, tolerance, x, y);
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_cairo_in_fill_move_to,
_cairo_in_fill_line_to,
_cairo_in_fill_curve_to,
diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index cdf22ce..2b5e23a 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -1319,7 +1319,6 @@ _cairo_path_fixed_stroke_to_shaper (cairo_path_fixed_t *path,
stroker.closure = closure;
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_cairo_stroker_move_to,
stroker.dash.dashed ?
_cairo_stroker_line_to_dashed :
@@ -1363,7 +1362,6 @@ _cairo_path_fixed_stroke_to_polygon (const cairo_path_fixed_t *path,
_cairo_stroker_limit (&stroker, polygon->limits, polygon->num_limits);
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_cairo_stroker_move_to,
stroker.dash.dashed ?
_cairo_stroker_line_to_dashed :
@@ -2054,7 +2052,6 @@ _cairo_path_fixed_stroke_rectilinear_to_traps (const cairo_path_fixed_t *path,
}
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_cairo_rectilinear_stroker_move_to,
rectilinear_stroker.dash.dashed ?
_cairo_rectilinear_stroker_line_to_dashed :
@@ -2108,7 +2105,6 @@ _cairo_path_fixed_stroke_rectilinear_to_boxes (const cairo_path_fixed_t *path,
}
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_cairo_rectilinear_stroker_move_to,
rectilinear_stroker.dash.dashed ?
_cairo_rectilinear_stroker_line_to_dashed :
diff --git a/src/cairo-path.c b/src/cairo-path.c
index 88a730b..d9f08ac 100644
--- a/src/cairo-path.c
+++ b/src/cairo-path.c
@@ -115,7 +115,6 @@ _cairo_path_count (cairo_path_t *path,
if (flatten) {
status = _cairo_path_fixed_interpret_flat (path_fixed,
- CAIRO_DIRECTION_FORWARD,
_cpc_move_to,
_cpc_line_to,
_cpc_close_path,
@@ -123,7 +122,6 @@ _cairo_path_count (cairo_path_t *path,
tolerance);
} else {
status = _cairo_path_fixed_interpret (path_fixed,
- CAIRO_DIRECTION_FORWARD,
_cpc_move_to,
_cpc_line_to,
_cpc_curve_to,
@@ -264,7 +262,6 @@ _cairo_path_populate (cairo_path_t *path,
if (flatten) {
double tolerance = _cairo_gstate_get_tolerance (gstate);
status = _cairo_path_fixed_interpret_flat (path_fixed,
- CAIRO_DIRECTION_FORWARD,
_cpp_move_to,
_cpp_line_to,
_cpp_close_path,
@@ -272,7 +269,6 @@ _cairo_path_populate (cairo_path_t *path,
tolerance);
} else {
status = _cairo_path_fixed_interpret (path_fixed,
- CAIRO_DIRECTION_FORWARD,
_cpp_move_to,
_cpp_line_to,
_cpp_curve_to,
diff --git a/src/cairo-pdf-operators.c b/src/cairo-pdf-operators.c
index 54a30b2..0f2500e 100644
--- a/src/cairo-pdf-operators.c
+++ b/src/cairo-pdf-operators.c
@@ -514,7 +514,6 @@ _cairo_pdf_operators_emit_path (cairo_pdf_operators_t *pdf_operators,
status = _cairo_pdf_path_rectangle (&info, &box);
} else {
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_cairo_pdf_path_move_to,
_cairo_pdf_path_line_to,
_cairo_pdf_path_curve_to,
diff --git a/src/cairo-qt-surface.cpp b/src/cairo-qt-surface.cpp
index 5b61b42..7e528a3 100644
--- a/src/cairo-qt-surface.cpp
+++ b/src/cairo-qt-surface.cpp
@@ -391,7 +391,6 @@ path_to_qt (cairo_path_fixed_t *path,
data.ctm_inverse = ctm_inverse;
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_cairo_path_to_qpainterpath_move_to,
_cairo_path_to_qpainterpath_line_to,
_cairo_path_to_qpainterpath_curve_to,
diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index c86d913..a340865 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -359,7 +359,6 @@ _cairo_quartz_cairo_path_to_quartz_context (cairo_path_fixed_t *path,
CGContextBeginPath (closure);
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_cairo_path_to_quartz_context_move_to,
_cairo_path_to_quartz_context_line_to,
_cairo_path_to_quartz_context_curve_to,
diff --git a/src/cairo-recording-surface.c b/src/cairo-recording-surface.c
index 3e4dd0c..f5f1014 100644
--- a/src/cairo-recording-surface.c
+++ b/src/cairo-recording-surface.c
@@ -801,7 +801,7 @@ _cairo_recording_surface_get_path (cairo_surface_t *surface,
case CAIRO_COMMAND_FILL:
{
status = _cairo_path_fixed_append (path,
- &command->fill.path, CAIRO_DIRECTION_FORWARD,
+ &command->fill.path,
0, 0);
break;
}
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 12d8cea..70ecda2 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -2494,7 +2494,7 @@ _cairo_scaled_font_glyph_path (cairo_scaled_font_t *scaled_font,
&scaled_glyph);
if (status == CAIRO_STATUS_SUCCESS) {
status = _cairo_path_fixed_append (path,
- scaled_glyph->path, CAIRO_DIRECTION_FORWARD,
+ scaled_glyph->path,
_cairo_fixed_from_double (glyphs[i].x),
_cairo_fixed_from_double (glyphs[i].y));
diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c
index 6da7ae5..b3aa69d 100644
--- a/src/cairo-script-surface.c
+++ b/src/cairo-script-surface.c
@@ -1666,7 +1666,6 @@ _emit_path (cairo_script_surface_t *surface,
return status;
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_path_move_to,
_path_line_to,
_path_curve_to,
diff --git a/src/cairo-skia-surface.cpp b/src/cairo-skia-surface.cpp
index 8ce5a76..e29f022 100644
--- a/src/cairo-skia-surface.cpp
+++ b/src/cairo-skia-surface.cpp
@@ -500,7 +500,6 @@ path_to_sk (cairo_path_fixed_t *path,
data.matrix = mat;
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
cpc_move_to,
cpc_line_to,
cpc_curve_to,
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index 9628166..ab0f0c7 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -725,7 +725,6 @@ _cairo_svg_surface_emit_path (cairo_output_stream_t *output,
info.output = output;
info.ctm_inverse = ctm_inverse;
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_cairo_svg_path_move_to,
_cairo_svg_path_line_to,
_cairo_svg_path_curve_to,
diff --git a/src/cairo-type1-fallback.c b/src/cairo-type1-fallback.c
index 62ffe92..39bc53f 100644
--- a/src/cairo-type1-fallback.c
+++ b/src/cairo-type1-fallback.c
@@ -407,7 +407,6 @@ cairo_type1_font_create_charstring (cairo_type1_font_t *font,
path_info.type = type;
if (emit_path) {
status = _cairo_path_fixed_interpret (scaled_glyph->path,
- CAIRO_DIRECTION_FORWARD,
_charstring_move_to,
_charstring_line_to,
_charstring_curve_to,
diff --git a/src/cairo-vg-surface.c b/src/cairo-vg-surface.c
index a35c517..39059f6 100644
--- a/src/cairo-vg-surface.c
+++ b/src/cairo-vg-surface.c
@@ -588,7 +588,6 @@ _vg_path_from_cairo (vg_path_t *vg_path,
vg_path->dcount = 0;
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_vg_move_to,
_vg_line_to,
_vg_curve_to,
diff --git a/src/cairo-win32-printing-surface.c b/src/cairo-win32-printing-surface.c
index 806cab8..4d472b0 100644
--- a/src/cairo-win32-printing-surface.c
+++ b/src/cairo-win32-printing-surface.c
@@ -1087,7 +1087,6 @@ _cairo_win32_printing_surface_emit_path (cairo_win32_surface_t *surface,
path_info.surface = surface;
return _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_cairo_win32_printing_surface_path_move_to,
_cairo_win32_printing_surface_path_line_to,
_cairo_win32_printing_surface_path_curve_to,
diff --git a/src/cairo-xml-surface.c b/src/cairo-xml-surface.c
index 5f0f13b..0f25852 100644
--- a/src/cairo-xml-surface.c
+++ b/src/cairo-xml-surface.c
@@ -421,7 +421,6 @@ _cairo_xml_emit_path (cairo_xml_t *xml,
_cairo_xml_printf_start (xml, "<path>");
status = _cairo_path_fixed_interpret (path,
- CAIRO_DIRECTION_FORWARD,
_cairo_xml_move_to,
_cairo_xml_line_to,
_cairo_xml_curve_to,
diff --git a/src/cairoint.h b/src/cairoint.h
index c40dc9b..8a0fcaa 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1234,7 +1234,6 @@ typedef cairo_status_t
cairo_private cairo_status_t
_cairo_path_fixed_interpret (const cairo_path_fixed_t *path,
- cairo_direction_t dir,
cairo_path_fixed_move_to_func_t *move_to,
cairo_path_fixed_line_to_func_t *line_to,
cairo_path_fixed_curve_to_func_t *curve_to,
@@ -1243,7 +1242,6 @@ _cairo_path_fixed_interpret (const cairo_path_fixed_t *path,
cairo_private cairo_status_t
_cairo_path_fixed_interpret_flat (const cairo_path_fixed_t *path,
- cairo_direction_t dir,
cairo_path_fixed_move_to_func_t *move_to,
cairo_path_fixed_line_to_func_t *line_to,
cairo_path_fixed_close_path_func_t *close_path,
commit 83605de9958696d47b15baa2c95731bc076ff368
Author: Andrea Canciani <ranma42 at gmail.com>
Date: Thu Dec 9 21:59:43 2010 +0100
path: Cleanup unused current_point
The code keeps track of the current point but doesn't use it.
Remove it to clean up.
diff --git a/src/cairo-path.c b/src/cairo-path.c
index 28182c0..88a730b 100644
--- a/src/cairo-path.c
+++ b/src/cairo-path.c
@@ -55,7 +55,6 @@ static const cairo_path_t _cairo_path_nil = { CAIRO_STATUS_NO_MEMORY, NULL, 0 };
/* Closure for path interpretation. */
typedef struct cairo_path_count {
int count;
- cairo_point_t current_point;
} cpc_t;
static cairo_status_t
@@ -66,8 +65,6 @@ _cpc_move_to (void *closure,
cpc->count += 2;
- cpc->current_point = *point;
-
return CAIRO_STATUS_SUCCESS;
}
@@ -79,8 +76,6 @@ _cpc_line_to (void *closure,
cpc->count += 2;
- cpc->current_point = *point;
-
return CAIRO_STATUS_SUCCESS;
}
@@ -94,8 +89,6 @@ _cpc_curve_to (void *closure,
cpc->count += 4;
- cpc->current_point = *p3;
-
return CAIRO_STATUS_SUCCESS;
}
@@ -119,8 +112,6 @@ _cairo_path_count (cairo_path_t *path,
cpc_t cpc;
cpc.count = 0;
- cpc.current_point.x = 0;
- cpc.current_point.y = 0;
if (flatten) {
status = _cairo_path_fixed_interpret_flat (path_fixed,
@@ -150,7 +141,6 @@ _cairo_path_count (cairo_path_t *path,
typedef struct cairo_path_populate {
cairo_path_data_t *data;
cairo_gstate_t *gstate;
- cairo_point_t current_point;
} cpp_t;
static cairo_status_t
@@ -175,8 +165,6 @@ _cpp_move_to (void *closure,
cpp->data += data->header.length;
- cpp->current_point = *point;
-
return CAIRO_STATUS_SUCCESS;
}
@@ -202,8 +190,6 @@ _cpp_line_to (void *closure,
cpp->data += data->header.length;
- cpp->current_point = *point;
-
return CAIRO_STATUS_SUCCESS;
}
@@ -246,8 +232,6 @@ _cpp_curve_to (void *closure,
cpp->data += data->header.length;
- cpp->current_point = *p3;
-
return CAIRO_STATUS_SUCCESS;
}
@@ -276,8 +260,6 @@ _cairo_path_populate (cairo_path_t *path,
cpp.data = path->data;
cpp.gstate = gstate;
- cpp.current_point.x = 0;
- cpp.current_point.y = 0;
if (flatten) {
double tolerance = _cairo_gstate_get_tolerance (gstate);
More information about the cairo-commit
mailing list