Make clipping fast path fast. When we have a clipping region set, intersect it against the drawing extents to determine the bounding box for the visible drawing.

This commit is contained in:
Kristian Høgsberg 2005-02-12 12:59:53 +00:00
parent 063ba1f51d
commit b33f37ff04
4 changed files with 77 additions and 1 deletions

View file

@ -1,3 +1,11 @@
2005-02-12 Kristian Høgsberg <krh@redhat.com>
* src/cairo_gstate.c
(_cairo_gstate_clip_and_composite_trapezoids): Make clipping fast
path fast. When we have a clipping region set, intersect it
against the drawing extents to determine the bounding box for the
visible drawing.
2005-02-10 Carl Worth <cworth@cworth.org>
* BUGS: Add bug for cairo_show_surface under non-default CTM.

View file

@ -1565,6 +1565,40 @@ _cairo_gstate_clip_and_composite_trapezoids (cairo_gstate_t *gstate,
return status;
} else {
if (gstate->clip.region) {
pixman_box16_t box;
pixman_box16_t *intersection_extents;
pixman_region16_t *rect, *intersection;
box.x1 = _cairo_fixed_integer_floor (trap_extents.p1.x);
box.y1 = _cairo_fixed_integer_floor (trap_extents.p1.y);
box.x2 = _cairo_fixed_integer_ceil (trap_extents.p2.x);
box.y2 = _cairo_fixed_integer_ceil (trap_extents.p2.y);
rect = pixman_region_create_simple (&box);
if (rect == NULL)
goto bail1;
intersection = pixman_region_create();
if (intersection == NULL)
goto bail2;
if (pixman_region_intersect (intersection, gstate->clip.region,
rect) != PIXMAN_REGION_STATUS_SUCCESS)
goto bail3;
intersection_extents = pixman_region_extents (intersection);
extents.x = intersection_extents->x1;
extents.y = intersection_extents->y1;
extents.width = intersection_extents->x2 - intersection_extents->x2;
extents.height = intersection_extents->y2 - intersection_extents->y1;
bail3:
pixman_region_destroy (intersection);
bail2:
pixman_region_destroy (rect);
bail1:
;
}
_cairo_pattern_init_copy (&pattern, src);
_cairo_gstate_create_pattern (gstate, &pattern);

View file

@ -105,7 +105,7 @@ cairo_create (void)
* @cr: a #cairo_t
*
* Increases the reference count on @cr by one. This prevents
* @cr from being destroyed until a matching call to @cairo_destroy()
* @cr from being destroyed until a matching call to cairo_destroy()
* is made.
**/
void

View file

@ -1565,6 +1565,40 @@ _cairo_gstate_clip_and_composite_trapezoids (cairo_gstate_t *gstate,
return status;
} else {
if (gstate->clip.region) {
pixman_box16_t box;
pixman_box16_t *intersection_extents;
pixman_region16_t *rect, *intersection;
box.x1 = _cairo_fixed_integer_floor (trap_extents.p1.x);
box.y1 = _cairo_fixed_integer_floor (trap_extents.p1.y);
box.x2 = _cairo_fixed_integer_ceil (trap_extents.p2.x);
box.y2 = _cairo_fixed_integer_ceil (trap_extents.p2.y);
rect = pixman_region_create_simple (&box);
if (rect == NULL)
goto bail1;
intersection = pixman_region_create();
if (intersection == NULL)
goto bail2;
if (pixman_region_intersect (intersection, gstate->clip.region,
rect) != PIXMAN_REGION_STATUS_SUCCESS)
goto bail3;
intersection_extents = pixman_region_extents (intersection);
extents.x = intersection_extents->x1;
extents.y = intersection_extents->y1;
extents.width = intersection_extents->x2 - intersection_extents->x2;
extents.height = intersection_extents->y2 - intersection_extents->y1;
bail3:
pixman_region_destroy (intersection);
bail2:
pixman_region_destroy (rect);
bail1:
;
}
_cairo_pattern_init_copy (&pattern, src);
_cairo_gstate_create_pattern (gstate, &pattern);