From eaa4bd13926728e9da97a23df8a465ef2296049a Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 7 Oct 2008 21:09:16 +0100 Subject: [PATCH] [pattern] After cloning adjust [xy]_offset if possible. For the simple case where the pattern matrix only contains an integer translation then care is taken to convert that to a identity source matrix with the translation applied to the [xy]_offsets. 5b97ee6525 broke this guarantee by applying the clone offsets to the source matrix. So when the source matrix is identity we can simply adjust the [xy]_offsets and preserve the identity matrix. (This idea can be extended further by removing any integer translation from the source matrix and storing it in the [xy]_offsets as a means to extend the limited precision in pixman_matrix_t - encountered when downscaling large images offset onto the target surface.) --- src/cairo-pattern.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c index 33a99a15b..16c3dc9d6 100644 --- a/src/cairo-pattern.c +++ b/src/cairo-pattern.c @@ -1890,10 +1890,20 @@ _cairo_pattern_acquire_surface_for_surface (cairo_surface_pattern_t *pattern, extents.width, extents.height, &x, &y, out); if (status == CAIRO_STATUS_SUCCESS && (x != 0 || y != 0)) { - cairo_matrix_t m; + if (_cairo_matrix_is_identity (&attr->matrix)) { + attr->x_offset -= x; + attr->y_offset -= y; + } else { + cairo_matrix_t m; - cairo_matrix_init_translate (&m, -x, -y); - cairo_matrix_multiply (&attr->matrix, &attr->matrix, &m); + x -= attr->x_offset; + y -= attr->y_offset; + attr->x_offset = 0; + attr->y_offset = 0; + + cairo_matrix_init_translate (&m, -x, -y); + cairo_matrix_multiply (&attr->matrix, &attr->matrix, &m); + } } }