diff options
author | Michael Vrhel <michael.vrhel@artifex.com> | 2022-02-23 22:00:07 -0800 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2022-03-01 08:10:26 +0000 |
commit | c5f08bcad22abcc071bf77cefe23f65e15fa21ec (patch) | |
tree | 50c22702d75e3626c43c7a527126ee3b952363d5 | |
parent | 0584203526f049d2bb181f260bcfb6adf92f1078 (diff) | |
download | ghostpdl-c5f08bcad22abcc071bf77cefe23f65e15fa21ec.tar.gz |
Fix segfault issues with simulate overprint
When simulate overprint is set for a sep device, there is no
need to do a simulation as the device already supports spot
color overprinting. This will change in the future for cases
dealing with rendering to the output intent but the target
device uses a different ICC profile. This issue occurred only
with pdfi.
There was also a problem with the use of patterns in the
case where we are doing overprint simulation. If the pattern
accumulator target is the pdf14 device and we are doing
overprint simulation, then it is necessary
that the pattern accumulator uses transparency. This problem
occurs for the old PDF interpreter and pdfi. This commit
fixes the issue for pdfi. The old PDF interpreter needs an
additional fix.
Example command line with issues
-sDEVICE=bitrgbtags -dMaxBitmap=10000000000 -dNEWPDF=true/false -dOverprint=/simulate -r72 -o testout.ppm -f Bug693541.pdf
-rw-r--r-- | base/gdevdflt.c | 3 | ||||
-rw-r--r-- | base/gdevp14.c | 12 | ||||
-rw-r--r-- | base/gstrans.c | 20 | ||||
-rw-r--r-- | base/gxdevsop.h | 10 | ||||
-rw-r--r-- | base/gxpcmap.c | 2 | ||||
-rw-r--r-- | pdf/pdf_pattern.c | 14 | ||||
-rw-r--r-- | pdf/pdf_trans.c | 2 | ||||
-rw-r--r-- | psi/zpcolor.c | 4 |
8 files changed, 50 insertions, 17 deletions
diff --git a/base/gdevdflt.c b/base/gdevdflt.c index 413bb1444..3e680f65b 100644 --- a/base/gdevdflt.c +++ b/base/gdevdflt.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2021 Artifex Software, Inc. +/* Copyright (C) 2001-2022 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or @@ -971,6 +971,7 @@ gx_default_dev_spec_op(gx_device *pdev, int dev_spec_op, void *data, int size) case gxdso_supports_alpha: case gxdso_pdf14_sep_device: case gxdso_supports_pattern_transparency: + case gxdso_overprintsim_state: return 0; case gxdso_pattern_shfill_doesnt_need_path: return (dev_proc(pdev, fill_path) == gx_default_fill_path); diff --git a/base/gdevp14.c b/base/gdevp14.c index 3863fc88f..00e4bf797 100644 --- a/base/gdevp14.c +++ b/base/gdevp14.c @@ -8554,7 +8554,17 @@ pdf14_dev_spec_op(gx_device *pdev, int dev_spec_op, if (dev_spec_op == gxdso_interpolate_threshold) return p14dev->interpolate_threshold; - return dev_proc(p14dev->target, dev_spec_op)(p14dev->target, dev_spec_op, data, size); + if (dev_spec_op == gxdso_overprintsim_state) { + unsigned char *data_uchar = (unsigned char *) data; + data_uchar[0] = (unsigned char) p14dev->overprint_sim; + if (p14dev->ctx != NULL) + data_uchar[1] = (unsigned char)p14dev->ctx->num_spots; /* pdf14 page device */ + else + data_uchar[1] = (unsigned char)p14dev->devn_params.page_spot_colors; /* pdf14 clist device */ + return 1; + } + + return dev_proc(p14dev->target, dev_spec_op)(p14dev->target, dev_spec_op, data, size); } /* Needed to set color monitoring in the target device's profile */ diff --git a/base/gstrans.c b/base/gstrans.c index d810524a0..42207f995 100644 --- a/base/gstrans.c +++ b/base/gstrans.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2021 Artifex Software, Inc. +/* Copyright (C) 2001-2022 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or @@ -31,6 +31,7 @@ #include "gxclist.h" #include "gsicc_manage.h" #include "gsicc_cache.h" +#include "gxdevsop.h" /* ------ Transparency-related graphics state elements ------ */ @@ -789,6 +790,7 @@ gs_push_pdf14trans_device(gs_gstate * pgs, bool is_pattern, bool retain, gsicc_rendering_param_t render_cond; int code; cmm_dev_profile_t *dev_profile; + unsigned char pattern_opsim_setting[2]; code = dev_proc(pgs->device, get_profile)(pgs->device, &dev_profile); if (code < 0) @@ -805,10 +807,18 @@ gs_push_pdf14trans_device(gs_gstate * pgs, bool is_pattern, bool retain, params.num_spot_colors = get_num_pdf14_spot_colors(pgs); params.is_pattern = is_pattern; - /* Information related to overprint simulation */ - params.num_spot_colors_int = spot_color_count; - if (depth < 0) - params.overprint_sim_push = true; + /* If pattern, get overprint simulation information from + the pattern accumulators target device */ + if (is_pattern && dev_proc(pgs->device, dev_spec_op)(pgs->device, gxdso_overprintsim_state, &pattern_opsim_setting, sizeof(pattern_opsim_setting))) { + /* Use the target device setting */ + params.overprint_sim_push = pattern_opsim_setting[0]; + params.num_spot_colors_int = pattern_opsim_setting[1]; + } else { + /* Use information from interpreter */ + params.num_spot_colors_int = spot_color_count; + if (depth < 0) + params.overprint_sim_push = true; + } /* If we have an NCLR ICC profile, the extra spot colorants do not get included in the transparency buffers. This is also true diff --git a/base/gxdevsop.h b/base/gxdevsop.h index 0131d0e21..cfde902ab 100644 --- a/base/gxdevsop.h +++ b/base/gxdevsop.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2021 Artifex Software, Inc. +/* Copyright (C) 2001-2022 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or @@ -442,6 +442,14 @@ enum { /* Determine if a given device is a null device. Returns 1 if it is. */ gxdso_is_null_device, + /* Get information about pdf14 device overprint simulation state + * data = unsigned char[2], [0] is overprint_sim_push [1] is num_spot_colors_int + * size = sizeof(unsigned char[2]) + * Returns 1 if returned values are valid + * 0 otherwise. + */ + gxdso_overprintsim_state, + /* Add new gxdso_ keys above this. */ gxdso_pattern__LAST }; diff --git a/base/gxpcmap.c b/base/gxpcmap.c index a042b2b56..ae79987f0 100644 --- a/base/gxpcmap.c +++ b/base/gxpcmap.c @@ -1491,7 +1491,7 @@ gx_pattern_load(gx_device_color * pdc, const gs_gstate * pgs, goto fail; if (pinst->templat.uses_transparency) { if_debug0m('v', mem, "gx_pattern_load: pushing the pdf14 compositor device into this graphics state\n"); - if ((code = gs_push_pdf14trans_device(saved, true, false, 0, 0)) < 0) /* FIXME: do we need spot_color_count ??? */ + if ((code = gs_push_pdf14trans_device(saved, true, false, 0, 0)) < 0) /* spot_color_count taken from pdf14 target values */ return code; saved->device->is_open = true; } else { diff --git a/pdf/pdf_pattern.c b/pdf/pdf_pattern.c index 8137e624f..57a164493 100644 --- a/pdf/pdf_pattern.c +++ b/pdf/pdf_pattern.c @@ -483,11 +483,15 @@ pdfi_setpattern_type1(pdf_context *ctx, pdf_dict *stream_dict, pdf_dict *page_di goto exit; } - /* See if pattern uses transparency */ - if (ctx->page.has_transparency) { - code = pdfi_check_Pattern_transparency(ctx, pdict, page_dict, &transparency); - if (code < 0) - goto exit; + /* See if pattern uses transparency, or if we are in an overprint + simulation situation */ + if (ctx->page.simulate_op) + transparency = true; + else + if (ctx->page.has_transparency) { + code = pdfi_check_Pattern_transparency(ctx, pdict, page_dict, &transparency); + if (code < 0) + goto exit; } /* TODO: Resources? Maybe I should check that they are all valid before proceeding, or something? */ diff --git a/pdf/pdf_trans.c b/pdf/pdf_trans.c index 2d1f8e399..215fbac16 100644 --- a/pdf/pdf_trans.c +++ b/pdf/pdf_trans.c @@ -606,7 +606,7 @@ void pdfi_trans_set_needs_OP(pdf_context *ctx) case PDF_OVERPRINT_SIMULATE: if (!device_transparency && ctx->page.has_OP) { if (is_cmyk) { - if (ctx->page.num_spots > 0) { + if (ctx->page.num_spots > 0 && !ctx->device_state.spot_capable) { ctx->page.needs_OP = true; ctx->page.simulate_op = true; } diff --git a/psi/zpcolor.c b/psi/zpcolor.c index 81a94ddf2..93d6050a6 100644 --- a/psi/zpcolor.c +++ b/psi/zpcolor.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2021 Artifex Software, Inc. +/* Copyright (C) 2001-2022 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or @@ -245,7 +245,7 @@ pattern_paint_prepare(i_ctx_t *i_ctx_p) gs_setdevice_no_init(pgs, (gx_device *)pdev); if (pinst->templat.uses_transparency) { if_debug0m('v', imemory, " pushing the pdf14 compositor device into this graphics state\n"); - if ((code = gs_push_pdf14trans_device(pgs, true, true, 0, 0)) < 0) /* FIXME: do we need spot_color_count ??? */ + if ((code = gs_push_pdf14trans_device(pgs, true, true, 0, 0)) < 0) /* spot color count found from pdf14 target */ return code; } else { /* not transparent */ if (pinst->templat.PaintType == 1 && !(pinst->is_clist) |