diff options
author | Andrea Canciani <ranma42@gmail.com> | 2010-10-16 23:57:06 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2010-10-29 17:31:21 +0200 |
commit | e9c1fc31887c5bfbb7d086f923a7628b7cfa739c (patch) | |
tree | eb09b160574905223235f4efb45e0e165689946a | |
parent | 14cc9846b302a990e65d7572e7f095a8873a213d (diff) |
path: Do not access flags directly
Use inline accessors to hide the flags in the code.
This ensures that flags that need additional computations (example:
is_rectilinear for the fill case) are always used correctly.
-rw-r--r-- | src/cairo-clip.c | 18 | ||||
-rw-r--r-- | src/cairo-gstate.c | 2 | ||||
-rw-r--r-- | src/cairo-image-surface.c | 6 | ||||
-rw-r--r-- | src/cairo-path-fill.c | 8 | ||||
-rw-r--r-- | src/cairo-path-fixed-private.h | 26 | ||||
-rw-r--r-- | src/cairo-path-in-fill.c | 2 | ||||
-rw-r--r-- | src/cairo-path-stroke.c | 6 | ||||
-rw-r--r-- | src/cairo-surface-fallback.c | 6 |
8 files changed, 43 insertions, 31 deletions
diff --git a/src/cairo-clip.c b/src/cairo-clip.c index d5a2fab7..5b5d66ee 100644 --- a/src/cairo-clip.c +++ b/src/cairo-clip.c @@ -229,7 +229,7 @@ _cairo_clip_intersect_path (cairo_clip_t *clip, if (clip->path != NULL) { if (clip->path->fill_rule == fill_rule && - (path->is_rectilinear || tolerance == clip->path->tolerance) && + (_cairo_path_fixed_fill_is_rectilinear (path) || tolerance == clip->path->tolerance) && antialias == clip->path->antialias && _cairo_path_fixed_equal (&clip->path->path, path)) { @@ -553,7 +553,7 @@ static inline cairo_bool_t _clip_paths_are_rectilinear (cairo_clip_path_t *clip_path) { while (clip_path != NULL) { - if (! clip_path->path.is_rectilinear) + if (! _cairo_path_fixed_fill_is_rectilinear (&clip_path->path)) return FALSE; clip_path = clip_path->prev; @@ -578,7 +578,7 @@ _cairo_clip_path_to_region_geometric (cairo_clip_path_t *clip_path) goto UNSUPPORTED; /* Start simple... Intersect some boxes with an arbitrary path. */ - if (! clip_path->path.is_rectilinear) + if (! _cairo_path_fixed_fill_is_rectilinear (&clip_path->path)) goto UNSUPPORTED; if (clip_path->prev->prev != NULL) goto UNSUPPORTED; @@ -651,7 +651,7 @@ _cairo_clip_path_to_region (cairo_clip_path_t *clip_path) CAIRO_STATUS_SUCCESS; } - if (! clip_path->path.maybe_fill_region) + if (! _cairo_path_fixed_fill_maybe_region (&clip_path->path)) return _cairo_clip_path_to_region_geometric (clip_path); /* first retrieve the region for our antecedents */ @@ -961,7 +961,7 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path, while (clip_path->prev != NULL && clip_path->flags & CAIRO_CLIP_PATH_IS_BOX && - clip_path->path.maybe_fill_region) + _cairo_path_fixed_fill_maybe_region (&clip_path->path)) { clip_path = clip_path->prev; } @@ -989,7 +989,7 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path, need_translate = clip_extents->x | clip_extents->y; if (clip_path->flags & CAIRO_CLIP_PATH_IS_BOX && - clip_path->path.maybe_fill_region) + _cairo_path_fixed_fill_maybe_region (&clip_path->path)) { status = _cairo_surface_paint (surface, CAIRO_OPERATOR_SOURCE, @@ -1033,11 +1033,11 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path, prev = clip_path->prev; while (prev != NULL) { if (prev->flags & CAIRO_CLIP_PATH_IS_BOX && - prev->path.maybe_fill_region) + _cairo_path_fixed_fill_maybe_region (&prev->path)) { /* a simple box only affects the extents */ } - else if (prev->path.is_rectilinear || + else if (_cairo_path_fixed_fill_is_rectilinear (&prev->path) || prev->surface == NULL || prev->surface->backend != target->backend) { @@ -1233,7 +1233,7 @@ _cairo_clip_combine_with_surface (cairo_clip_t *clip, } if (clip_path->flags & CAIRO_CLIP_PATH_IS_BOX && - clip_path->path.maybe_fill_region) + _cairo_path_fixed_fill_maybe_region (&clip_path->path)) { continue; } diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c index b1d09d2a..7c54dcb3 100644 --- a/src/cairo-gstate.c +++ b/src/cairo-gstate.c @@ -1454,7 +1454,7 @@ _cairo_gstate_fill_extents (cairo_gstate_t *gstate, cairo_status_t status; cairo_traps_t traps; - if (path->is_empty_fill) { + if (_cairo_path_fixed_fill_is_empty (path)) { if (x1) *x1 = 0.0; if (y1) diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index 2d769ea8..a84aaab0 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -3629,7 +3629,7 @@ _cairo_image_surface_stroke (void *abstract_surface, } status = CAIRO_INT_STATUS_UNSUPPORTED; - if (path->is_rectilinear) { + if (_cairo_path_fixed_stroke_is_rectilinear (path)) { cairo_boxes_t boxes; _cairo_boxes_init (&boxes); @@ -3729,7 +3729,7 @@ _cairo_image_surface_fill (void *abstract_surface, return status; } - if (_cairo_path_fixed_is_rectilinear_fill (path)) { + if (_cairo_path_fixed_fill_is_rectilinear (path)) { cairo_boxes_t boxes; _cairo_boxes_init (&boxes); @@ -3748,7 +3748,7 @@ _cairo_image_surface_fill (void *abstract_surface, } else { cairo_polygon_t polygon; - assert (! path->is_empty_fill); + assert (! _cairo_path_fixed_fill_is_empty (path)); _cairo_polygon_init (&polygon); _cairo_polygon_limit (&polygon, clip_boxes, num_boxes); diff --git a/src/cairo-path-fill.c b/src/cairo-path-fill.c index 24aaa396..358c8b9e 100644 --- a/src/cairo-path-fill.c +++ b/src/cairo-path-fill.c @@ -139,7 +139,7 @@ _cairo_path_fixed_fill_to_traps (const cairo_path_fixed_t *path, cairo_polygon_t polygon; cairo_status_t status; - if (path->is_empty_fill) + if (_cairo_path_fixed_fill_is_empty (path)) return CAIRO_STATUS_SUCCESS; _cairo_polygon_init (&polygon); @@ -152,7 +152,7 @@ _cairo_path_fixed_fill_to_traps (const cairo_path_fixed_t *path, if (unlikely (status || polygon.num_edges == 0)) goto CLEANUP; - if (path->is_rectilinear) { + if (_cairo_path_fixed_fill_is_rectilinear (path)) { status = _cairo_bentley_ottmann_tessellate_rectilinear_polygon (traps, &polygon, fill_rule); @@ -242,8 +242,8 @@ _cairo_path_fixed_fill_rectilinear_to_region (const cairo_path_fixed_t *path, cairo_box_t box; cairo_region_t *region = NULL; - assert (path->maybe_fill_region); - assert (! path->is_empty_fill); + assert (_cairo_path_fixed_fill_maybe_region (path)); + assert (! _cairo_path_fixed_fill_is_empty (path)); if (_cairo_path_fixed_is_box (path, &box)) { rectangle_stack[0].x = _cairo_fixed_integer_part (box.p1.x); diff --git a/src/cairo-path-fixed-private.h b/src/cairo-path-fixed-private.h index 42e64eda..5d665dbd 100644 --- a/src/cairo-path-fixed-private.h +++ b/src/cairo-path-fixed-private.h @@ -139,7 +139,7 @@ _cairo_path_fixed_fill_is_empty (const cairo_path_fixed_t *path) } static inline cairo_bool_t -_cairo_path_fixed_is_rectilinear_fill (const cairo_path_fixed_t *path) +_cairo_path_fixed_fill_is_rectilinear (const cairo_path_fixed_t *path) { if (! path->is_rectilinear) return 0; @@ -153,13 +153,25 @@ _cairo_path_fixed_is_rectilinear_fill (const cairo_path_fixed_t *path) } static inline cairo_bool_t -_cairo_path_fixed_maybe_fill_region (const cairo_path_fixed_t *path) +_cairo_path_fixed_stroke_is_rectilinear (const cairo_path_fixed_t *path) { -#if WATCH_PATH - fprintf (stderr, "_cairo_path_fixed_maybe_fill_region () = %s\n", - path->maybe_fill_region ? "true" : "false"); -#endif - return path->maybe_fill_region; + return path->is_rectilinear; +} + +static inline cairo_bool_t +_cairo_path_fixed_fill_maybe_region (const cairo_path_fixed_t *path) +{ + if (! path->maybe_fill_region) + return FALSE; + + if (! path->has_current_point) + return TRUE; + + /* check whether the implicit close preserves the rectilinear property + * (the integer point property is automatically preserved) + */ + return path->current_point.x == path->last_move_point.x || + path->current_point.y == path->last_move_point.y; } #endif /* CAIRO_PATH_FIXED_PRIVATE_H */ diff --git a/src/cairo-path-in-fill.c b/src/cairo-path-in-fill.c index b344f529..a19784c9 100644 --- a/src/cairo-path-in-fill.c +++ b/src/cairo-path-in-fill.c @@ -254,7 +254,7 @@ _cairo_path_fixed_in_fill (const cairo_path_fixed_t *path, cairo_status_t status; cairo_bool_t is_inside; - if (path->is_empty_fill) + if (_cairo_path_fixed_fill_is_empty (path)) return FALSE; _cairo_in_fill_init (&in_fill, tolerance, x, y); diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c index 505b6ab6..a31ac67c 100644 --- a/src/cairo-path-stroke.c +++ b/src/cairo-path-stroke.c @@ -1399,7 +1399,7 @@ _cairo_path_fixed_stroke_to_traps (const cairo_path_fixed_t *path, * device-pixel boundaries when possible. Many backends can render * those much faster than non-aligned trapezoids, (by using clip * regions, etc.) */ - if (path->is_rectilinear) { + if (_cairo_path_fixed_stroke_is_rectilinear (path)) { status = _cairo_path_fixed_stroke_rectilinear_to_traps (path, stroke_style, ctm, @@ -2037,7 +2037,7 @@ _cairo_path_fixed_stroke_rectilinear_to_traps (const cairo_path_fixed_t *path, cairo_rectilinear_stroker_t rectilinear_stroker; cairo_int_status_t status; - assert (path->is_rectilinear); + assert (_cairo_path_fixed_stroke_is_rectilinear (path)); if (! _cairo_rectilinear_stroker_init (&rectilinear_stroker, stroke_style, ctm, @@ -2091,7 +2091,7 @@ _cairo_path_fixed_stroke_rectilinear_to_boxes (const cairo_path_fixed_t *path, cairo_rectilinear_stroker_t rectilinear_stroker; cairo_int_status_t status; - assert (path->is_rectilinear); + assert (_cairo_path_fixed_stroke_is_rectilinear (path)); if (! _cairo_rectilinear_stroker_init (&rectilinear_stroker, stroke_style, ctm, diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c index 99ea07e7..61944c04 100644 --- a/src/cairo-surface-fallback.c +++ b/src/cairo-surface-fallback.c @@ -1073,7 +1073,7 @@ _cairo_surface_fallback_stroke (cairo_surface_t *surface, _cairo_traps_init (&traps); _cairo_traps_limit (&traps, clip_boxes, num_boxes); - if (path->is_rectilinear) { + if (_cairo_path_fixed_stroke_is_rectilinear (path)) { status = _cairo_path_fixed_stroke_rectilinear_to_traps (path, stroke_style, ctm, @@ -1166,10 +1166,10 @@ _cairo_surface_fallback_fill (cairo_surface_t *surface, _cairo_polygon_init (&polygon); _cairo_polygon_limit (&polygon, clip_boxes, num_boxes); - if (path->is_empty_fill) + if (_cairo_path_fixed_fill_is_empty (path)) goto DO_TRAPS; - is_rectilinear = _cairo_path_fixed_is_rectilinear_fill (path); + is_rectilinear = _cairo_path_fixed_fill_is_rectilinear (path); if (is_rectilinear) { status = _cairo_path_fixed_fill_rectilinear_to_traps (path, fill_rule, |