summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2016-07-15 16:24:03 +0930
committerAdrian Johnson <ajohnson@redneon.com>2016-07-15 16:32:53 +0930
commit0e6f7deac1092666464b81866f5d5a13866befe4 (patch)
treeb83d2399ab1033df476fbc3aa699d3b445fa629f
parentb73c082c7f412f53eb2e4b52689601128a5f06a0 (diff)
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
-rw-r--r--src/cairo-ps-surface.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 7a098f602..7d0240d5c 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