diff options
author | Raph Levien <raph.levien@artifex.com> | 2004-11-19 01:44:52 +0000 |
---|---|---|
committer | Raph Levien <raph.levien@artifex.com> | 2004-11-19 01:44:52 +0000 |
commit | 89612d0039b67d9941c4be5c8ab412c042d74826 (patch) | |
tree | b2fef8fac63309248d72875a76875b8b675375af /gs | |
parent | f7c89674f3e7908569bf0597a43cc34f0d6abbbd (diff) |
Copies over new-style color procs when making a null device with a
target, to avoid inconsistent states. Fixes bug #687770.
DETAILS
The problem was a null device (for implementing stringwidth) with
inconsistent color info; the color_info struct specified 4 components,
but the get_color_mapping_procs was
gx_default_DevGray_get_color_mapping_procs, which is the desired value
for null devices instantiated through gs_copydevice
(i.e. -sDEVICE=null). As a result, cm_comps[1] through [3] were left
uninitialized, and, when negative, would crash the halftone logic.
This patch copies over the new-style color mapping procs (the
old-style were already copied) in the gs_make_null_device routine. A
strong argument could be made for changing the logic in
gx_device_copy_color_procs() instead, but it was felt that this change
was more localized.
Dan reviewed this patch during a phone conversation, so I am going ahead
and committing. I'm also opening a new bug to encourage a closer look
at other uses of gx_device_copy_color_procs() to see whether a change
there is beneficial or harmful.
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@5514 a1074d23-0009-0410-80fe-cf8c14f379e6
Diffstat (limited to 'gs')
-rw-r--r-- | gs/src/gsdevice.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/gs/src/gsdevice.c b/gs/src/gsdevice.c index 60c9b0a44..e213c8667 100644 --- a/gs/src/gsdevice.c +++ b/gs/src/gsdevice.c @@ -441,8 +441,20 @@ gs_make_null_device(gx_device_null *dev_null, gx_device *dev, gx_device_init((gx_device *)dev_null, (const gx_device *)&gs_null_device, mem, true); gx_device_set_target((gx_device_forward *)dev_null, dev); - if (dev) - gx_device_copy_color_params((gx_device *)dev_null, dev); + if (dev) { + /* The gx_device_copy_color_params() call below should + probably copy over these new-style color mapping procs, as + well as the old-style (map_rgb_color and friends). However, + the change was made here instead, to minimize the potential + impact of the patch. + */ + gx_device *dn = (gx_device *)dev_null; + set_dev_proc(dn, get_color_mapping_procs, gx_forward_get_color_mapping_procs); + set_dev_proc(dn, get_color_comp_index, gx_forward_get_color_comp_index); + set_dev_proc(dn, encode_color, gx_forward_encode_color); + set_dev_proc(dn, decode_color, gx_forward_decode_color); + gx_device_copy_color_params(dn, dev); + } } /* Mark a device as retained or not retained. */ @@ -616,6 +628,11 @@ gx_device_copy_color_procs(gx_device *dev, const gx_device *target) dev_proc_map_color_rgb((*to_rgb)) = dev_proc(dev, map_color_rgb); + /* The logic in this function seems a bit stale; it sets the + old-style color procs, but not the new ones + (get_color_mapping_procs, get_color_comp_index, encode_color, + and decode_color). It should probably copy those as well. + */ if (from_cmyk == gx_forward_map_cmyk_color || from_cmyk == cmyk_1bit_map_cmyk_color || from_cmyk == cmyk_8bit_map_cmyk_color) { |