summaryrefslogtreecommitdiff
path: root/src/cairo-pattern.c
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2010-12-17 11:04:41 +0100
committerAndrea Canciani <ranma42@gmail.com>2011-01-02 18:31:42 +0100
commit51594d9787905618de608a367c3a5fc0544c52e3 (patch)
tree47487f06cfdac82952d37befa52ba03c5e8e5485 /src/cairo-pattern.c
parentada6057b8ccab133909b127850c41abb3216a842 (diff)
matrix: Cairo matrix to pixman transform/offset conversion
Xlib, XCB and image use the same code to convert a cairo_matrix_t to a backend-specific transform. The code did not handle correctly some matrices, thus a new function that performs the conversion in a more generic way was added and used in the backends instead of fixing the repeated code. Fixes part of https://bugs.freedesktop.org/show_bug.cgi?id=32215
Diffstat (limited to 'src/cairo-pattern.c')
-rw-r--r--src/cairo-pattern.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 34a5cf44..c69e70ba 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -2126,7 +2126,7 @@ _cairo_pattern_acquire_surface_for_gradient (const cairo_gradient_pattern_t *pat
pixman_transform_t pixman_transform;
cairo_status_t status;
cairo_bool_t repeat = FALSE;
-
+ int ix, iy;
pixman_gradient_stop_t pixman_stops_static[2];
pixman_gradient_stop_t *pixman_stops = pixman_stops_static;
unsigned int i;
@@ -2286,12 +2286,21 @@ _cairo_pattern_acquire_surface_for_gradient (const cairo_gradient_pattern_t *pat
return image->base.status;
}
- _cairo_matrix_to_pixman_matrix (&matrix, &pixman_transform,
- width/2., height/2.);
- if (!pixman_image_set_transform (pixman_image, &pixman_transform)) {
- cairo_surface_destroy (&image->base);
- pixman_image_unref (pixman_image);
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ ix = x;
+ iy = y;
+ status = _cairo_matrix_to_pixman_matrix_offset (&matrix,
+ pattern->base.filter,
+ width/2., height/2.,
+ &pixman_transform,
+ &ix, &iy);
+ if (status != CAIRO_INT_STATUS_NOTHING_TO_DO) {
+ if (unlikely (status != CAIRO_STATUS_SUCCESS) ||
+ ! pixman_image_set_transform (pixman_image, &pixman_transform))
+ {
+ cairo_surface_destroy (&image->base);
+ pixman_image_unref (pixman_image);
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ }
}
switch (pattern->base.extend) {
@@ -2313,7 +2322,7 @@ _cairo_pattern_acquire_surface_for_gradient (const cairo_gradient_pattern_t *pat
pixman_image,
NULL,
image->pixman_image,
- x, y,
+ ix, iy,
0, 0,
0, 0,
width, height);