[cairo-commit] 2 commits - src/cairo-pdf-surface.c
test/text-antialias-gray-pdf-argb32-ref.png
test/text-antialias-none-pdf-argb32-ref.png
test/text-antialias-subpixel-pdf-argb32-ref.png
Carl Worth
cworth at kemper.freedesktop.org
Fri Apr 21 02:51:12 PDT 2006
src/cairo-pdf-surface.c | 37 ++++++++++++------------
test/text-antialias-gray-pdf-argb32-ref.png |binary
test/text-antialias-none-pdf-argb32-ref.png |binary
test/text-antialias-subpixel-pdf-argb32-ref.png |binary
4 files changed, 20 insertions(+), 17 deletions(-)
New commits:
diff-tree 810d9d19854f671d6a5d985b950d7442e59176e3 (from 7fa8bfd738f939c06480c40162e347a2ecadd4d6)
Author: Carl Worth <cworth at cworth.org>
Date: Thu Apr 20 10:54:01 2006 -0700
PDF: Fix reference images inadvertently committed as PDF not PNG
diff --git a/test/text-antialias-gray-pdf-argb32-ref.png b/test/text-antialias-gray-pdf-argb32-ref.png
index fd0e716..bd039b3 100644
Binary files a/test/text-antialias-gray-pdf-argb32-ref.png and b/test/text-antialias-gray-pdf-argb32-ref.png differ
diff --git a/test/text-antialias-none-pdf-argb32-ref.png b/test/text-antialias-none-pdf-argb32-ref.png
index fd0e716..bd039b3 100644
Binary files a/test/text-antialias-none-pdf-argb32-ref.png and b/test/text-antialias-none-pdf-argb32-ref.png differ
diff --git a/test/text-antialias-subpixel-pdf-argb32-ref.png b/test/text-antialias-subpixel-pdf-argb32-ref.png
index fd0e716..bd039b3 100644
Binary files a/test/text-antialias-subpixel-pdf-argb32-ref.png and b/test/text-antialias-subpixel-pdf-argb32-ref.png differ
diff-tree 7fa8bfd738f939c06480c40162e347a2ecadd4d6 (from c5d5687ac09049ca5b942993fc259e54ad5b6721)
Author: Carl Worth <cworth at cworth.org>
Date: Thu Apr 20 10:01:45 2006 -0700
PDF: Cleanup error handling of emit_image_rgb_data
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 8c2252a..7cb9d13 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -637,12 +637,12 @@ compress_dup (const void *data, unsigned
return compressed;
}
-/* XXX: This should be rewritten to use the standard cairo_status_t
- * return and the error paths here need to be checked for memory
- * leaks. */
-static unsigned int
-emit_image_rgb_data (cairo_pdf_document_t *document,
- cairo_image_surface_t *image)
+/* Emit image data into the given document, providing an id that can
+ * be used to reference the data in id_ret. */
+static cairo_status_t
+emit_image_rgb_data (cairo_pdf_document_t *document,
+ cairo_image_surface_t *image,
+ unsigned int *id_ret)
{
cairo_output_stream_t *output = document->output_stream;
cairo_pdf_stream_t *stream;
@@ -657,7 +657,7 @@ emit_image_rgb_data (cairo_pdf_document_
rgb_size = image->height * image->width * 3;
rgb = malloc (rgb_size);
if (rgb == NULL)
- return 0;
+ return CAIRO_STATUS_NO_MEMORY;
/* XXX: We could actually output the alpha channels through PDF
* 1.4's SMask. But for now, all we support is opaque image data,
@@ -669,7 +669,7 @@ emit_image_rgb_data (cairo_pdf_document_
image->height);
if (opaque->status) {
free (rgb);
- return 0;
+ return opaque->status;
}
_cairo_pattern_init_for_surface (&pattern.surface, &image->base);
@@ -710,7 +710,7 @@ emit_image_rgb_data (cairo_pdf_document_
compressed = compress_dup (rgb, rgb_size, &compressed_size);
if (compressed == NULL) {
free (rgb);
- return 0;
+ return CAIRO_STATUS_NO_MEMORY;
}
_cairo_pdf_document_close_stream (document);
@@ -736,7 +736,9 @@ emit_image_rgb_data (cairo_pdf_document_
if (opaque_image != image)
cairo_surface_destroy (opaque);
- return stream->id;
+ *id_ret = stream->id;
+
+ return CAIRO_STATUS_SUCCESS;
}
static cairo_int_status_t
@@ -757,11 +759,9 @@ _cairo_pdf_surface_composite_image (cair
if (status)
return status;
- id = emit_image_rgb_data (dst->document, image);
- if (id == 0) {
- status = CAIRO_STATUS_NO_MEMORY;
+ status = emit_image_rgb_data (dst->document, image, &id);
+ if (status)
goto bail;
- }
_cairo_pdf_surface_add_xobject (dst, id);
@@ -929,7 +929,7 @@ emit_surface_pattern (cairo_pdf_surface_
cairo_pdf_stream_t *stream;
cairo_image_surface_t *image;
void *image_extra;
- cairo_status_t status;
+ cairo_status_t status = CAIRO_STATUS_SUCCESS;
unsigned int id, alpha;
cairo_matrix_t i2u;
@@ -944,7 +944,9 @@ emit_surface_pattern (cairo_pdf_surface_
_cairo_pdf_document_close_stream (document);
- id = emit_image_rgb_data (dst->document, image);
+ status = emit_image_rgb_data (dst->document, image, &id);
+ if (status)
+ goto BAIL;
/* BBox must be smaller than XStep by YStep or acroread wont
* display the pattern. */
@@ -983,9 +985,10 @@ emit_surface_pattern (cairo_pdf_surface_
"/a%d gs\r\n",
stream->id, stream->id, alpha);
+ BAIL:
_cairo_surface_release_source_image (pattern->surface, image, image_extra);
- return CAIRO_STATUS_SUCCESS;
+ return status;
}
More information about the cairo-commit
mailing list