Skip to content

Commit

Permalink
[pattern] After cloning adjust [xy]_offset if possible.
Browse files Browse the repository at this point in the history
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. 5b97ee6 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.)
  • Loading branch information
Chris Wilson committed Oct 7, 2008
1 parent 552cc09 commit eaa4bd1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/cairo-pattern.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit eaa4bd1

Please sign in to comment.