diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-03-23 16:43:39 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-03-23 16:43:39 +0000 |
commit | 1ddcd5cf31bb47e9ff18ddf94d0a4648fa70a617 (patch) | |
tree | 1f507a9cd24dc52138c01ba1a8730c7a02f734af /src/cairo-clip.c | |
parent | 61ad28fe7d334c63197ae3881d5edd074d63cfec (diff) | |
download | cairo-1ddcd5cf31bb47e9ff18ddf94d0a4648fa70a617.tar.gz |
clip: Remove the redundant _cairo_clip_init_rectangle()
As _cairo_clip_init_rectangle() is equivalent and more importantly more
clearly written as:
_cairo_clip_init(&clip);
if (status = _cairo_clip_rectangle(&clip, &rect)) {
_cairo_clip_fini(&fini);
return status;
}
perform the transformation and in the process catch a few mistakes along
error paths.
Diffstat (limited to 'src/cairo-clip.c')
-rw-r--r-- | src/cairo-clip.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/cairo-clip.c b/src/cairo-clip.c index fdb94701d..19be8120e 100644 --- a/src/cairo-clip.c +++ b/src/cairo-clip.c @@ -164,35 +164,25 @@ _cairo_clip_intersect_rectangle (cairo_clip_t *clip, status = _cairo_path_fixed_close_path (&clip_path->path); assert (status == CAIRO_STATUS_SUCCESS); - clip_path->extents = *rect; clip_path->fill_rule = CAIRO_FILL_RULE_WINDING; clip_path->tolerance = 1; clip_path->antialias = CAIRO_ANTIALIAS_DEFAULT; clip_path->flags |= CAIRO_CLIP_PATH_IS_BOX; + clip_path->extents = *rect; + if (clip_path->prev != NULL) { + if (! _cairo_rectangle_intersect (&clip_path->extents, + &clip_path->prev->extents)) + { + _cairo_clip_set_all_clipped (clip); + } + } + /* could preallocate the region if it proves worthwhile */ return CAIRO_STATUS_SUCCESS; } -/* XXX consider accepting a matrix, no users yet. */ -cairo_status_t -_cairo_clip_init_rectangle (cairo_clip_t *clip, - const cairo_rectangle_int_t *rect) -{ - _cairo_clip_init (clip); - - if (rect == NULL) - return CAIRO_STATUS_SUCCESS; - - if (rect->width == 0 || rect->height == 0) { - _cairo_clip_set_all_clipped (clip); - return CAIRO_STATUS_SUCCESS; - } - - return _cairo_clip_intersect_rectangle (clip, rect); -} - cairo_clip_t * _cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other) { @@ -361,6 +351,7 @@ _cairo_clip_path_reapply_clip_path_transform (cairo_clip_t *clip, status = _cairo_path_fixed_init_copy (&clip_path->path, &other_path->path); if (unlikely (status)) { + clip->path = clip->path->prev; _cairo_clip_path_destroy (clip_path); return status; } @@ -403,6 +394,7 @@ _cairo_clip_path_reapply_clip_path_translate (cairo_clip_t *clip, status = _cairo_path_fixed_init_copy (&clip_path->path, &other_path->path); if (unlikely (status)) { + clip->path = clip->path->prev; _cairo_clip_path_destroy (clip_path); return status; } |