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

Chris Wilson ickle at kemper.freedesktop.org
Thu May 10 13:03:02 PDT 2007


 src/cairo-meta-surface.c |    3 +++
 src/cairo-pattern.c      |    3 +++
 2 files changed, 6 insertions(+)

New commits:
diff-tree ebababc0cf83f828d48200b8e316f57912fb0128 (from e8e5f93ffec8321c029c0b95abcb3cd8cadcff31)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu May 10 19:24:54 2007 +0100

    [cairo-pattern] Return the nil cairo_pattern_t for CAIRO_STATUS_NO_MEMORY.
    
    If we asked to create a pattern after encountering an allocation failure,
    we can avoid another allocation by returning the nil pattern object.

diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 033519c..151fc3c 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -338,6 +338,9 @@ _cairo_pattern_create_in_error (cairo_st
 {
     cairo_pattern_t *pattern;
 
+    if (status == CAIRO_STATUS_NO_MEMORY)
+	return (cairo_pattern_t *)&_cairo_pattern_nil.base;
+
     pattern = _cairo_pattern_create_solid (_cairo_stock_color (CAIRO_STOCK_BLACK),
 					   CAIRO_CONTENT_COLOR);
     /* no-op on a pattern already in error i.e the _cairo_pattern_nil */
diff-tree e8e5f93ffec8321c029c0b95abcb3cd8cadcff31 (from 195112697fac77e70ef36e00a2d557eda1e0e145)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu May 10 20:50:58 2007 +0100

    [cairo-meta-surface] Add a surface->status guard to meta_surface_replay()
    
    Before attempting to access the cairo_meta_surface_t specific members,
    we need to ensure that _cairo_meta_surface_replay() has received a true
    meta surface rather than an error surface (e.g. _cairo_surface_nil).

diff --git a/src/cairo-meta-surface.c b/src/cairo-meta-surface.c
index 98ccaaf..8dbd608 100644
--- a/src/cairo-meta-surface.c
+++ b/src/cairo-meta-surface.c
@@ -652,6 +652,9 @@ _cairo_meta_surface_replay (cairo_surfac
     cairo_matrix_t *device_transform = &target->device_transform;
     cairo_path_fixed_t path_copy, *dev_path;
 
+    if (surface->status)
+	return surface->status;
+
     meta = (cairo_meta_surface_t *) surface;
     status = CAIRO_STATUS_SUCCESS;
 


More information about the cairo-commit mailing list