summaryrefslogtreecommitdiff
path: root/src/cairo-surface-subsurface.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-05-07 11:21:50 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-05-07 11:25:03 +0100
commitb9e9ff59348412a1f1f2c57d6185c84f77874c26 (patch)
tree6e37b674f0080367081f0eb79e48014ed0448a02 /src/cairo-surface-subsurface.c
parent5e3b28ffeac3fc7239c7ada6992e4794a27b0818 (diff)
downloadcairo-b9e9ff59348412a1f1f2c57d6185c84f77874c26.tar.gz
subsurface: Include device offset in extents
Adjust the subsurface extents so that the user specifies the extents in world space rather than device space.
Diffstat (limited to 'src/cairo-surface-subsurface.c')
-rw-r--r--src/cairo-surface-subsurface.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/cairo-surface-subsurface.c b/src/cairo-surface-subsurface.c
index 079f9edd7..90fb16d6e 100644
--- a/src/cairo-surface-subsurface.c
+++ b/src/cairo-surface-subsurface.c
@@ -491,7 +491,8 @@ cairo_surface_create_for_rectangle (cairo_surface_t *target,
{
cairo_surface_subsurface_t *surface;
cairo_rectangle_int_t target_extents;
- cairo_bool_t is_empty;
+ cairo_bool_t ret;
+ int tx, ty;
if (unlikely (target->status))
return _cairo_surface_create_in_error (target->status);
@@ -513,7 +514,7 @@ cairo_surface_create_for_rectangle (cairo_surface_t *target,
surface->extents.height = floor (y + height) - surface->extents.y;
if (_cairo_surface_get_extents (target, &target_extents))
- is_empty = _cairo_rectangle_intersect (&surface->extents, &target_extents);
+ ret = _cairo_rectangle_intersect (&surface->extents, &target_extents);
if (target->backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SUBSURFACE) {
/* Maintain subsurfaces as 1-depth */
@@ -523,6 +524,11 @@ cairo_surface_create_for_rectangle (cairo_surface_t *target,
target = sub->target;
}
+ ret = _cairo_matrix_is_integer_translation (&target->device_transform, &tx, &ty);
+ assert (ret);
+ surface->extents.x += tx;
+ surface->extents.y += ty;
+
surface->target = cairo_surface_reference (target);
surface->owns_target = FALSE;