diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-05-25 12:40:35 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-05-25 22:14:56 +0100 |
commit | b7f199fde25c960bf87302d5e868a7c2dffa4f5d (patch) | |
tree | ba9c62e64cd3bdb586314f4c3d6d2c3ca08d44d6 /src/cairo-pattern.c | |
parent | e4efc80b8e89b05afc22d74f984f4ec9012bc39b (diff) |
[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.
Diffstat (limited to 'src/cairo-pattern.c')
-rw-r--r-- | src/cairo-pattern.c | 21 |
1 files changed, 18 insertions, 3 deletions
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; } |