mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-02-02 05:00:27 +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_surface_wrapper_get_target_extents (cairo_surface_wrapper_t *wrapper,
|
||||||
cairo_rectangle_int_t *extents)
|
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) {
|
if (wrapper->clip) {
|
||||||
const cairo_rectangle_int_t *r = _cairo_clip_get_extents (wrapper->clip);
|
if (has_clip) {
|
||||||
if (wrapper->needs_transform) {
|
if (! _cairo_rectangle_intersect (&clip,
|
||||||
cairo_matrix_t m;
|
_cairo_clip_get_extents (wrapper->clip)))
|
||||||
double x1, y1, x2, y2;
|
return FALSE;
|
||||||
|
} else {
|
||||||
_cairo_surface_wrapper_get_inverse_transform (wrapper, &m);
|
has_clip = TRUE;
|
||||||
|
clip = *_cairo_clip_get_extents (wrapper->clip);
|
||||||
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 && 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) {
|
if (wrapper->has_extents) {
|
||||||
*extents = wrapper->extents;
|
*extents = wrapper->extents;
|
||||||
return _cairo_rectangle_intersect (extents, r);
|
return _cairo_rectangle_intersect (extents, &clip);
|
||||||
} else {
|
} else {
|
||||||
*extents = *r;
|
*extents = clip;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
} else if (wrapper->has_extents) {
|
} else if (wrapper->has_extents) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue