[cairo-commit] 2 commits - src/cairo-image-surface.c src/cairo-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Sat May 26 07:23:32 PDT 2012


 src/cairo-image-surface.c |   26 +++++++++++++++++++-------
 src/cairo-surface.c       |   19 +++++--------------
 2 files changed, 24 insertions(+), 21 deletions(-)

New commits:
commit 29a42ae6827dd17d002304aba552ffb83d3f8a2f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat May 26 15:16:13 2012 +0100

    surface: Kill imagesurf temporary variable
    
    The local alias to &image->base is more confusing that the code it
    replaces.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 0e5484c..8a7cbb0 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -760,7 +760,6 @@ cairo_surface_map_to_image (cairo_surface_t  *surface,
 			    const cairo_rectangle_int_t *extents)
 {
     cairo_rectangle_int_t rect;
-    cairo_surface_t *imagesurf;
     cairo_image_surface_t *image;
     cairo_status_t status;
 
@@ -786,27 +785,19 @@ cairo_surface_map_to_image (cairo_surface_t  *surface,
     }
 
     image = _cairo_surface_map_to_image (surface, extents);
-    imagesurf = &image->base;
 
-    status = cairo_surface_status (imagesurf);
+    status = image->base.status;
     if (unlikely (status)) {
-	cairo_surface_destroy (imagesurf);
+	cairo_surface_destroy (&image->base);
 	return _cairo_surface_create_in_error (status);
     }
 
-    if (cairo_image_surface_get_format (imagesurf) == CAIRO_FORMAT_INVALID) {
-	cairo_surface_destroy (imagesurf);
+    if (image->format == CAIRO_FORMAT_INVALID) {
+	cairo_surface_destroy (&image->base);
 	image = _cairo_image_surface_clone_subimage (surface, extents);
-	imagesurf = &image->base;
     }
 
-    status = cairo_surface_status (imagesurf);
-    if (unlikely (status)) {
-	cairo_surface_destroy (imagesurf);
-	return _cairo_surface_create_in_error (status);
-    }
-
-    return imagesurf;
+    return &image->base;
 }
 
 /**
commit 11e276753f0d335027a7727bf17006d612b4e4c2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat May 26 15:20:56 2012 +0100

    image: Propagate errors from clone_subimage
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 13e1d03..33170cd 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -1214,12 +1214,15 @@ _cairo_image_surface_clone_subimage (cairo_surface_t             *surface,
 {
     cairo_surface_t *image;
     cairo_surface_pattern_t pattern;
-    cairo_status_t ignored;
+    cairo_status_t status;
 
     image = cairo_surface_create_similar_image (surface,
 						_cairo_format_from_content (surface->content),
 						extents->width,
 						extents->height);
+    if (image->status)
+	return to_image_surface (image);
+
     /* TODO: check me with non-identity device_transform. Should we
      * clone the scaling, too? */
     cairo_surface_set_device_offset (image,
@@ -1229,16 +1232,25 @@ _cairo_image_surface_clone_subimage (cairo_surface_t             *surface,
     _cairo_pattern_init_for_surface (&pattern, surface);
     pattern.base.filter = CAIRO_FILTER_NEAREST;
 
-    ignored = _cairo_surface_paint (image,
-				    CAIRO_OPERATOR_SOURCE,
-				    &pattern.base,
-				    NULL);
+    status = _cairo_surface_paint (image,
+				   CAIRO_OPERATOR_SOURCE,
+				   &pattern.base,
+				   NULL);
 
     _cairo_pattern_fini (&pattern.base);
 
-    cairo_surface_set_user_data (image, &clone_key, surface, NULL);
+    if (unlikely (status))
+	goto error;
+
+    status = cairo_surface_set_user_data (image, &clone_key, surface, NULL);
+    if (unlikely (status))
+	goto error;
+
+    return to_image_surface (image);
 
-    return (cairo_image_surface_t *) image;
+error:
+    cairo_surface_destroy (image);
+    return to_image_surface (_cairo_surface_create_in_error (status));
 }
 
 cairo_bool_t


More information about the cairo-commit mailing list