From b7f199fde25c960bf87302d5e868a7c2dffa4f5d Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 25 May 2009 12:40:35 +0100 Subject: [pattern] Trim REPEAT source size when applicable. Some backends are quite constrained with surface sizes and so trigger fallbacks when asked to clone large images. To avoid this we attempt to trim ROIs (as these are often limited to the destination image, and so can be accommodated by the hardware). This patch allows trimming REPEAT sources both horizontally and vertically independently. --- src/cairo-pattern.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/cairo-pattern.c') diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c index 49187c42..654989f8 100644 --- a/src/cairo-pattern.c +++ b/src/cairo-pattern.c @@ -1972,13 +1972,28 @@ _cairo_pattern_acquire_surface_for_surface (const cairo_surface_pattern_t *pat /* Never acquire a larger area than the source itself */ is_empty = _cairo_rectangle_intersect (&extents, &sampled_area); } else { + int trim = 0; + if (sampled_area.x >= extents.x && - sampled_area.y >= extents.y && - sampled_area.x + (int) sampled_area.width <= extents.x + (int) extents.width && + sampled_area.x + (int) sampled_area.width <= extents.x + (int) extents.width) + { + /* source is horizontally contained within extents, trim */ + extents.x = sampled_area.x; + extents.width = sampled_area.width; + trim |= 0x1; + } + + if (sampled_area.y >= extents.y && sampled_area.y + (int) sampled_area.height <= extents.y + (int) extents.height) { + /* source is vertically contained within extents, trim */ + extents.y = sampled_area.y; + extents.height = sampled_area.height; + trim |= 0x2; + } + + if (trim == 0x3) { /* source is wholly contained within extents, drop the REPEAT */ - extents = sampled_area; attr->extend = CAIRO_EXTEND_NONE; } -- cgit v1.2.3