mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-08 23:30:21 +01:00
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>
This commit is contained in:
parent
242fbb010e
commit
09b42c748e
1 changed files with 33 additions and 22 deletions
|
|
@ -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;
|
||||
|
||||
_cairo_surface_wrapper_get_inverse_transform (wrapper, &m);
|
||||
|
||||
x1 = r->x;
|
||||
y1 = r->y;
|
||||
x2 = r->x + r->width;
|
||||
y2 = r->y + r->height;
|
||||
|
||||
_cairo_matrix_transform_bounding_box (&m, &x1, &y1, &x2, &y2, NULL);
|
||||
|
||||
tmp.x = floor (x1);
|
||||
tmp.y = floor (y1);
|
||||
tmp.width = ceil (x2) - tmp.x;
|
||||
tmp.height = ceil (y2) - tmp.y;
|
||||
r = &tmp;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (has_clip && wrapper->needs_transform) {
|
||||
cairo_matrix_t m;
|
||||
double x1, y1, x2, y2;
|
||||
|
||||
_cairo_surface_wrapper_get_inverse_transform (wrapper, &m);
|
||||
|
||||
x1 = clip.x;
|
||||
y1 = clip.y;
|
||||
x2 = clip.x + clip.width;
|
||||
y2 = clip.y + clip.height;
|
||||
|
||||
_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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue