summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gs/base/gdevp14.c4
-rw-r--r--gs/base/gscdevn.c2
-rw-r--r--gs/base/gscms.h10
-rw-r--r--gs/base/gscsepr.c2
-rw-r--r--gs/base/gsicc.c6
-rw-r--r--gs/base/gsicc_cache.c23
-rw-r--r--gs/base/gsicc_cms.h2
-rw-r--r--gs/base/gsicc_manage.c49
-rw-r--r--gs/base/gsicc_manage.h1
-rw-r--r--gs/base/gsicc_nocm.c6
-rw-r--r--gs/base/gsicc_replacecm.c372
-rw-r--r--gs/base/gxclimag.c10
-rw-r--r--gs/base/gxcmap.c4
-rw-r--r--gs/base/gxi12bit.c2
-rw-r--r--gs/base/gxicolor.c2
-rw-r--r--gs/base/gximono.c2
-rw-r--r--gs/base/gxiscale.c2
-rw-r--r--gs/base/gxshade.c2
-rw-r--r--gs/base/lib.mak9
-rw-r--r--gs/ghostscript.vcproj6
-rw-r--r--xps/xpsgradient.c2
21 files changed, 466 insertions, 52 deletions
diff --git a/gs/base/gdevp14.c b/gs/base/gdevp14.c
index 9a79b8993..4c910b966 100644
--- a/gs/base/gdevp14.c
+++ b/gs/base/gdevp14.c
@@ -906,7 +906,7 @@ pdf14_pop_transparency_group(gs_imager_state *pis, pdf14_ctx *ctx,
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = gsPERCEPTUAL;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
/* Request the ICC link for the transform that we will need to use */
/* Note that if pis is NULL we assume the same color space. This
is due to a call to pop the group from fill_mask when filling
@@ -1277,7 +1277,7 @@ pdf14_pop_transparency_mask(pdf14_ctx *ctx, gs_imager_state *pis, gx_device *dev
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = gsPERCEPTUAL;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
icc_link = gsicc_get_link_profile(pis, dev, des_profile,
src_profile, &rendering_params, pis->memory, false);
smask_icc(dev, tos->rect.q.y - tos->rect.p.y,
diff --git a/gs/base/gscdevn.c b/gs/base/gscdevn.c
index 4940a138d..900e14e16 100644
--- a/gs/base/gscdevn.c
+++ b/gs/base/gscdevn.c
@@ -433,7 +433,7 @@ gx_concretize_DeviceN(const gs_client_color * pc, const gs_color_space * pcs,
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = pis->renderingintent;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
/* Allocate and initialize name structure */
named_color =
diff --git a/gs/base/gscms.h b/gs/base/gscms.h
index 3e106a16f..c37c77cfb 100644
--- a/gs/base/gscms.h
+++ b/gs/base/gscms.h
@@ -142,6 +142,14 @@ typedef enum {
gsBPNOTSPECIFIED = 8 /* Used to ignore value when source based setting */
} gsicc_blackptcomp_t;
+/* This is used mainly for when the sourcegtag option specifies us to use no
+ color management or a replacement color management CMM */
+typedef enum {
+ gsCMM_DEFAULT = 0,
+ gsCMM_NONE,
+ gsCMM_REPLACE
+} gsicc_cmm_t;
+
/* Since this is not specified by the source document we don't need to worry
about override values */
typedef enum {
@@ -191,7 +199,7 @@ typedef struct gsicc_rendering_param_s {
gsicc_blackptcomp_t black_point_comp; /* Black point compensation */
gsicc_blackpreserve_t preserve_black; /* preserve K plane in CMYK2CMYK */
gs_graphics_type_tag_t graphics_type_tag; /* Some CMM may want this */
- bool use_cm; /* use color management (used only with sourcetag) */
+ gsicc_cmm_t cmm; /* which cmm? (used only with sourcetag) */
bool override_icc; /* Override source ICC (used only with sourcetag) */
} gsicc_rendering_param_t;
diff --git a/gs/base/gscsepr.c b/gs/base/gscsepr.c
index 5552fb362..152ee4afb 100644
--- a/gs/base/gscsepr.c
+++ b/gs/base/gscsepr.c
@@ -334,7 +334,7 @@ gx_concretize_Separation(const gs_client_color *pc, const gs_color_space *pcs,
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = pis->renderingintent;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
pcs->params.separation.get_colorname_string(pis->memory, name,
&pname, &name_size);
/* Make the name structure and initialized it */
diff --git a/gs/base/gsicc.c b/gs/base/gsicc.c
index 0717e62b4..db6dfe299 100644
--- a/gs/base/gsicc.c
+++ b/gs/base/gsicc.c
@@ -360,7 +360,7 @@ gx_remap_ICC(const gs_client_color * pcc, const gs_color_space * pcs,
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = pis->renderingintent;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
/* Need to clear out psrc_cm in case we have separation bands that are
not color managed */
memset(psrc_cm,0,sizeof(unsigned short)*GS_CLIENT_COLOR_MAX_COMPONENTS);
@@ -449,7 +449,7 @@ gx_remap_ICC_imagelab(const gs_client_color * pcc, const gs_color_space * pcs,
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = pis->renderingintent;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
/* Need to clear out psrc_cm in case we have separation bands that are
not color managed */
memset(psrc_cm,0,sizeof(unsigned short)*GS_CLIENT_COLOR_MAX_COMPONENTS);
@@ -516,7 +516,7 @@ gx_concretize_ICC(
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = pis->renderingintent;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
for (k = 0; k < pcs->cmm_icc_profile_data->num_comps; k++) {
psrc[k] = (unsigned short) (pcc->paint.values[k]*65535.0);
}
diff --git a/gs/base/gsicc_cache.c b/gs/base/gsicc_cache.c
index 7a5c3b9e8..cb2180b82 100644
--- a/gs/base/gsicc_cache.c
+++ b/gs/base/gsicc_cache.c
@@ -303,7 +303,7 @@ gsicc_compute_linkhash(gsicc_manager_t *icc_manager, gx_device *dev,
point in time, we only include the black point setting, the intent
and if we are preserving black. We don't differentiate at this time
with object type since the current CMM does not create different
- links based upon this type setting. Other parameters such as use_cm
+ links based upon this type setting. Other parameters such as cmm
and override ICC are used prior to a link creation and so should also
not factor into the link hash calculation */
hash->rend_hash = ((rendering_params->black_point_comp) << BP_SHIFT) +
@@ -528,8 +528,9 @@ gsicc_get_link(const gs_imager_state *pis, gx_device *dev_in,
/* In this case we may be wanting for a "unmanaged color"
result. This is done by specifying "None" on the
particular line for that source object. Check if this
- is what is desired. If it is, then return the link now */
- if (render_cond.use_cm == false) {
+ is what is desired. If it is, then return the link now.
+ Also need to worry about the replace case */
+ if (render_cond.cmm == gsCMM_NONE) {
gsicc_link_t *link;
if (gs_input_profile->data_cs == gsRGB) {
@@ -545,6 +546,10 @@ gsicc_get_link(const gs_imager_state *pis, gx_device *dev_in,
}
return link;
}
+ } else if (render_cond.cmm == gsCMM_REPLACE) {
+ return gsicc_rcm_get_link(pis, dev,
+ gs_input_profile->data_cs);
+ /* Note that there is never an identity case */
}
}
}
@@ -737,9 +742,10 @@ gsicc_get_link_profile(const gs_imager_state *pis, gx_device *dev,
due to a setting forced from srcgtag object (the None option)
which has made its way though the clist in the clist imaging
code. In this case, the srcgtag_profile structure
- which was part of the ICC manager is no longer available */
+ which was part of the ICC manager is no longer available.
+ We also have the Replace option. */
if (gs_input_profile->rend_is_valid &&
- gs_input_profile->rend_cond.use_cm == false) {
+ gs_input_profile->rend_cond.cmm == gsCMM_NONE) {
if (gs_input_profile->data_cs == gsRGB) {
link = gsicc_nocm_get_link(pis, dev, 3);
@@ -754,7 +760,12 @@ gsicc_get_link_profile(const gs_imager_state *pis, gx_device *dev,
}
return link;
}
- }
+ } else if (gs_input_profile->rend_is_valid &&
+ gs_input_profile->rend_cond.cmm == gsCMM_REPLACE) {
+ return gsicc_rcm_get_link(pis, dev, gs_input_profile->data_cs);
+ /* Note that there is never an identity case for
+ this type. */
+ }
/* We may have a source profile that is a device link profile and
made its way through the clist. If so get things set up to
handle that properly. */
diff --git a/gs/base/gsicc_cms.h b/gs/base/gsicc_cms.h
index b317a013e..65e1ec48e 100644
--- a/gs/base/gsicc_cms.h
+++ b/gs/base/gsicc_cms.h
@@ -34,6 +34,8 @@
/* Prototypes */
+gsicc_link_t* gsicc_rcm_get_link(const gs_imager_state *pis, gx_device *dev,
+ gsicc_colorbuffer_t data_cs);
gsicc_link_t* gsicc_nocm_get_link(const gs_imager_state *pis, gx_device *dev,
gs_color_space_index src_index);
gcmmhprofile_t gscms_get_profile_handle_mem(gs_memory_t *mem,
diff --git a/gs/base/gsicc_manage.c b/gs/base/gsicc_manage.c
index e144dc808..ebe082033 100644
--- a/gs/base/gsicc_manage.c
+++ b/gs/base/gsicc_manage.c
@@ -505,7 +505,7 @@ gsicc_set_srcgtag_struct(gsicc_manager_t *icc_manager, const char* pname,
cmm_profile_t *icc_profile;
cmm_srcgtag_profile_t *srcgtag;
bool start = true;
- bool use_cm = true;
+ gsicc_cmm_t cmm = gsCMM_DEFAULT;
/* If we don't have an icc manager or if this thing is already set
then ignore the call. For now, I am going to allow it to
@@ -553,8 +553,8 @@ gsicc_set_srcgtag_struct(gsicc_manager_t *icc_manager, const char* pname,
source type. Else if we have no profile and don't want color
management we will make sure to do that */
for (k = 0; k < NUM_SOURCE_PROFILES; k++) {
- srcgtag->rgb_rend_cond[k].use_cm = true;
- srcgtag->cmyk_rend_cond[k].use_cm = true;
+ srcgtag->rgb_rend_cond[k].cmm = gsCMM_DEFAULT;
+ srcgtag->cmyk_rend_cond[k].cmm = gsCMM_DEFAULT;
}
while (start || strlen(curr_ptr) > 0) {
if (start) {
@@ -568,11 +568,18 @@ gsicc_set_srcgtag_struct(gsicc_manager_t *icc_manager, const char* pname,
for (k = 0; k < GSICC_NUM_SRCGTAG_KEYS; k++) {
if (strncmp(curr_ptr, srcgtag_keys[k], strlen(srcgtag_keys[k])) == 0 ) {
/* Check if the curr_ptr is None which indicates that this
- object is not to be color managed. */
+ object is not to be color managed. Also, if the
+ curr_ptr is Replace which indicates we will be doing
+ direct replacement of the colors. */
curr_ptr = strtok(NULL, "\t,\32\n\r");
if (strncmp(curr_ptr, GSICC_SRCTAG_NOCM, strlen(GSICC_SRCTAG_NOCM)) == 0 &&
strlen(curr_ptr) == strlen(GSICC_SRCTAG_NOCM)) {
- use_cm = false;
+ cmm = gsCMM_NONE;
+ icc_profile = NULL;
+ break;
+ } else if ((strncmp(curr_ptr, GSICC_SRCTAG_REPLACE, strlen(GSICC_SRCTAG_REPLACE)) == 0 &&
+ strlen(curr_ptr) == strlen(GSICC_SRCTAG_REPLACE))) {
+ cmm = gsCMM_REPLACE;
icc_profile = NULL;
break;
} else {
@@ -585,7 +592,7 @@ gsicc_set_srcgtag_struct(gsicc_manager_t *icc_manager, const char* pname,
gsicc_profile_new(str, mem, curr_ptr, strlen(curr_ptr));
code = sfclose(str);
gsicc_init_profile_info(icc_profile);
- use_cm = true;
+ cmm = gsCMM_DEFAULT;
/* Check if this object is a devicelink profile.
If it is then the intent, blackpoint etc. are not
read nor used when dealing with these profiles */
@@ -610,43 +617,43 @@ gsicc_set_srcgtag_struct(gsicc_manager_t *icc_manager, const char* pname,
break;
case GRAPHIC_CMYK:
srcgtag->cmyk_profiles[gsSRC_GRAPPRO] = icc_profile;
- srcgtag->cmyk_rend_cond[gsSRC_GRAPPRO].use_cm = use_cm;
- if (use_cm) {
+ srcgtag->cmyk_rend_cond[gsSRC_GRAPPRO].cmm = cmm;
+ if (cmm == gsCMM_DEFAULT) {
gsicc_fill_srcgtag_item(&(srcgtag->cmyk_rend_cond[gsSRC_GRAPPRO]), true);
}
break;
case IMAGE_CMYK:
srcgtag->cmyk_profiles[gsSRC_IMAGPRO] = icc_profile;
- srcgtag->cmyk_rend_cond[gsSRC_IMAGPRO].use_cm = use_cm;
- if (use_cm) {
+ srcgtag->cmyk_rend_cond[gsSRC_IMAGPRO].cmm = cmm;
+ if (cmm == gsCMM_DEFAULT) {
gsicc_fill_srcgtag_item(&(srcgtag->cmyk_rend_cond[gsSRC_IMAGPRO]), true);
}
break;
case TEXT_CMYK:
srcgtag->cmyk_profiles[gsSRC_TEXTPRO] = icc_profile;
- srcgtag->cmyk_rend_cond[gsSRC_TEXTPRO].use_cm = use_cm;
- if (use_cm) {
+ srcgtag->cmyk_rend_cond[gsSRC_TEXTPRO].cmm = cmm;
+ if (cmm == gsCMM_DEFAULT) {
gsicc_fill_srcgtag_item(&(srcgtag->cmyk_rend_cond[gsSRC_TEXTPRO]), true);
}
break;
case GRAPHIC_RGB:
srcgtag->rgb_profiles[gsSRC_GRAPPRO] = icc_profile;
- srcgtag->rgb_rend_cond[gsSRC_GRAPPRO].use_cm = use_cm;
- if (use_cm) {
+ srcgtag->rgb_rend_cond[gsSRC_GRAPPRO].cmm = cmm;
+ if (cmm == gsCMM_DEFAULT) {
gsicc_fill_srcgtag_item(&(srcgtag->rgb_rend_cond[gsSRC_GRAPPRO]), false);
}
break;
case IMAGE_RGB:
srcgtag->rgb_profiles[gsSRC_IMAGPRO] = icc_profile;
- srcgtag->rgb_rend_cond[gsSRC_IMAGPRO].use_cm = use_cm;
- if (use_cm) {
+ srcgtag->rgb_rend_cond[gsSRC_IMAGPRO].cmm = cmm;
+ if (cmm == gsCMM_DEFAULT) {
gsicc_fill_srcgtag_item(&(srcgtag->rgb_rend_cond[gsSRC_IMAGPRO]), false);
}
break;
case TEXT_RGB:
srcgtag->rgb_profiles[gsSRC_TEXTPRO] = icc_profile;
- srcgtag->rgb_rend_cond[gsSRC_TEXTPRO].use_cm = use_cm;
- if (use_cm) {
+ srcgtag->rgb_rend_cond[gsSRC_TEXTPRO].cmm = cmm;
+ if (cmm == gsCMM_DEFAULT) {
gsicc_fill_srcgtag_item(&(srcgtag->rgb_rend_cond[gsSRC_TEXTPRO]), false);
}
break;
@@ -1056,12 +1063,12 @@ gsicc_new_srcgtag_profile(gs_memory_t *memory)
result->rgb_rend_cond[k].rendering_intent = gsRINOTSPECIFIED;
result->rgb_rend_cond[k].override_icc = false;
result->rgb_rend_cond[k].preserve_black = gsBKPRESNOTSPECIFIED;
- result->rgb_rend_cond[k].use_cm = true;
+ result->rgb_rend_cond[k].cmm = gsCMM_DEFAULT;
result->cmyk_rend_cond[k].black_point_comp = gsBPNOTSPECIFIED;
result->cmyk_rend_cond[k].rendering_intent = gsRINOTSPECIFIED;
result->cmyk_rend_cond[k].override_icc = false;
result->cmyk_rend_cond[k].preserve_black = gsBKPRESNOTSPECIFIED;
- result->cmyk_rend_cond[k].use_cm = true;
+ result->cmyk_rend_cond[k].cmm = gsCMM_DEFAULT;
}
result->color_warp_profile = NULL;
result->name = NULL;
@@ -1155,7 +1162,7 @@ gsicc_new_device_profile_array(gs_memory_t *memory)
result->rendercond[k].override_icc = false;
result->rendercond[k].preserve_black = gsBLACKPRESERVE_OFF;
result->rendercond[k].graphics_type_tag = GS_UNKNOWN_TAG;
- result->rendercond[k].use_cm = true;
+ result->rendercond[k].cmm = gsCMM_DEFAULT;
}
result->proof_profile = NULL;
result->link_profile = NULL;
diff --git a/gs/base/gsicc_manage.h b/gs/base/gsicc_manage.h
index 47e35dccd..22d3c3399 100644
--- a/gs/base/gsicc_manage.h
+++ b/gs/base/gsicc_manage.h
@@ -55,6 +55,7 @@ typedef enum {
} gsicc_srcgtagkey_t;
#define GSICC_SRCTAG_NOCM "None"
+#define GSICC_SRCTAG_REPLACE "Replace"
#define GSICC_SRCGTAG_KEYS\
"ColorTune", "Graphic_CMYK", "Image_CMYK", "Text_CMYK",\
diff --git a/gs/base/gsicc_nocm.c b/gs/base/gsicc_nocm.c
index 6bae9ce24..8b2a3538f 100644
--- a/gs/base/gsicc_nocm.c
+++ b/gs/base/gsicc_nocm.c
@@ -297,6 +297,7 @@ static void
gsicc_nocm_freelink(gsicc_link_t *icclink)
{
nocm_link_t *nocm_link = (nocm_link_t*) icclink->link_handle;
+
if (nocm_link->pis != NULL) {
if (nocm_link->pis->black_generation != NULL) {
gs_free_object(nocm_link->memory, nocm_link->pis->black_generation,
@@ -308,6 +309,7 @@ gsicc_nocm_freelink(gsicc_link_t *icclink)
}
gs_free_object(nocm_link->memory, nocm_link->pis, "gsicc_nocm_freelink");
}
+ gs_free_object(nocm_link->memory, nocm_link, "gsicc_nocm_freelink");
}
/* Since this is the only occurence of this object we are not going to
@@ -355,10 +357,10 @@ gsicc_nocm_get_link(const gs_imager_state *pis, gx_device *dev,
Since the link is not GC we would need to copy the contents over
each time a link was requested. This could be costly if we had
a lot of link requests. */
- hash.rend_hash = 0;
+ hash.rend_hash = gsCMM_NONE;
hash.des_hash = dev->color_info.num_components;
hash.src_hash = src_index;
- hash.link_hashcode = src_index + hash.des_hash * 256;
+ hash.link_hashcode = src_index + hash.des_hash * 256 + hash.rend_hash * 4096;
/* Check the cache for a hit. */
result = gsicc_findcachelink(hash, pis->icc_link_cache, false, false);
diff --git a/gs/base/gsicc_replacecm.c b/gs/base/gsicc_replacecm.c
new file mode 100644
index 000000000..1a7c9e667
--- /dev/null
+++ b/gs/base/gsicc_replacecm.c
@@ -0,0 +1,372 @@
+/* Copyright (C) 2001-2012 Artifex Software, Inc.
+ All Rights Reserved.
+
+ This software is provided AS-IS with no warranty, either express or
+ implied.
+
+ This software is distributed under license and may not be copied,
+ modified or distributed except as expressly authorized under the terms
+ of the license contained in the file LICENSE in this distribution.
+
+ Refer to licensing information at http://www.artifex.com or contact
+ Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael,
+ CA 94903, U.S.A., +1(415)492-9861, for further information.
+*/
+
+
+/* gsicc handling for direct color replacement. */
+
+#include "std.h"
+#include "string_.h"
+#include "stdpre.h"
+#include "gstypes.h"
+#include "gsmemory.h"
+#include "gsstruct.h"
+#include "scommon.h"
+#include "strmio.h"
+#include "gx.h"
+#include "gxistate.h"
+#include "gxcspace.h"
+#include "gsicc_cms.h"
+#include "gsicc_cache.h"
+
+/* A link structure for our replace color transform */
+typedef struct rcm_link_s {
+ byte num_out;
+ byte num_in;
+ gsicc_colorbuffer_t data_cs_in;
+ gs_memory_t *memory;
+ gx_cm_color_map_procs cm_procs; /* for the demo */
+ void *context; /* For a table and or a set of procs */
+} rcm_link_t;
+
+static void gsicc_rcm_transform_general(gx_device *dev, gsicc_link_t *icclink,
+ void *inputcolor, void *outputcolor,
+ int num_bytes_in, int num_bytes_out);
+
+/* Functions that should be optimized later to do planar/chunky with
+ color conversions. Just putting in something that should work
+ right now */
+static void
+gsicc_rcm_planar_to_planar(gx_device *dev, gsicc_link_t *icclink,
+ gsicc_bufferdesc_t *input_buff_desc,
+ gsicc_bufferdesc_t *output_buff_desc,
+ void *inputbuffer, void *outputbuffer)
+{
+ int k, j;
+ byte *inputpos[4];
+ byte *outputpos[4];
+ byte *in_buffer_ptr = (byte *) inputbuffer;
+ byte *out_buffer_ptr = (byte *) outputbuffer;
+ byte in_color[4], out_color[4];
+
+ for (k = 0; k < input_buff_desc->num_chan; k++) {
+ inputpos[k] = in_buffer_ptr + k * input_buff_desc->plane_stride;
+ }
+ for (k = 0; k < output_buff_desc->num_chan; k++) {
+ outputpos[k] = out_buffer_ptr + k * input_buff_desc->plane_stride;
+ }
+ /* Note to self. We currently only do this in the transparency buffer
+ case which has byte representation so just stepping through
+ plane_stride is ok at this time. */
+ for (k = 0; k < input_buff_desc->plane_stride ; k++) {
+ for (j = 0; j < input_buff_desc->num_chan; j++) {
+ in_color[j] = *(inputpos[j]);
+ inputpos[j] += input_buff_desc->bytes_per_chan;
+ }
+ gsicc_rcm_transform_general(dev, icclink, (void*) &(in_color[0]),
+ (void*) &(out_color[0]), 1, 1);
+ for (j = 0; j < output_buff_desc->num_chan; j++) {
+ *(outputpos[j]) = out_color[j];
+ outputpos[j] += output_buff_desc->bytes_per_chan;
+ }
+ }
+}
+
+/* This is not really used yet */
+static void
+gsicc_rcm_planar_to_chunky(gx_device *dev, gsicc_link_t *icclink,
+ gsicc_bufferdesc_t *input_buff_desc,
+ gsicc_bufferdesc_t *output_buff_desc,
+ void *inputbuffer, void *outputbuffer)
+{
+
+
+}
+
+/* This is used with the fast thresholding code when doing -dUseFastColor
+ and going out to a planar device */
+static void
+gsicc_rcm_chunky_to_planar(gx_device *dev, gsicc_link_t *icclink,
+ gsicc_bufferdesc_t *input_buff_desc,
+ gsicc_bufferdesc_t *output_buff_desc,
+ void *inputbuffer, void *outputbuffer)
+{
+ int k, j, m;
+ byte *inputpos = (byte *) inputbuffer;
+ byte *outputpos = (byte *) outputbuffer;
+ byte *output_loc;
+ byte *inputcolor;
+ byte outputcolor[8]; /* 8 since we have max 4 colorants and 2 bytes/colorant */
+ unsigned short *pos_in_short, *pos_out_short;
+ int num_bytes_in = input_buff_desc->bytes_per_chan;
+ int num_bytes_out = output_buff_desc->bytes_per_chan;
+ int pixel_in_step = num_bytes_in * input_buff_desc->num_chan;
+ int plane_stride = output_buff_desc->plane_stride;
+
+ /* Do row by row. */
+ for (k = 0; k < input_buff_desc->num_rows ; k++) {
+ inputcolor = inputpos;
+ output_loc = outputpos;
+
+ /* split the 2 byte 1 byte case here to avoid decision in inner loop */
+ if (output_buff_desc->bytes_per_chan == 1) {
+ for (j = 0; j < input_buff_desc->pixels_per_row; j++) {
+ gsicc_rcm_transform_general(dev, icclink, (void*) inputcolor,
+ (void*) &(outputcolor[0]), num_bytes_in,
+ num_bytes_out);
+ /* Stuff the output in the proper planar location */
+ for (m = 0; m < output_buff_desc->num_chan; m++) {
+ *(output_loc + m * plane_stride + j) = outputcolor[m];
+ }
+ inputcolor += pixel_in_step;
+ }
+ inputpos += input_buff_desc->row_stride;
+ outputpos += output_buff_desc->row_stride;
+ } else {
+ for (j = 0; j < input_buff_desc->pixels_per_row; j++) {
+ gsicc_rcm_transform_general(dev, icclink, (void*) inputcolor,
+ (void*) &(outputcolor[0]), num_bytes_in,
+ num_bytes_out);
+ /* Stuff the output in the proper planar location */
+ pos_in_short = (unsigned short*) &(outputcolor[0]);
+ pos_out_short = (unsigned short*) (output_loc);
+ for (m = 0; m < output_buff_desc->num_chan; m++) {
+ *(pos_out_short + m * plane_stride + j) = pos_in_short[m];
+ }
+ inputcolor += pixel_in_step;
+ }
+ inputpos += input_buff_desc->row_stride;
+ outputpos += output_buff_desc->row_stride;
+ }
+ }
+}
+
+static void
+gsicc_rcm_chunky_to_chunky(gx_device *dev, gsicc_link_t *icclink,
+ gsicc_bufferdesc_t *input_buff_desc,
+ gsicc_bufferdesc_t *output_buff_desc,
+ void *inputbuffer, void *outputbuffer)
+{
+ int k, j;
+ byte *inputpos = (byte *) inputbuffer;
+ byte *outputpos = (byte *) outputbuffer;
+ byte *inputcolor, *outputcolor;
+ int num_bytes_in = input_buff_desc->bytes_per_chan;
+ int num_bytes_out = output_buff_desc->bytes_per_chan;
+ int pixel_in_step = num_bytes_in * input_buff_desc->num_chan;
+ int pixel_out_step = num_bytes_out * output_buff_desc->num_chan;
+
+ /* Do row by row. */
+ for (k = 0; k < input_buff_desc->num_rows ; k++) {
+ inputcolor = inputpos;
+ outputcolor = outputpos;
+ for (j = 0; j < input_buff_desc->pixels_per_row; j++) {
+ gsicc_rcm_transform_general(dev, icclink, (void*) inputcolor,
+ (void*) outputcolor, num_bytes_in,
+ num_bytes_out);
+ inputcolor += pixel_in_step;
+ outputcolor += pixel_out_step;
+ }
+ inputpos += input_buff_desc->row_stride;
+ outputpos += output_buff_desc->row_stride;
+ }
+}
+
+/* Transform an entire buffer using replacement method */
+static void
+gsicc_rcm_transform_color_buffer(gx_device *dev, gsicc_link_t *icclink,
+ gsicc_bufferdesc_t *input_buff_desc,
+ gsicc_bufferdesc_t *output_buff_desc,
+ void *inputbuffer, void *outputbuffer)
+{
+ /* Since we have to do the mappings to and from frac colors we will for
+ now just call the gsicc_rcm_transform_color as we step through the
+ buffers. This process can be significantly sped up */
+
+ if (input_buff_desc->is_planar) {
+ if (output_buff_desc->is_planar) {
+ gsicc_rcm_planar_to_planar(dev, icclink, input_buff_desc,
+ output_buff_desc, inputbuffer,
+ outputbuffer);
+ } else {
+ gsicc_rcm_planar_to_chunky(dev, icclink, input_buff_desc,
+ output_buff_desc, inputbuffer,
+ outputbuffer);
+ }
+ } else {
+ if (output_buff_desc->is_planar) {
+ gsicc_rcm_chunky_to_planar(dev, icclink, input_buff_desc,
+ output_buff_desc, inputbuffer,
+ outputbuffer);
+ } else {
+ gsicc_rcm_chunky_to_chunky(dev, icclink, input_buff_desc,
+ output_buff_desc, inputbuffer,
+ outputbuffer);
+ }
+ }
+ return;
+}
+
+/* Shared function between the single and buffer conversions. This is where
+ we do the actual replacement. For now, we make the replacement a
+ negative to show the effect of what using color replacement. We also use
+ the device procs to map to the device value. */
+static void
+gsicc_rcm_transform_general(gx_device *dev, gsicc_link_t *icclink,
+ void *inputcolor, void *outputcolor,
+ int num_bytes_in, int num_bytes_out)
+{
+ /* Input data is either single byte or 2 byte color values. */
+ rcm_link_t *link = (rcm_link_t*) icclink->link_handle;
+ byte num_in = link->num_in;
+ byte num_out = link->num_out;
+ frac frac_in[4];
+ frac frac_out[GX_DEVICE_COLOR_MAX_COMPONENTS];
+ int k;
+
+ /* Make the negative for the demo.... */
+ if (num_bytes_in == 2) {
+ unsigned short *data = (unsigned short *) inputcolor;
+ for (k = 0; k < num_in; k++) {
+ frac_in[k] = frac_1 - ushort2frac(data[k]);
+ }
+ } else {
+ byte *data = (byte *) inputcolor;
+ for (k = 0; k < num_in; k++) {
+ frac_in[k] = frac_1 - byte2frac(data[k]);
+ }
+ }
+ /* Use the device procedure */
+ switch (num_in) {
+ case 1:
+ (link->cm_procs.map_gray)(dev, frac_in[0], frac_out);
+ break;
+ case 3:
+ (link->cm_procs.map_rgb)(dev, NULL, frac_in[0], frac_in[1],
+ frac_in[2], frac_out);
+ break;
+ case 4:
+ (link->cm_procs.map_cmyk)(dev, frac_in[0], frac_in[1], frac_in[2],
+ frac_in[3], frac_out);
+ break;
+ default:
+ break;
+ }
+ if (num_bytes_out == 2) {
+ unsigned short *data = (unsigned short *) outputcolor;
+ for (k = 0; k < num_out; k++) {
+ data[k] = frac2ushort(frac_out[k]);
+ }
+ } else {
+ byte *data = (byte *) outputcolor;
+ for (k = 0; k < num_out; k++) {
+ data[k] = frac2byte(frac_out[k]);
+ }
+ }
+ return;
+}
+
+/* Transform a single color using the generic (non color managed)
+ transformations */
+static void
+gsicc_rcm_transform_color(gx_device *dev, gsicc_link_t *icclink, void *inputcolor,
+ void *outputcolor, int num_bytes)
+{
+ gsicc_rcm_transform_general(dev, icclink, inputcolor, outputcolor,
+ num_bytes, num_bytes);
+}
+
+static void
+gsicc_rcm_freelink(gsicc_link_t *icclink)
+{
+ rcm_link_t *rcm_link = (rcm_link_t*) icclink->link_handle;
+ gs_free_object(rcm_link->memory, rcm_link, "gsicc_rcm_freelink");
+}
+
+/* Get the replacement color management link. It basically needs to store
+ the number of components for the source so that we know what we are
+ coming from (e.g. RGB, CMYK, Gray) */
+gsicc_link_t*
+gsicc_rcm_get_link(const gs_imager_state *pis, gx_device *dev,
+ gsicc_colorbuffer_t data_cs)
+{
+ gsicc_link_t *result;
+ gsicc_hashlink_t hash;
+ rcm_link_t *rcm_link;
+ gs_memory_t *mem = dev->memory->non_gc_memory;
+ const gx_cm_color_map_procs * cm_procs;
+
+ /* If the cm_procs are forwarding due to the overprint device or other
+ odd thing, drill down now and get the proper ones */
+ if (fwd_uses_fwd_cmap_procs(dev)) {
+ cm_procs = fwd_get_target_cmap_procs(dev);
+ } else {
+ cm_procs = dev_proc(dev, get_color_mapping_procs)(dev);
+ }
+
+ hash.rend_hash = gsCMM_REPLACE;
+ hash.des_hash = dev->color_info.num_components;
+ hash.src_hash = data_cs;
+ hash.link_hashcode = data_cs + hash.des_hash * 256 + hash.rend_hash * 4096;
+
+ /* Check the cache for a hit. */
+ result = gsicc_findcachelink(hash, pis->icc_link_cache, false, false);
+ if (result != NULL) {
+ return result;
+ }
+ /* If not, then lets create a new one. This may actually return a link if
+ another thread has already created it while we were trying to do so */
+ if (gsicc_alloc_link_entry(pis->icc_link_cache, &result, hash, false, false))
+ return result;
+
+ /* Now compute the link contents */
+ result->procs.map_buffer = gsicc_rcm_transform_color_buffer;
+ result->procs.map_color = gsicc_rcm_transform_color;
+ result->procs.free_link = gsicc_rcm_freelink;
+ result->hashcode = hash;
+ result->is_identity = false;
+ rcm_link = (rcm_link_t *) gs_alloc_bytes(mem, sizeof(rcm_link_t),
+ "gsicc_rcm_get_link");
+ result->link_handle = (void*) rcm_link;
+ rcm_link->memory = mem;
+ rcm_link->num_out = min(dev->color_info.num_components,
+ GS_CLIENT_COLOR_MAX_COMPONENTS);
+ rcm_link->data_cs_in = data_cs;
+ rcm_link->cm_procs.map_cmyk = cm_procs->map_cmyk;
+ rcm_link->cm_procs.map_rgb = cm_procs->map_rgb;
+ rcm_link->cm_procs.map_gray = cm_procs->map_gray;
+
+ switch (data_cs) {
+ case gsGRAY:
+ rcm_link->num_in = 1;
+ break;
+ case gsRGB:
+ case gsCIELAB:
+ rcm_link->num_in = 3;
+ break;
+ case gsCMYK:
+ rcm_link->num_in = 4;
+ break;
+ default:
+ result->procs.free_link(result);
+ return NULL;
+ }
+ /* Likely set if we have something like a table or procs */
+ rcm_link->context = NULL;
+ if (result != NULL) {
+ gsicc_set_link_data(result, rcm_link, hash,
+ pis->icc_link_cache->lock, false, false);
+ }
+ return result;
+}
diff --git a/gs/base/gxclimag.c b/gs/base/gxclimag.c
index 1b366a35f..eb7e15e30 100644
--- a/gs/base/gxclimag.c
+++ b/gs/base/gxclimag.c
@@ -523,7 +523,7 @@ clist_begin_typed_image(gx_device * dev,
dev_render_cond.override_icc;
stored_rendering_cond.preserve_black =
dev_render_cond.preserve_black;
- stored_rendering_cond.use_cm = true; /* Unless spec. below */
+ stored_rendering_cond.cmm = gsCMM_DEFAULT; /* Unless spec. below */
/* We may need to do some substitions for the source profile */
if (pis->icc_manager->srcgtag_profile != NULL) {
srcgtag_profile = pis->icc_manager->srcgtag_profile;
@@ -546,8 +546,8 @@ clist_begin_typed_image(gx_device * dev,
}
} else {
/* A possible do not use CM case */
- stored_rendering_cond.use_cm =
- srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO].use_cm;
+ stored_rendering_cond.cmm =
+ srcgtag_profile->rgb_rend_cond[gsSRC_IMAGPRO].cmm;
}
} else if (src_profile->data_cs == gsCMYK) {
if (srcgtag_profile->cmyk_profiles[gsSRC_IMAGPRO] != NULL) {
@@ -565,8 +565,8 @@ clist_begin_typed_image(gx_device * dev,
}
} else {
/* A possible do not use CM case */
- stored_rendering_cond.use_cm =
- srcgtag_profile->cmyk_rend_cond[gsSRC_IMAGPRO].use_cm;
+ stored_rendering_cond.cmm =
+ srcgtag_profile->cmyk_rend_cond[gsSRC_IMAGPRO].cmm;
}
}
}
diff --git a/gs/base/gxcmap.c b/gs/base/gxcmap.c
index d10dc98b8..6c0819d44 100644
--- a/gs/base/gxcmap.c
+++ b/gs/base/gxcmap.c
@@ -1240,7 +1240,7 @@ cmap_separation_direct(frac all, gx_device_color * pdc, const gs_imager_state *
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = pis->renderingintent;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
icc_link = gsicc_get_link_profile(pis, dev, pis->icc_manager->default_rgb,
des_profile, &rendering_params,
@@ -1315,7 +1315,7 @@ devicen_icc_cmyk(frac cm_comps[], const gs_imager_state * pis, gx_device *dev)
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = pis->renderingintent;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
/* Sigh, frac to full 16 bit. Need to clean this up */
for (k = 0; k < 4; k++){
psrc[k] = frac2cv(cm_comps[k]);
diff --git a/gs/base/gxi12bit.c b/gs/base/gxi12bit.c
index 78026aafd..9f4281ea5 100644
--- a/gs/base/gxi12bit.c
+++ b/gs/base/gxi12bit.c
@@ -163,7 +163,7 @@ gs_image_class_2_fracs(gx_image_enum * penum)
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = penum->pis->renderingintent;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
if (gs_color_space_is_PSCIE(penum->pcs) && penum->pcs->icc_equivalent != NULL) {
pcs = penum->pcs->icc_equivalent;
} else {
diff --git a/gs/base/gxicolor.c b/gs/base/gxicolor.c
index 04fa24bbd..60bac18ad 100644
--- a/gs/base/gxicolor.c
+++ b/gs/base/gxicolor.c
@@ -138,7 +138,7 @@ gs_image_class_4_color(gx_image_enum * penum)
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = penum->pis->renderingintent;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
if (gs_color_space_is_PSCIE(penum->pcs) && penum->pcs->icc_equivalent != NULL) {
pcs = penum->pcs->icc_equivalent;
} else {
diff --git a/gs/base/gximono.c b/gs/base/gximono.c
index 905c296cf..eae18aa41 100644
--- a/gs/base/gximono.c
+++ b/gs/base/gximono.c
@@ -120,7 +120,7 @@ gs_image_class_3_mono(gx_image_enum * penum)
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = penum->pis->renderingintent;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
if (gs_color_space_get_index(penum->pcs) ==
gs_color_space_index_Indexed) {
pcs = penum->pcs->base_space;
diff --git a/gs/base/gxiscale.c b/gs/base/gxiscale.c
index 1781ca585..fc23ca932 100644
--- a/gs/base/gxiscale.c
+++ b/gs/base/gxiscale.c
@@ -341,7 +341,7 @@ gs_image_class_0_interpolate(gx_image_enum * penum)
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = penum->pis->renderingintent;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
if (gs_color_space_is_PSCIE(penum->pcs) && penum->pcs->icc_equivalent != NULL) {
pcs = penum->pcs->icc_equivalent;
} else {
diff --git a/gs/base/gxshade.c b/gs/base/gxshade.c
index 2751c3d7d..6a77b5559 100644
--- a/gs/base/gxshade.c
+++ b/gs/base/gxshade.c
@@ -387,7 +387,7 @@ top:
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = pis->renderingintent;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
/* Grab the icc link transform that we need now */
if (pcs->cmm_icc_profile_data != NULL) {
pfs->icclink = gsicc_get_link(pis, pis->trans_device, pcs, NULL,
diff --git a/gs/base/lib.mak b/gs/base/lib.mak
index 99aed841c..234900361 100644
--- a/gs/base/lib.mak
+++ b/gs/base/lib.mak
@@ -2703,7 +2703,8 @@ $(GLOBJ)gxctable.$(OBJ) : $(GLSRC)gxctable.c $(AK) $(gx_h)\
gsicc_=$(GLOBJ)gsicc_manage.$(OBJ) $(GLOBJ)gsicc_cache.$(OBJ)\
$(GLOBJ)gsicc_$(WHICH_CMS).$(OBJ) $(GLOBJ)gsicc_profilecache.$(OBJ)\
- $(GLOBJ)gsicc_create.$(OBJ) $(GLOBJ)gsicc_nocm.$(OBJ)
+ $(GLOBJ)gsicc_create.$(OBJ) $(GLOBJ)gsicc_nocm.$(OBJ)\
+ $(GLOBJ)gsicc_replacecm.$(OBJ)
sicclib_=$(GLOBJ)gsicc.$(OBJ)
$(GLD)sicclib.dev : $(LIB_MAK) $(ECHOGS_XE) $(sicclib_) $(gsicc_)\
@@ -2731,6 +2732,12 @@ $(GLOBJ)gsicc_nocm.$(OBJ) : $(GLSRC)gsicc_nocm.c $(AK) $(std_h) $(gx_h)\
$(gsicc_cache_h) $(MAKEDIRS)
$(GLCC) $(GLO_)gsicc_nocm.$(OBJ) $(C_) $(GLSRC)gsicc_nocm.c
+$(GLOBJ)gsicc_replacecm.$(OBJ) : $(GLSRC)gsicc_replacecm.c $(AK) $(std_h) $(gx_h)\
+ $(stdpre_h) $(gstypes_h) $(gsmemory_h) $(gsstruct_h) $(scommon_h) $(strmio_h)\
+ $(string__h) $(gxistate_h) $(gxcspace_h) $(gsicc_cms_h)\
+ $(gsicc_cache_h) $(MAKEDIRS)
+ $(GLCC) $(GLO_)gsicc_replacecm.$(OBJ) $(C_) $(GLSRC)gsicc_replacecm.c
+
$(GLOBJ)gsicc_manage.$(OBJ) : $(GLSRC)gsicc_manage.c $(AK) $(gx_h)\
$(stdpre_h) $(gstypes_h) $(gsmemory_h) $(gsstruct_h) $(scommon_h) $(strmio_h)\
$(gxistate_h) $(gxcspace_h) $(gscms_h) $(gsicc_manage_h) $(gsicc_cache_h)\
diff --git a/gs/ghostscript.vcproj b/gs/ghostscript.vcproj
index 70456a9f0..4893112f9 100644
--- a/gs/ghostscript.vcproj
+++ b/gs/ghostscript.vcproj
@@ -2184,6 +2184,10 @@
RelativePath=".\base\gsicc_profilecache.c"
>
</File>
+ <File
+ RelativePath=".\base\gsicc_replacecm.c"
+ >
+ </File>
</Filter>
</Filter>
<Filter
@@ -9465,4 +9469,4 @@
</Files>
<Globals>
</Globals>
-</VisualStudioProject>
+</VisualStudioProject> \ No newline at end of file
diff --git a/xps/xpsgradient.c b/xps/xpsgradient.c
index c1e3a7147..5b1fa7af6 100644
--- a/xps/xpsgradient.c
+++ b/xps/xpsgradient.c
@@ -86,7 +86,7 @@ xps_parse_gradient_stops(xps_context_t *ctx, char *base_uri, xps_item_t *node,
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = gsPERCEPTUAL;
- rendering_params.use_cm = true;
+ rendering_params.cmm = gsCMM_DEFAULT;
/* Get link to map from source to sRGB */
icclink = gsicc_get_link((gs_imager_state*) ctx->pgs,
NULL, colorspace, ctx->srgb,