[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.)
This commit is contained in:
Chris Wilson 2008-10-07 21:09:16 +01:00
parent 552cc09e6b
commit eaa4bd1392

View file

@ -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);
}
}
}