[cairo] [PATCH 4/5] surface: Only use non-NULL extents for internal mapping

Andrea Canciani ranma42 at gmail.com
Thu May 17 13:28:09 PDT 2012


_cairo_surface_map_to_image() requires the input extents to be
non-NULL.
---
 src/cairo-gl-operand.c  |    5 ++++-
 src/cairo-xlib-source.c |   13 ++++++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/cairo-gl-operand.c b/src/cairo-gl-operand.c
index a6c7185..9291ac8 100644
--- a/src/cairo-gl-operand.c
+++ b/src/cairo-gl-operand.c
@@ -247,6 +247,7 @@ _cairo_gl_pattern_texture_setup (cairo_gl_operand_t *operand,
     cairo_gl_context_t *ctx;
     cairo_surface_t *image;
     cairo_bool_t src_is_gl_surface = FALSE;
+    cairo_rectangle_int_t map_extents;
 
     if (_src->type == CAIRO_PATTERN_TYPE_SURFACE) {
 	cairo_surface_t* src_surface = ((cairo_surface_pattern_t *) _src)->surface;
@@ -261,7 +262,9 @@ _cairo_gl_pattern_texture_setup (cairo_gl_operand_t *operand,
 	_cairo_gl_surface_create_scratch (ctx,
 					  CAIRO_CONTENT_COLOR_ALPHA,
 					  extents->width, extents->height);
-    image = cairo_surface_map_to_image (&surface->base, NULL);
+    map_extents = *extents;
+    map_extents.x = map_extents.y = 0;
+    image = cairo_surface_map_to_image (&surface->base, &map_extents);
 
     /* If the pattern is a GL surface, it belongs to some other GL context,
        so we need to release this device while we paint it to the image. */
diff --git a/src/cairo-xlib-source.c b/src/cairo-xlib-source.c
index f8dac70..dec7622 100644
--- a/src/cairo-xlib-source.c
+++ b/src/cairo-xlib-source.c
@@ -261,6 +261,7 @@ render_pattern (cairo_xlib_surface_t *dst,
     cairo_xlib_surface_t *src;
     cairo_surface_t *image;
     cairo_status_t status;
+    cairo_rectangle_int_t map_extents;
 
     src = (cairo_xlib_surface_t *)
 	_cairo_surface_create_similar_scratch (&dst->base,
@@ -272,7 +273,10 @@ render_pattern (cairo_xlib_surface_t *dst,
 	return None;
     }
 
-    image = cairo_surface_map_to_image (&src->base, NULL);
+    map_extents = *extents;
+    map_extents.x = map_extents.y = 0;
+
+    image = cairo_surface_map_to_image (&src->base, &map_extents);
     status = _cairo_surface_offset_paint (image, extents->x, extents->y,
 					  CAIRO_OPERATOR_SOURCE, pattern,
 					  NULL);
@@ -912,7 +916,7 @@ surface_source (cairo_xlib_surface_t *dst,
     cairo_surface_t *image;
     cairo_surface_pattern_t local_pattern;
     cairo_status_t status;
-    cairo_rectangle_int_t upload, limit;
+    cairo_rectangle_int_t upload, limit, map_extents;
     cairo_matrix_t m;
 
     upload = *sample;
@@ -939,7 +943,10 @@ surface_source (cairo_xlib_surface_t *dst,
     cairo_matrix_init_translate (&local_pattern.base.matrix,
 				 upload.x, upload.y);
 
-    image = cairo_surface_map_to_image (&src->base, NULL);
+    map_extents = upload;
+    map_extents.x = map_extents.y = 0;
+
+    image = cairo_surface_map_to_image (&src->base, &map_extents);
     status = _cairo_surface_paint (image,
 				   CAIRO_OPERATOR_SOURCE,
 				   &local_pattern.base,
-- 
1.7.7.5 (Apple Git-26)



More information about the cairo mailing list