mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-01 12:37:58 +02:00
[clip] During _clip() limit the extracted traps to the current clip extents
By applying a tight _cairo_traps_limit() we can reduce the amount of work we need to do when tessellating the path and extracting the trapezoids.
This commit is contained in:
parent
650b85ec77
commit
394e139213
1 changed files with 35 additions and 4 deletions
|
|
@ -626,9 +626,10 @@ _cairo_clip_clip (cairo_clip_t *clip,
|
|||
cairo_surface_t *target)
|
||||
{
|
||||
cairo_status_t status;
|
||||
cairo_rectangle_int_t rectangle;
|
||||
cairo_rectangle_int_t limits, extents;
|
||||
cairo_traps_t traps;
|
||||
cairo_box_t ignored_box;
|
||||
cairo_bool_t have_limits;
|
||||
|
||||
if (clip->all_clipped)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
|
@ -662,13 +663,43 @@ _cairo_clip_clip (cairo_clip_t *clip,
|
|||
|
||||
_cairo_traps_init (&traps);
|
||||
|
||||
/* Limit the traps to the target surface
|
||||
/* Limit the traps to the target surface and current clip
|
||||
* - so we don't add more traps than needed. */
|
||||
status = _cairo_surface_get_extents (target, &rectangle);
|
||||
have_limits = FALSE;
|
||||
if (clip->region != NULL) {
|
||||
cairo_region_get_extents (clip->region, &limits);
|
||||
have_limits = TRUE;
|
||||
}
|
||||
|
||||
if (clip->surface != NULL) {
|
||||
if (have_limits) {
|
||||
if (! _cairo_rectangle_intersect (&limits, &clip->surface_rect)) {
|
||||
_cairo_clip_set_all_clipped (clip, target);
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
limits = clip->surface_rect;
|
||||
have_limits = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
status = _cairo_surface_get_extents (target, &extents);
|
||||
if (status == CAIRO_STATUS_SUCCESS) {
|
||||
if (have_limits) {
|
||||
if (! _cairo_rectangle_intersect (&limits, &extents)) {
|
||||
_cairo_clip_set_all_clipped (clip, target);
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
limits = extents;
|
||||
have_limits = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (have_limits) {
|
||||
cairo_box_t box;
|
||||
|
||||
_cairo_box_from_rectangle (&box, &rectangle);
|
||||
_cairo_box_from_rectangle (&box, &limits);
|
||||
_cairo_traps_limit (&traps, &box);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue