diff options
author | Andrea Canciani <ranma42@gmail.com> | 2010-07-27 21:22:02 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2010-10-07 20:44:50 +0200 |
commit | 5500d072e0e3d66d762a147caa803d036766b629 (patch) | |
tree | 2a94200e4144daafeafeda0577d4ba6d23dcc09f /src | |
parent | 17bb0f8b1fc6d209ad53b7b995bc013c85a4e058 (diff) |
quartz: Handle failures in _cairo_quartz_setup_fallback_source
If the fallback surface creation or painting fail, the fallback
surface needs to be destroyed.
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-quartz-surface.c | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index daae871e..1d7ef047 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -1333,6 +1333,7 @@ static cairo_quartz_action_t _cairo_quartz_setup_fallback_source (cairo_quartz_surface_t *surface, const cairo_pattern_t *source) { + cairo_pattern_union_t pattern; CGRect clipBox = CGContextGetClipBoundingBox (surface->cgContext); double x0, y0, w, h; @@ -1355,42 +1356,23 @@ _cairo_quartz_setup_fallback_source (cairo_quartz_surface_t *surface, fallback = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, (int) w, (int) h); cairo_surface_set_device_offset (fallback, -x0, -y0); -#if 0 - { - cairo_t *fallback_cr; - cairo_pattern_t *source_copy; - - /* Paint the source onto our temporary */ - fallback_cr = cairo_create (fallback); - cairo_set_operator (fallback_cr, CAIRO_OPERATOR_SOURCE); - - /* Use a copy of the pattern because it is const and could be allocated - * on the stack */ - status = _cairo_pattern_create_copy (&source_copy, source); - cairo_set_source (fallback_cr, source_copy); - cairo_pattern_destroy (source_copy); - - cairo_paint (fallback_cr); - cairo_destroy (fallback_cr); - } -#else - { - cairo_pattern_union_t pattern; - - _cairo_pattern_init_static_copy (&pattern.base, source); - _cairo_pattern_transform (&pattern.base, - &fallback->device_transform_inverse); - status = _cairo_surface_paint (fallback, - CAIRO_OPERATOR_SOURCE, - &pattern.base, NULL); + _cairo_pattern_init_static_copy (&pattern.base, source); + _cairo_pattern_transform (&pattern.base, &fallback->device_transform_inverse); + status = _cairo_surface_paint (fallback, CAIRO_OPERATOR_SOURCE, &pattern.base, NULL); + if (unlikely (status)) { + cairo_surface_destroy (fallback); + return DO_UNSUPPORTED; } -#endif status = _cairo_surface_to_cgimage (fallback, &img); - if (unlikely (status)) + if (unlikely (status)) { + cairo_surface_destroy (fallback); return DO_UNSUPPORTED; - if (unlikely (img == NULL)) + } + if (unlikely (img == NULL)) { + cairo_surface_destroy (fallback); return DO_NOTHING; + } surface->sourceImageRect = CGRectMake (0.0, 0.0, w, h); surface->sourceImage = img; |