summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2020-09-10 18:10:49 +0200
committerThomas Deutschmann <whissi@gentoo.org>2020-09-11 20:06:36 +0200
commitacfc02c1747065fe450c7cfeb6f1844b62335f08 (patch)
tree5887806a2e6b99bbb0255e013a9028810e230a7f /base/gstrans.c
parentImport Ghostscript 9.52 (diff)
downloadghostscript-gpl-patches-acfc02c1747065fe450c7cfeb6f1844b62335f08.tar.gz
ghostscript-gpl-patches-acfc02c1747065fe450c7cfeb6f1844b62335f08.tar.bz2
ghostscript-gpl-patches-acfc02c1747065fe450c7cfeb6f1844b62335f08.zip
Import Ghostscript 9.53ghostscript-9.53
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'base/gstrans.c')
-rw-r--r--base/gstrans.c117
1 files changed, 52 insertions, 65 deletions
diff --git a/base/gstrans.c b/base/gstrans.c
index 8c4fca30..cb3f2ce6 100644
--- a/base/gstrans.c
+++ b/base/gstrans.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2019 Artifex Software, Inc.
+/* Copyright (C) 2001-2020 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -40,7 +40,7 @@ gs_setblendmode(gs_gstate *pgs, gs_blend_mode_t mode)
if (gs_debug_c('v')) {
static const char *const bm_names[] = { GS_BLEND_MODE_NAMES };
- dmlprintf1(pgs->memory, "[v](0x%lx)blend_mode = ", (long)pgs);
+ dmlprintf1(pgs->memory, "[v]("PRI_INTPTR")blend_mode = ", (intptr_t)pgs);
if (mode >= 0 && mode < countof(bm_names))
dmprintf1(pgs->memory, "%s\n", bm_names[mode]);
else
@@ -65,38 +65,10 @@ gs_currentblendmode(const gs_gstate *pgs)
}
int
-gs_setopacityalpha(gs_gstate *pgs, double alpha)
-{
- if_debug2m('v', pgs->memory, "[v](0x%lx)opacity.alpha = %g\n", (ulong)pgs, alpha);
- pgs->opacity.alpha = (alpha < 0.0 ? 0.0 : alpha > 1.0 ? 1.0 : alpha);
- return 0;
-}
-
-float
-gs_currentopacityalpha(const gs_gstate *pgs)
-{
- return pgs->opacity.alpha;
-}
-
-int
-gs_setshapealpha(gs_gstate *pgs, double alpha)
-{
- if_debug2m('v', pgs->memory, "[v](0x%lx)shape.alpha = %g\n", (ulong)pgs, alpha);
- pgs->shape.alpha = (alpha < 0.0 ? 0.0 : alpha > 1.0 ? 1.0 : alpha);
- return 0;
-}
-
-float
-gs_currentshapealpha(const gs_gstate *pgs)
-{
- return pgs->shape.alpha;
-}
-
-int
gs_settextknockout(gs_gstate *pgs, bool knockout)
{
- if_debug2m('v', pgs->memory, "[v](0x%lx)text_knockout = %s\n",
- (ulong)pgs, (knockout ? "true" : "false"));
+ if_debug2m('v', pgs->memory, "[v]("PRI_INTPTR")text_knockout = %s\n",
+ (intptr_t)pgs, (knockout ? "true" : "false"));
pgs->text_knockout = knockout;
return 0;
}
@@ -193,15 +165,19 @@ gs_gstate_update_pdf14trans(gs_gstate * pgs, gs_pdf14trans_params_t * pparams)
}
void
-gs_trans_group_params_init(gs_transparency_group_params_t *ptgp)
+gs_trans_group_params_init(gs_transparency_group_params_t *ptgp, float opacity)
{
ptgp->ColorSpace = NULL; /* bogus, but can't do better */
ptgp->Isolated = false;
ptgp->Knockout = false;
+ ptgp->page_group = false;
ptgp->text_group = PDF14_TEXTGROUP_NO_BT;
ptgp->image_with_SMask = false;
ptgp->mask_id = 0;
ptgp->iccprofile = NULL;
+ ptgp->group_opacity = opacity;
+ ptgp->group_shape = 1.0;
+ ptgp->shade_group = false;
}
int
@@ -235,11 +211,14 @@ gs_begin_transparency_group(gs_gstate *pgs,
params.pdf14_op = group_type;
params.Isolated = ptgp->Isolated;
params.Knockout = ptgp->Knockout;
+ if (group_type == PDF14_BEGIN_TRANS_PAGE_GROUP)
+ params.page_group = true;
params.image_with_SMask = ptgp->image_with_SMask;
- params.opacity = pgs->opacity;
- params.shape = pgs->shape;
+ params.opacity = ptgp->group_opacity;
+ params.shape = ptgp->group_shape;
params.blend_mode = pgs->blend_mode;
params.text_group = ptgp->text_group;
+ params.shade_group = ptgp->shade_group;
/* This function is called during the c-list writer side.
Store some information so that we know what the color space is
so that we can adjust according later during the clist reader.
@@ -264,11 +243,14 @@ gs_begin_transparency_group(gs_gstate *pgs,
target device (process color model). Here we just want
to set it as a unknown type for clist writing, as we will take care
of using the parent group color space later during clist reading.
- */
-
+ Also, if the group was not isolated we MUST use the parent group
+ color space regardless of what the group color space is specified to be.
+ Note that the page group should always be isolated */
+ if (group_type == PDF14_BEGIN_TRANS_PAGE_GROUP)
+ params.Isolated = true;
if (ptgp->ColorSpace == NULL || params.Isolated != true) {
- params.group_color = UNKNOWN;
+ params.group_color_type = UNKNOWN;
params.group_color_numcomps = 0;
} else {
/* The /CS parameter was present. Use what was set. Currently
@@ -283,7 +265,7 @@ gs_begin_transparency_group(gs_gstate *pgs,
/* Blending space is ICC based. If we are doing c-list rendering
we will need to write this color space into the clist.
*/
- params.group_color = ICC;
+ params.group_color_type = ICC;
params.group_color_numcomps =
blend_color_space->cmm_icc_profile_data->num_comps;
/* Get the ICC profile */
@@ -306,12 +288,12 @@ gs_begin_transparency_group(gs_gstate *pgs,
/* We can end up here if we are in a deviceN color space and
we have a sep output device */
profile = NULL;
- params.group_color = DEVICEN;
+ params.group_color_type = DEVICEN;
params.group_color_numcomps = cs_num_components(blend_color_space);
break;
}
if (profile != NULL) {
- params.group_color = ICC;
+ params.group_color_type = ICC;
params.group_color_numcomps = profile->num_comps;
params.iccprofile = profile;
params.icc_hash = profile->hashcode;
@@ -323,16 +305,16 @@ gs_begin_transparency_group(gs_gstate *pgs,
static const char *const cs_names[] = {
GS_COLOR_SPACE_TYPE_NAMES
};
- dmlprintf6(pgs->memory, "[v](0x%lx)begin_transparency_group [%g %g %g %g] Num_grp_clr_comp = %d\n",
- (ulong)pgs, pbbox->p.x, pbbox->p.y, pbbox->q.x, pbbox->q.y,params.group_color_numcomps);
+ dmlprintf6(pgs->memory, "[v]("PRI_INTPTR")begin_transparency_group [%g %g %g %g] Num_grp_clr_comp = %d\n",
+ (intptr_t)pgs, pbbox->p.x, pbbox->p.y, pbbox->q.x, pbbox->q.y,params.group_color_numcomps);
if (ptgp->ColorSpace)
dmprintf1(pgs->memory, " CS = %s",
cs_names[(int)gs_color_space_get_index(ptgp->ColorSpace)]);
else
dmputs(pgs->memory, " (no CS)");
- dmprintf3(pgs->memory, " Isolated = %d Knockout = %d text_group = %d\n",
- ptgp->Isolated, ptgp->Knockout, ptgp->text_group);
+ dmprintf4(pgs->memory, " Isolated = %d Knockout = %d text_group = %d page_group = %d\n",
+ ptgp->Isolated, ptgp->Knockout, ptgp->text_group, ptgp->page_group);
}
#endif
params.bbox = *pbbox;
@@ -351,18 +333,21 @@ gx_begin_transparency_group(gs_gstate * pgs, gx_device * pdev,
return_error(gs_error_rangecheck);
tgp.Isolated = pparams->Isolated;
tgp.Knockout = pparams->Knockout;
+ tgp.page_group = pparams->page_group;
tgp.idle = pparams->idle;
tgp.mask_id = pparams->mask_id;
tgp.text_group = pparams->text_group;
+ tgp.shade_group = pparams->shade_group;
/* Needed so that we do proper blending */
- tgp.group_color = pparams->group_color;
+ tgp.group_color_type = pparams->group_color_type;
tgp.group_color_numcomps = pparams->group_color_numcomps;
tgp.iccprofile = pparams->iccprofile;
tgp.icc_hashcode = pparams->icc_hash;
- pgs->opacity.alpha = pparams->opacity.alpha;
- pgs->shape.alpha = pparams->shape.alpha;
+ tgp.group_opacity = pparams->opacity;
+ tgp.group_shape = pparams->shape;
+
pgs->blend_mode = pparams->blend_mode;
bbox = pparams->bbox;
#ifdef DEBUG
@@ -370,18 +355,20 @@ gx_begin_transparency_group(gs_gstate * pgs, gx_device * pdev,
static const char *const cs_names[] = {
GS_COLOR_SPACE_TYPE_NAMES
};
- dmlprintf6(pdev->memory, "[v](0x%lx)gx_begin_transparency_group [%g %g %g %g] Num_grp_clr_comp = %d\n",
- (ulong)pgs, bbox.p.x, bbox.p.y, bbox.q.x, bbox.q.y,
- pparams->group_color_numcomps);
+ dmlprintf6(pdev->memory, "[v]("PRI_INTPTR")gx_begin_transparency_group [%g %g %g %g] Num_grp_clr_comp = %d\n",
+ (intptr_t)pgs, bbox.p.x, bbox.p.y, bbox.q.x, bbox.q.y,
+ pparams->group_color_numcomps);
+ dmlprintf2(pdev->memory, " opacity = %g shape = %g\n", pparams->opacity, pparams->shape);
if (tgp.ColorSpace)
dmprintf1(pdev->memory, " CS = %s",
cs_names[(int)gs_color_space_get_index(tgp.ColorSpace)]);
else
dmputs(pdev->memory, " (no CS)");
- dmprintf2(pdev->memory, " Isolated = %d Knockout = %d\n",
- tgp.Isolated, tgp.Knockout);
+ dmprintf3(pdev->memory, " Isolated = %d Knockout = %d page_group = %d\n",
+ tgp.Isolated, tgp.Knockout, tgp.page_group);
if (tgp.iccprofile)
dmprintf(pdev->memory, " Have ICC Profile for blending\n");
+
}
#endif
return (*dev_proc(pdev, begin_transparency_group)) (pdev, &tgp, &bbox, pgs,
@@ -601,9 +588,9 @@ gs_begin_transparency_mask(gs_gstate * pgs,
return_error(gs_error_VMerror);
blend_color_space->cmm_icc_profile_data = pgs->icc_manager->default_gray;
gsicc_adjust_profile_rc(blend_color_space->cmm_icc_profile_data, 1, "gs_begin_transparency_mask");
- if_debug9m('v', pgs->memory, "[v](0x%lx)gs_begin_transparency_mask [%g %g %g %g]\n\
- subtype = %d Background_components = %d, Matte_components = %d, %s\n",
- (ulong)pgs, pbbox->p.x, pbbox->p.y, pbbox->q.x, pbbox->q.y,
+ if_debug9m('v', pgs->memory, "[v]("PRI_INTPTR")gs_begin_transparency_mask [%g %g %g %g]\n"
+ " subtype = %d Background_components = %d, Matte_components = %d, %s\n",
+ (intptr_t)pgs, pbbox->p.x, pbbox->p.y, pbbox->q.x, pbbox->q.y,
(int)ptmp->subtype, ptmp->Background_components,
ptmp->Matte_components,
(ptmp->TransferFunction == mask_transfer_identity ? "no TR" :
@@ -637,7 +624,7 @@ gs_begin_transparency_mask(gs_gstate * pgs,
if ( blend_color_space->cmm_icc_profile_data != NULL ) {
/* Blending space is ICC based. If we are doing c-list rendering we will
need to write this color space into the clist. */
- params.group_color = ICC;
+ params.group_color_type = ICC;
params.group_color_numcomps =
blend_color_space->cmm_icc_profile_data->num_comps;
/* Get the ICC profile */
@@ -647,7 +634,7 @@ gs_begin_transparency_mask(gs_gstate * pgs,
params.iccprofile = blend_color_space->cmm_icc_profile_data;
params.icc_hash = blend_color_space->cmm_icc_profile_data->hashcode;
} else {
- params.group_color = GRAY_SCALE;
+ params.group_color_type = GRAY_SCALE;
params.group_color_numcomps = 1; /* Need to check */
}
/* Explicitly decrement the profile data since blend_color_space may not
@@ -669,7 +656,7 @@ gx_begin_transparency_mask(gs_gstate * pgs, gx_device * pdev,
const int l = sizeof(pparams->Background[0]) * pparams->Background_components;
const int m = sizeof(pparams->Matte[0]) * pparams->Matte_components;
- tmp.group_color = pparams->group_color;
+ tmp.group_color_type = pparams->group_color_type;
tmp.subtype = pparams->subtype;
tmp.group_color_numcomps = pparams->group_color_numcomps;
tmp.Background_components = pparams->Background_components;
@@ -682,7 +669,7 @@ gx_begin_transparency_mask(gs_gstate * pgs, gx_device * pdev,
tmp.replacing = pparams->replacing;
tmp.mask_id = pparams->mask_id;
- if (tmp.group_color == ICC ) {
+ if (tmp.group_color_type == ICC ) {
/* Do I need to ref count here? */
tmp.iccprofile = pparams->iccprofile;
tmp.icc_hashcode = pparams->icc_hash;
@@ -692,9 +679,9 @@ gx_begin_transparency_mask(gs_gstate * pgs, gx_device * pdev,
}
memcpy(tmp.transfer_fn, pparams->transfer_fn, size_of(tmp.transfer_fn));
if_debug10m('v', pgs->memory,
- "[v](0x%lx)gx_begin_transparency_mask [%g %g %g %g]\n"
+ "[v]("PRI_INTPTR")gx_begin_transparency_mask [%g %g %g %g]\n"
" subtype = %d Background_components = %d Matte_components = %d Num_grp_clr_comp = %d %s\n",
- (ulong)pgs, pparams->bbox.p.x, pparams->bbox.p.y,
+ (intptr_t)pgs, pparams->bbox.p.x, pparams->bbox.p.y,
pparams->bbox.q.x, pparams->bbox.q.y,
(int)tmp.subtype, tmp.Background_components, tmp.Matte_components,
tmp.group_color_numcomps,
@@ -729,7 +716,7 @@ gs_end_transparency_mask(gs_gstate *pgs,
if_debug1m('v', pgs->memory,
"[v]xstate_changed set true, gstate level is %d\n", pgs->level);
if_debug2m('v', pgs->memory,
- "[v](0x%lx)gs_end_transparency_mask(%d)\n", (ulong)pgs,
+ "[v]("PRI_INTPTR")gs_end_transparency_mask(%d)\n", (intptr_t)pgs,
(int)csel);
params.pdf14_op = PDF14_END_TRANS_MASK; /* Other parameters not used */
params.csel = csel;
@@ -747,7 +734,7 @@ gx_end_transparency_mask(gs_gstate * pgs, gx_device * pdev,
const gs_pdf14trans_params_t * pparams)
{
if_debug2m('v', pgs->memory,
- "[v](0x%lx)gx_end_transparency_mask(%d)\n", (ulong)pgs,
+ "[v]("PRI_INTPTR")gx_end_transparency_mask(%d)\n", (intptr_t)pgs,
(int)pparams->csel);
return (*dev_proc(pdev, end_transparency_mask)) (pdev, pgs);
}
@@ -846,7 +833,7 @@ gs_abort_pdf14trans_device(gs_gstate * pgs)
int
gx_abort_trans_device(gs_gstate * pgs, gx_device * pdev)
{
- if_debug1m('v', pgs->memory, "[v](0x%lx)gx_abort_trans_device\n", (ulong)pgs);
+ if_debug1m('v', pgs->memory, "[v]("PRI_INTPTR")gx_abort_trans_device\n", (intptr_t)pgs);
return (*dev_proc(pdev, discard_transparency_layer)) (pdev, pgs);
}