mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-01 01:20:15 +01:00
[clip] Limit traps.
Apply prior knowledge to limit the traps during clipping to avoid generating extra work.
This commit is contained in:
parent
c36a242303
commit
7357e80054
1 changed files with 16 additions and 2 deletions
|
|
@ -148,7 +148,10 @@ _cairo_clip_path_intersect_to_rectangle (cairo_clip_path_t *clip_path,
|
|||
cairo_box_t extents;
|
||||
cairo_rectangle_int_t extents_rect;
|
||||
|
||||
_cairo_box_from_rectangle (&extents, rectangle);
|
||||
|
||||
_cairo_traps_init (&traps);
|
||||
_cairo_traps_limit (&traps, &extents);
|
||||
|
||||
status = _cairo_path_fixed_fill_to_traps (&clip_path->path,
|
||||
clip_path->fill_rule,
|
||||
|
|
@ -436,9 +439,8 @@ _cairo_clip_intersect_mask (cairo_clip_t *clip,
|
|||
|
||||
/* Intersect with the target surface rectangle so we don't use
|
||||
* more memory and time than we need to. */
|
||||
|
||||
status = _cairo_surface_get_extents (target, &target_rect);
|
||||
if (!status)
|
||||
if (status == CAIRO_STATUS_SUCCESS)
|
||||
_cairo_rectangle_intersect (&surface_rect, &target_rect);
|
||||
|
||||
if (surface_rect.width == 0 || surface_rect.height == 0) {
|
||||
|
|
@ -561,6 +563,7 @@ _cairo_clip_clip (cairo_clip_t *clip,
|
|||
cairo_surface_t *target)
|
||||
{
|
||||
cairo_status_t status;
|
||||
cairo_rectangle_int_t rectangle;
|
||||
cairo_traps_t traps;
|
||||
|
||||
if (clip->all_clipped)
|
||||
|
|
@ -582,6 +585,17 @@ _cairo_clip_clip (cairo_clip_t *clip,
|
|||
return status;
|
||||
|
||||
_cairo_traps_init (&traps);
|
||||
|
||||
/* Limit the traps to the target surface
|
||||
* - so we don't add more traps than needed. */
|
||||
status = _cairo_surface_get_extents (target, &rectangle);
|
||||
if (status == CAIRO_STATUS_SUCCESS) {
|
||||
cairo_box_t box;
|
||||
|
||||
_cairo_box_from_rectangle (&box, &rectangle);
|
||||
_cairo_traps_limit (&traps, &box);
|
||||
}
|
||||
|
||||
status = _cairo_path_fixed_fill_to_traps (path,
|
||||
fill_rule,
|
||||
tolerance,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue