[cairo-commit] src/cairo-ps-surface.c
Adrian Johnson
ajohnson at kemper.freedesktop.org
Fri Jul 15 07:06:59 UTC 2016
src/cairo-ps-surface.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
New commits:
commit 0e6f7deac1092666464b81866f5d5a13866befe4
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Fri Jul 15 16:24:03 2016 +0930
ps: flush ASCII85Decode file after use
If the image operator does not read all the ASCII85 data, the PS
interpreter will try to execute the next byte of unread data.
Define our own image operator that calls flushfile (reads until end of
file) on the filter after drawing the image.
https://bugs.freedesktop.org/show_bug.cgi?id=84811
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 7a098f6..7d0240d 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -335,7 +335,10 @@ _cairo_ps_surface_emit_header (cairo_ps_surface_t *surface)
" cairo_store_point /cairo_font where { pop cairo_selectfont } if } bind def\n"
"/g { setgray } bind def\n"
"/rg { setrgbcolor } bind def\n"
- "/d1 { setcachedevice } bind def\n");
+ "/d1 { setcachedevice } bind def\n"
+ "/cairo_flush_ascii85_file { cairo_ascii85_file status { cairo_ascii85_file flushfile } if } def\n"
+ "/cairo_image { image cairo_flush_ascii85_file } def\n"
+ "/cairo_imagemask { imagemask cairo_flush_ascii85_file } def\n");
if (!surface->eps) {
_cairo_output_stream_printf (surface->final_stream,
@@ -2721,6 +2724,9 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t *surface,
"] def\n");
_cairo_output_stream_printf (surface->stream,
"/CairoImageDataIndex 0 def\n");
+ } else {
+ _cairo_output_stream_printf (surface->stream,
+ "/cairo_ascii85_file currentfile /ASCII85Decode filter def\n");
}
if (use_mask) {
@@ -2755,7 +2761,7 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t *surface,
compress_filter);
} else {
_cairo_output_stream_printf (surface->stream,
- " /DataSource currentfile /ASCII85Decode filter /%s filter def\n",
+ " /DataSource cairo_ascii85_file /%s filter def\n",
compress_filter);
}
@@ -2809,15 +2815,16 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t *surface,
compress_filter);
} else {
_cairo_output_stream_printf (surface->stream,
- " /DataSource currentfile /ASCII85Decode filter /%s filter def\n",
+ " /DataSource cairo_ascii85_file /%s filter def\n",
compress_filter);
}
_cairo_output_stream_printf (surface->stream,
" /ImageMatrix [ 1 0 0 -1 0 %d ] def\n"
"end\n"
- "%s\n",
+ "%s%s\n",
ps_image->height,
+ surface->use_string_datasource ? "" : "cairo_",
stencil_mask ? "imagemask" : "image");
}
@@ -2907,6 +2914,9 @@ _cairo_ps_surface_emit_jpeg_image (cairo_ps_surface_t *surface,
"] def\n");
_cairo_output_stream_printf (surface->stream,
"/CairoImageDataIndex 0 def\n");
+ } else {
+ _cairo_output_stream_printf (surface->stream,
+ "/cairo_ascii85_file currentfile /ASCII85Decode filter def\n");
}
_cairo_output_stream_printf (surface->stream,
@@ -2933,14 +2943,15 @@ _cairo_ps_surface_emit_jpeg_image (cairo_ps_surface_t *surface,
" } /ASCII85Decode filter /DCTDecode filter def\n");
} else {
_cairo_output_stream_printf (surface->stream,
- " /DataSource currentfile /ASCII85Decode filter /DCTDecode filter def\n");
+ " /DataSource cairo_ascii85_file /DCTDecode filter def\n");
}
_cairo_output_stream_printf (surface->stream,
" /ImageMatrix [ 1 0 0 -1 0 %d ] def\n"
"end\n"
- "image\n",
- info.height);
+ "%simage\n",
+ info.height,
+ surface->use_string_datasource ? "" : "cairo_");
if (!surface->use_string_datasource) {
/* Emit the image data as a base85-encoded string which will
More information about the cairo-commit
mailing list