summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vrhel <michael.vrhel@artifex.com>2019-12-07 12:29:38 -0800
committerMichael Vrhel <michael.vrhel@artifex.com>2020-01-10 09:37:28 -0800
commitb4090e581cb7af67e801bc838bdb4cf43986745f (patch)
treef20a42bc2ca6b6f8ed91634382b1efb994e2328b
parente8ea7f394c09d411729bd91dfa363df5041a9057 (diff)
downloadghostpdl-b4090e581cb7af67e801bc838bdb4cf43986745f.tar.gz
Make sure effective opm makes it to blend method
The effective opm can be different for the stroke color vs. the fill color. We need to make sure we are setting and picking the right one.
-rw-r--r--base/gdevp14.c8
-rw-r--r--base/gxblend.c22
2 files changed, 24 insertions, 6 deletions
diff --git a/base/gdevp14.c b/base/gdevp14.c
index 54df3d016..bf457a0a5 100644
--- a/base/gdevp14.c
+++ b/base/gdevp14.c
@@ -2949,7 +2949,7 @@ pdf14_set_marking_params(gx_device *dev, const gs_gstate *pgs)
pdev->blend_mode = pgs->blend_mode;
pdev->overprint = pgs->overprint;
pdev->effective_overprint_mode = pgs->color[!pgs->is_fill_color].effective_opm;
- pdev->stroke_effective_op_mode = pgs->color[!pgs->is_fill_color].effective_opm;
+ pdev->stroke_effective_op_mode = pgs->color[pgs->is_fill_color].effective_opm;
pdev->stroke_overprint = pgs->stroke_overprint;
pdev->fillconstantalpha = pgs->fillconstantalpha;
pdev->strokeconstantalpha = pgs->strokeconstantalpha;
@@ -4371,8 +4371,10 @@ pdf14_set_params(gs_gstate * pgs,
pgs->overprint = pparams->overprint;
if (pparams->changed & PDF14_SET_STROKEOVERPRINT)
pgs->stroke_overprint = pparams->stroke_overprint;
- if (pparams->changed & PDF14_SET_OVERPRINT_MODE)
- pgs->color[0].effective_opm = pparams->effective_overprint_mode;
+ if (pparams->changed & PDF14_SET_OVERPRINT_MODE) {
+ pgs->color[!pgs->is_fill_color].effective_opm = pparams->effective_overprint_mode;
+ pgs->color[pgs->is_fill_color].effective_opm = pparams->stroke_effective_op_mode;
+ }
if (pparams->changed & PDF14_SET_FILLCONSTANTALPHA)
pgs->fillconstantalpha = pparams->fillconstantalpha;
if (pparams->changed & PDF14_SET_STROKECONSTANTALPHA)
diff --git a/base/gxblend.c b/base/gxblend.c
index 6b97fdf22..73f0a82a5 100644
--- a/base/gxblend.c
+++ b/base/gxblend.c
@@ -1209,6 +1209,8 @@ art_blend_pixel_8_inline(byte *gs_restrict dst, const byte *gs_restrict backdrop
{
gx_color_index drawn_comps = p14dev->op_state == PDF14_OP_STATE_FILL ?
p14dev->drawn_comps_fill : p14dev->drawn_comps_stroke;
+ bool opm = p14dev->op_state == PDF14_OP_STATE_FILL ?
+ p14dev->effective_overprint_mode : p14dev->stroke_effective_op_mode;
gx_color_index comps;
/* If overprint mode is true and the current color space and
* the group color space are CMYK (or CMYK and spots), then
@@ -1267,7 +1269,7 @@ art_blend_pixel_8_inline(byte *gs_restrict dst, const byte *gs_restrict backdrop
the mixing of the source with the blend result. Essentially
replacing that mixing with the color we have here.
*/
- if (p14dev->effective_overprint_mode && p14dev->color_info.num_components > 3
+ if (opm && p14dev->color_info.num_components > 3
&& !(p14dev->ctx->additive)) {
for (i = 0; i < 4; i++) {
b = backdrop[i];
@@ -4587,6 +4589,7 @@ template_mark_fill_rect(int w, int h, byte *gs_restrict dst_ptr, byte *gs_restri
{
int i, j, k;
byte dst[PDF14_MAX_PLANES] = { 0 };
+ byte dest_alpha;
bool tag_blend = blend_mode == BLEND_MODE_Normal ||
blend_mode == BLEND_MODE_Compatible ||
blend_mode == BLEND_MODE_CompatibleOverprint;
@@ -4630,6 +4633,7 @@ template_mark_fill_rect(int w, int h, byte *gs_restrict dst_ptr, byte *gs_restri
}
}
dst[num_comp] = dst_ptr[num_comp * planestride];
+ dest_alpha = dst[num_comp];
pdst = art_pdf_composite_pixel_alpha_8_inline(dst, src, num_comp, blend_mode, first_blend_spot,
pdev->blend_procs, pdev);
/* Post blend complement for subtractive and handling of drawncomps
@@ -4641,10 +4645,22 @@ template_mark_fill_rect(int w, int h, byte *gs_restrict dst_ptr, byte *gs_restri
dst_ptr[k * planestride] = 255 - pdst[k];
} else if (!additive && overprint) {
int comps;
-
- for (k = 0, comps = drawn_comps; comps != 0; ++k, comps >>= 1) {
+ /* If this is an overprint case, and alpha_r is different
+ than alpha_d then we will need to adjust
+ the colors of the non-drawn components here too */
+ for (k = 0, comps = drawn_comps; k < num_comp; ++k, comps >>= 1) {
if ((comps & 0x1) != 0) {
dst_ptr[k * planestride] = 255 - pdst[k];
+ } else if (dest_alpha != pdst[num_comp]) {
+ /* We need val_new = (val_old * old_alpha) / new_alpha */
+ if (pdst[num_comp] != 0) {
+ int val = (int)floor(((float)dest_alpha / (float)pdst[num_comp]) * (255 - pdst[k]) + 0.5);
+ if (val < 0)
+ val = 0;
+ else if (val > 255)
+ val = 255;
+ dst_ptr[k * planestride] = val;
+ }
}
}
} else {