summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-09-17 12:00:49 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-09-17 12:00:49 +0100
commit09b42c748e9dbcc923560c7d8bf5298fbffe95ef (patch)
tree74425634513db0384a3d9d066cdec7f6bd63f27c
parent242fbb010efffb3a75f2e824bbdbb3a75ad51d12 (diff)
wrapper: intersect with target extents
Treat the target extents as an implicit clip for computing the maximal operation extents. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/cairo-surface-wrapper.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/cairo-surface-wrapper.c b/src/cairo-surface-wrapper.c
index d2d971dec..48bd30a55 100644
--- a/src/cairo-surface-wrapper.c
+++ b/src/cairo-surface-wrapper.c
@@ -621,35 +621,46 @@ cairo_bool_t
_cairo_surface_wrapper_get_target_extents (cairo_surface_wrapper_t *wrapper,
cairo_rectangle_int_t *extents)
{
- cairo_rectangle_int_t tmp;
+ cairo_rectangle_int_t clip;
+ cairo_bool_t has_clip;
+ has_clip = _cairo_surface_get_extents (wrapper->target, &clip);
if (wrapper->clip) {
- const cairo_rectangle_int_t *r = _cairo_clip_get_extents (wrapper->clip);
- if (wrapper->needs_transform) {
- cairo_matrix_t m;
- double x1, y1, x2, y2;
+ if (has_clip) {
+ if (! _cairo_rectangle_intersect (&clip,
+ _cairo_clip_get_extents (wrapper->clip)))
+ return FALSE;
+ } else {
+ has_clip = TRUE;
+ clip = *_cairo_clip_get_extents (wrapper->clip);
+ }
+ }
- _cairo_surface_wrapper_get_inverse_transform (wrapper, &m);
+ if (has_clip && wrapper->needs_transform) {
+ cairo_matrix_t m;
+ double x1, y1, x2, y2;
- x1 = r->x;
- y1 = r->y;
- x2 = r->x + r->width;
- y2 = r->y + r->height;
+ _cairo_surface_wrapper_get_inverse_transform (wrapper, &m);
- _cairo_matrix_transform_bounding_box (&m, &x1, &y1, &x2, &y2, NULL);
+ x1 = clip.x;
+ y1 = clip.y;
+ x2 = clip.x + clip.width;
+ y2 = clip.y + clip.height;
- tmp.x = floor (x1);
- tmp.y = floor (y1);
- tmp.width = ceil (x2) - tmp.x;
- tmp.height = ceil (y2) - tmp.y;
- r = &tmp;
- }
+ _cairo_matrix_transform_bounding_box (&m, &x1, &y1, &x2, &y2, NULL);
+
+ clip.x = floor (x1);
+ clip.y = floor (y1);
+ clip.width = ceil (x2) - clip.x;
+ clip.height = ceil (y2) - clip.y;
+ }
+ if (has_clip) {
if (wrapper->has_extents) {
*extents = wrapper->extents;
- return _cairo_rectangle_intersect (extents, r);
+ return _cairo_rectangle_intersect (extents, &clip);
} else {
- *extents = *r;
+ *extents = clip;
return TRUE;
}
} else if (wrapper->has_extents) {