From 2d39c3217d72ff82585c16f0c018cf56e717ef3a Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 12 Nov 2007 23:13:55 +0000 Subject: [PATCH] Revert "[cairo-clip] Special case using an empty clip path." This reverts commits b4057b8643cf02439b6033d7443d0d4c42220a62, 2f0867b43fbc9a385a32a2a39895f4c3559f6ddf and 5c08226a0f7bc373a96fe75d15ad854910eb3265, which together tried to eliminate redundant work performed whilst the operations are notionally all clipped. However it introduced a couple of regressions in the xlib and quartz backends (and quite possibly a few more unreported ones) so take the safe course of action and revert the changes. --- src/cairo-clip-private.h | 2 - src/cairo-clip.c | 85 +++------------------------------------------ src/cairo-surface.c | 61 +++++---------------------------- 3 files changed, 15 insertions(+), 133 deletions(-) diff --git a/src/cairo-clip-private.h b/src/cairo-clip-private.h index 2e1eabd..c2fe494 100644 --- a/src/cairo-clip-private.h +++ b/src/cairo-clip-private.h @@ -53,8 +53,6 @@ struct _cairo_clip_path { struct _cairo_clip { cairo_clip_mode_t mode; - cairo_bool_t all_clipped; - /* * Mask-based clipping for cases where the backend * clipping isn't sufficiently able. diff --git a/src/cairo-clip.c b/src/cairo-clip.c index 0fed3f6..0b6bf61 100644 --- a/src/cairo-clip.c +++ b/src/cairo-clip.c @@ -54,8 +54,6 @@ _cairo_clip_init (cairo_clip_t *clip, cairo_surface_t *target) else clip->mode = CAIRO_CLIP_MODE_MASK; - clip->all_clipped = FALSE; - clip->surface = NULL; clip->surface_rect.x = 0; clip->surface_rect.y = 0; @@ -75,8 +73,6 @@ _cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other) { clip->mode = other->mode; - clip->all_clipped = other->all_clipped; - clip->surface = cairo_surface_reference (other->surface); clip->surface_rect = other->surface_rect; @@ -86,12 +82,14 @@ _cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other) if (other->has_region) { cairo_status_t status; + status = _cairo_region_copy (&clip->region, &other->region); if (status) { _cairo_region_fini (&clip->region); cairo_surface_destroy (clip->surface); return status; } + clip->has_region = TRUE; } else { clip->has_region = FALSE; @@ -105,8 +103,6 @@ _cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other) void _cairo_clip_reset (cairo_clip_t *clip) { - clip->all_clipped = FALSE; - /* destroy any existing clip-region artifacts */ cairo_surface_destroy (clip->surface); clip->surface = NULL; @@ -127,19 +123,9 @@ _cairo_clip_reset (cairo_clip_t *clip) clip->path = NULL; } -static void -_cairo_clip_set_all_clipped (cairo_clip_t *clip, cairo_surface_t *target) -{ - _cairo_clip_reset (clip); - - clip->all_clipped = TRUE; - clip->serial = _cairo_surface_allocate_clip_serial (target); -} - - static cairo_status_t _cairo_clip_path_intersect_to_rectangle (cairo_clip_path_t *clip_path, - cairo_rectangle_int_t *rectangle) + cairo_rectangle_int_t *rectangle) { while (clip_path) { cairo_status_t status; @@ -174,17 +160,12 @@ cairo_status_t _cairo_clip_intersect_to_rectangle (cairo_clip_t *clip, cairo_rectangle_int_t *rectangle) { - if (!clip) - return CAIRO_STATUS_SUCCESS; + cairo_status_t status; - if (clip->all_clipped) { - *rectangle = clip->surface_rect; + if (!clip) return CAIRO_STATUS_SUCCESS; - } if (clip->path) { - cairo_status_t status; - status = _cairo_clip_path_intersect_to_rectangle (clip->path, rectangle); if (status) @@ -192,7 +173,6 @@ _cairo_clip_intersect_to_rectangle (cairo_clip_t *clip, } if (clip->has_region) { - cairo_status_t status = CAIRO_STATUS_SUCCESS; cairo_region_t intersection; _cairo_region_init_rect (&intersection, rectangle); @@ -224,18 +204,6 @@ _cairo_clip_intersect_to_region (cairo_clip_t *clip, if (!clip) return CAIRO_STATUS_SUCCESS; - if (clip->all_clipped) { - cairo_region_t clip_rect; - - _cairo_region_init_rect (&clip_rect, &clip->surface_rect); - - status = _cairo_region_intersect (region, &clip_rect, region); - - _cairo_region_fini (&clip_rect); - - return status; - } - if (clip->path) { /* Intersect clip path into region. */ } @@ -277,9 +245,6 @@ _cairo_clip_combine_to_surface (cairo_clip_t *clip, cairo_pattern_union_t pattern; cairo_status_t status; - if (clip->all_clipped) - return CAIRO_STATUS_SUCCESS; - _cairo_pattern_init_for_surface (&pattern.surface, clip->surface); status = _cairo_surface_composite (op, @@ -360,7 +325,6 @@ _cairo_clip_path_destroy (cairo_clip_path_t *clip_path) free (clip_path); } - static cairo_int_status_t _cairo_clip_intersect_region (cairo_clip_t *clip, cairo_traps_t *traps, @@ -369,9 +333,6 @@ _cairo_clip_intersect_region (cairo_clip_t *clip, cairo_region_t region; cairo_int_status_t status; - if (clip->all_clipped) - return CAIRO_STATUS_SUCCESS; - if (clip->mode != CAIRO_CLIP_MODE_REGION) return CAIRO_INT_STATUS_UNSUPPORTED; @@ -403,9 +364,6 @@ _cairo_clip_intersect_region (cairo_clip_t *clip, clip->serial = _cairo_surface_allocate_clip_serial (target); _cairo_region_fini (®ion); - if (! _cairo_region_not_empty (&clip->region)) - _cairo_clip_set_all_clipped (clip, target); - return status; } @@ -421,9 +379,6 @@ _cairo_clip_intersect_mask (cairo_clip_t *clip, cairo_surface_t *surface; cairo_status_t status; - if (clip->all_clipped) - return CAIRO_STATUS_SUCCESS; - /* Represent the clip as a mask surface. We create a new surface * the size of the intersection of the old mask surface and the * extents of the new clip path. */ @@ -441,14 +396,6 @@ _cairo_clip_intersect_mask (cairo_clip_t *clip, if (!status) _cairo_rectangle_intersect (&surface_rect, &target_rect); - if (surface_rect.width == 0 || surface_rect.height == 0) { - surface = NULL; - status = CAIRO_STATUS_SUCCESS; - if (clip->surface != NULL) - cairo_surface_destroy (clip->surface); - goto DONE; - } - _cairo_pattern_init_solid (&pattern.solid, CAIRO_COLOR_WHITE, CAIRO_CONTENT_COLOR); surface = _cairo_surface_create_similar_solid (target, @@ -512,14 +459,10 @@ _cairo_clip_intersect_mask (cairo_clip_t *clip, cairo_surface_destroy (clip->surface); } - DONE: clip->surface = surface; clip->surface_rect = surface_rect; clip->serial = _cairo_surface_allocate_clip_serial (target); - if (surface_rect.width == 0 || surface_rect.height == 0) - _cairo_clip_set_all_clipped (clip, target); - return status; } @@ -534,15 +477,6 @@ _cairo_clip_clip (cairo_clip_t *clip, cairo_status_t status; cairo_traps_t traps; - if (clip->all_clipped) - return CAIRO_STATUS_SUCCESS; - - /* catch the empty clip path */ - if (! path->has_current_point) { - _cairo_clip_set_all_clipped (clip, target); - return CAIRO_STATUS_SUCCESS; - } - status = _cairo_clip_intersect_path (clip, path, fill_rule, tolerance, antialias); @@ -577,9 +511,6 @@ _cairo_clip_translate (cairo_clip_t *clip, cairo_fixed_t tx, cairo_fixed_t ty) { - if (clip->all_clipped) - return; - if (clip->has_region) { _cairo_region_translate (&clip->region, _cairo_fixed_integer_part (tx), @@ -709,10 +640,7 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate) { cairo_rectangle_list_t *list; cairo_rectangle_t *rectangles = NULL; - int n_boxes = 0; - - if (clip->all_clipped) - goto DONE; + int n_boxes; if (clip->path || clip->surface) return (cairo_rectangle_list_t*) &_cairo_rectangles_not_representable; @@ -765,7 +693,6 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate) } } - DONE: list = malloc (sizeof (cairo_rectangle_list_t)); if (list == NULL) { free (rectangles); diff --git a/src/cairo-surface.c b/src/cairo-surface.c index ed332f5..97a8b9e 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -1903,38 +1903,6 @@ _cairo_surface_set_clip_path (cairo_surface_t *surface, return CAIRO_STATUS_SUCCESS; } - -/** - * _cairo_surface_set_empty_clip_path: - * @surface: the #cairo_surface_t to set the clip on - * @serial: the clip serial number associated with the clip path - * - * Create an empty clip path, one that represents the entire surface clipped - * out, and assigns the given clipping serial to the surface. - **/ -static cairo_status_t -_cairo_surface_set_empty_clip_path (cairo_surface_t *surface, - unsigned int serial) -{ - cairo_path_fixed_t path; - cairo_status_t status; - - _cairo_path_fixed_init (&path); - - status = surface->backend->intersect_clip_path (surface, - &path, - CAIRO_FILL_RULE_WINDING, - 0, - CAIRO_ANTIALIAS_DEFAULT); - - if (status == CAIRO_STATUS_SUCCESS) - surface->current_clip_serial = serial; - - _cairo_path_fixed_fini (&path); - - return _cairo_surface_set_error (surface, status); -} - cairo_status_t _cairo_surface_set_clip (cairo_surface_t *surface, cairo_clip_t *clip) { @@ -1958,26 +1926,15 @@ _cairo_surface_set_clip (cairo_surface_t *surface, cairo_clip_t *clip) return CAIRO_STATUS_SUCCESS; if (clip) { - if (clip->all_clipped) { - if (surface->backend->intersect_clip_path != NULL) - return _cairo_surface_set_empty_clip_path (surface, - clip->serial); - - if (surface->backend->set_clip_region != NULL) - return _cairo_surface_set_clip_region (surface, - &clip->region, - clip->serial); - } else { - if (clip->path) - return _cairo_surface_set_clip_path (surface, - clip->path, - clip->serial); - - if (clip->has_region) - return _cairo_surface_set_clip_region (surface, - &clip->region, - clip->serial); - } + if (clip->path) + return _cairo_surface_set_clip_path (surface, + clip->path, + clip->serial); + + if (clip->has_region) + return _cairo_surface_set_clip_region (surface, + &clip->region, + clip->serial); } return _cairo_surface_reset_clip (surface); -- 1.5.3.5