From 582604f7b6b5b2ab6e681245bc7cde64d4995307 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 25 Jan 2010 19:22:33 +0100 Subject: [PATCH] [png] Simplify coercion code Call _cairo_image_surface_coerce() unconditionally to ensure coercion to one of the standard formats happens even when it's a format we support. --- src/cairo-png.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/cairo-png.c b/src/cairo-png.c index f89e03fc0..ecb27d84b 100644 --- a/src/cairo-png.c +++ b/src/cairo-png.c @@ -172,14 +172,11 @@ write_png (cairo_surface_t *surface, /* Handle the various fallback formats (e.g. low bit-depth XServers) * by coercing them to a simpler format using pixman. */ - if (image->format == CAIRO_FORMAT_INVALID) { - clone = _cairo_image_surface_coerce (image, - _cairo_format_from_content (image->base.content)); - status = clone->base.status; - if (unlikely (status)) - goto BAIL1; - } else - clone = image; + clone = _cairo_image_surface_coerce (image, + _cairo_format_from_content (image->base.content)); + status = clone->base.status; + if (unlikely (status)) + goto BAIL1; rows = _cairo_malloc_ab (clone->height, sizeof (png_byte*)); if (unlikely (rows == NULL)) { @@ -279,8 +276,7 @@ BAIL4: BAIL3: free (rows); BAIL2: - if (clone != image) - cairo_surface_destroy (&clone->base); + cairo_surface_destroy (&clone->base); BAIL1: _cairo_surface_release_source_image (surface, image, image_extra);