ps: ensure shading domain is [ 0 1 ]

Printing to a printer with an Adobe PostScript 3 interpreter fails
with rangecheck when the shading domain is not [ 0 1 ]. Workaround
this by using a type 3 function to map from [ 0 1] to the required
domain.
This commit is contained in:
Adrian Johnson 2012-02-02 22:58:06 +10:30
parent a004fe8529
commit 477bcd89d7

View file

@ -3722,10 +3722,6 @@ _cairo_ps_surface_emit_gradient (cairo_ps_surface_t *surface,
MAX (end.radius, 0));
}
_cairo_output_stream_printf (surface->stream,
" /Domain [ %f %f ]\n",
domain[0], domain[1]);
if (pattern->base.extend != CAIRO_EXTEND_NONE) {
_cairo_output_stream_printf (surface->stream,
" /Extend [ true true ]\n");
@ -3734,8 +3730,22 @@ _cairo_ps_surface_emit_gradient (cairo_ps_surface_t *surface,
" /Extend [ false false ]\n");
}
if (domain[0] == 0.0 && domain[1] == 1.0) {
_cairo_output_stream_printf (surface->stream,
" /Function CairoFunction\n");
} else {
_cairo_output_stream_printf (surface->stream,
" /Function <<\n"
" /FunctionType 3\n"
" /Domain [ 0 1 ]\n"
" /Bounds [ ]\n"
" /Encode [ %f %f ]\n"
" /Functions [ CairoFunction ]\n"
" >>\n",
domain[0], domain[1]);
}
_cairo_output_stream_printf (surface->stream,
" /Function CairoFunction\n"
" >>\n");
if (is_ps_pattern) {