summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vrhel <michael.vrhel@artifex.com>2018-06-26 14:52:22 -0700
committerMichael Vrhel <michael.vrhel@artifex.com>2018-06-27 10:14:29 -0700
commit250b5e83e923bed9b6d48bf3965f3b38af52286d (patch)
tree2c484c47ea50b3ef822397c88fe399676b3e4c1e
parente4a7fc24c051241e4dbd14760a218290769d78a6 (diff)
downloadghostpdl-250b5e83e923bed9b6d48bf3965f3b38af52286d.tar.gz
Fix errors introduced in previous commit
The commit f2cf68297e3d63cb927db3c98d317f7ee68e7898 resulted in errors with the separation type devices. With these devices, we can simply check if the color model matches the ICC profile since these devices change their number of components. Will likely need to do some testing with these device and different profiles to see what breaks when and make sure we exit gracefully.
-rw-r--r--base/gsicc_manage.c24
-rw-r--r--devices/devs.mak6
-rw-r--r--devices/gdevcmykog.c3
-rw-r--r--devices/gdevgprf.c65
-rw-r--r--devices/gdevpsd.c17
5 files changed, 77 insertions, 38 deletions
diff --git a/base/gsicc_manage.c b/base/gsicc_manage.c
index 2577db893..ca13366b8 100644
--- a/base/gsicc_manage.c
+++ b/base/gsicc_manage.c
@@ -1764,8 +1764,15 @@ static int
gsicc_verify_device_profiles(gx_device * pdev)
{
int k;
- bool objects = false;
cmm_dev_profile_t *dev_icc = pdev->icc_struct;
+ bool is_sep = false;
+ bool can_postrender = false;
+ bool objects = false;
+
+ if (pdev->procs.dev_spec_op != NULL) {
+ is_sep = dev_proc(pdev, dev_spec_op)(pdev, gxdso_supports_devn, NULL, 0);
+ can_postrender = dev_proc(pdev, dev_spec_op)(pdev, gxdso_supports_iccpostrender, NULL, 0);
+ }
if (dev_icc->device_profile[0] == NULL)
return 0;
@@ -1782,11 +1789,10 @@ gsicc_verify_device_profiles(gx_device * pdev)
}
if (dev_icc->postren_profile != NULL) {
- if (pdev->procs.dev_spec_op == NULL ||
- !dev_proc(pdev, dev_spec_op)(pdev, gxdso_supports_iccpostrender, NULL, 0)) {
+ if (!can_postrender) {
return gs_rethrow(-1, "Post render profile not supported by device");
}
- if (!dev_proc(pdev, dev_spec_op)(pdev, gxdso_supports_devn, NULL, 0)) {
+ if (!is_sep) {
if (dev_icc->postren_profile->num_comps !=
pdev->color_info.num_components) {
return gs_rethrow(-1, "Post render profile does not match the device color model");
@@ -1805,14 +1811,14 @@ gsicc_verify_device_profiles(gx_device * pdev)
if (dev_icc->link_profile == NULL) {
if (!objects) {
- if (dev_icc->device_profile[0]->num_comps !=
+ if (!is_sep && dev_icc->device_profile[0]->num_comps !=
pdev->color_info.num_components)
return gs_rethrow(-1, "Mismatch of ICC profiles and device color model");
else
- return 0;
+ return 0; /* Currently sep devices have some leeway here */
} else {
for (k = 1; k < NUM_DEVICE_PROFILES; k++)
- if (dev_icc->device_profile[k] != NULL) {
+ if (!is_sep && dev_icc->device_profile[k] != NULL) {
if (dev_icc->device_profile[k]->num_comps !=
pdev->color_info.num_components)
return gs_rethrow(-1, "Mismatch of object dependent ICC profiles and device color model");
@@ -1823,12 +1829,12 @@ gsicc_verify_device_profiles(gx_device * pdev)
/* The input of the device link must match the output of the device
profile and the device link output must match the device color
model */
- if (dev_icc->link_profile->num_comps_out !=
+ if (!is_sep && dev_icc->link_profile->num_comps_out !=
pdev->color_info.num_components) {
return gs_rethrow(-1, "Mismatch of device link profile and device color model");
}
for (k = 0; k < NUM_DEVICE_PROFILES; k++) {
- if (dev_icc->device_profile[k] != NULL) {
+ if (!is_sep && dev_icc->device_profile[k] != NULL) {
if (dev_icc->device_profile[k]->num_comps !=
dev_icc->link_profile->num_comps) {
return gs_rethrow(-1, "Mismatch of device link profile and device ICC profile");
diff --git a/devices/devs.mak b/devices/devs.mak
index 184be7ba4..3b7304846 100644
--- a/devices/devs.mak
+++ b/devices/devs.mak
@@ -1205,7 +1205,7 @@ $(DEVOBJ)gdevpsd.$(OBJ) : $(DEVSRC)gdevpsd.c $(PDEVH) $(math__h)\
$(gdevdcrd_h) $(gscrd_h) $(gscrdp_h) $(gsparam_h) $(gxlum_h)\
$(gstypes_h) $(gxdcconv_h) $(gdevdevn_h) $(gxdevsop_h) $(gsequivc_h)\
$(gscms_h) $(gsicc_cache_h) $(gsicc_manage_h) $(gxgetbit_h)\
- $(gdevppla_h) $(gxiodev_h) $(gdevpsd_h) $(DEVS_MAK) $(MAKEDIRS)
+ $(gdevppla_h) $(gxiodev_h) $(gdevpsd_h) $(gxdevsop_h) $(DEVS_MAK) $(MAKEDIRS)
$(DEVCC) $(DEVO_)gdevpsd.$(OBJ) $(C_) $(DEVSRC)gdevpsd.c
### --------------------------- The GPRF device ------------------------- ###
@@ -1219,14 +1219,14 @@ $(DEVOBJ)gdevgprf_1.$(OBJ) : $(DEVSRC)gdevgprf.c $(PDEVH) $(math__h)\
$(gdevdcrd_h) $(gscrd_h) $(gscrdp_h) $(gsparam_h) $(gxlum_h)\
$(gstypes_h) $(gxdcconv_h) $(gdevdevn_h) $(gsequivc_h) \
$(gscms_h) $(gsicc_cache_h) $(gsicc_manage_h) $(gxgetbit_h)\
- $(gdevppla_h) $(DEVS_MAK) $(MAKEDIRS)
+ $(gdevppla_h) $(gxdevsop_h) $(DEVS_MAK) $(MAKEDIRS)
$(DEVCC) $(DEVO_)gdevgprf_1.$(OBJ) $(II)$(ZI_)$(_I) $(C_) $(DEVSRC)gdevgprf.c
$(DEVOBJ)gdevgprf_0.$(OBJ) : $(DEVSRC)gdevgprf.c $(PDEVH) $(math__h)\
$(gdevdcrd_h) $(gscrd_h) $(gscrdp_h) $(gsparam_h) $(gxlum_h)\
$(gstypes_h) $(gxdcconv_h) $(gdevdevn_h) $(gsequivc_h) $(zlib_h)\
$(gscms_h) $(gsicc_cache_h) $(gsicc_manage_h) $(gxgetbit_h)\
- $(gdevppla_h) $(DEVS_MAK) $(MAKEDIRS)
+ $(gdevppla_h) $(gxdevsop_h) $(DEVS_MAK) $(MAKEDIRS)
$(DEVCC) $(DEVO_)gdevgprf_0.$(OBJ) $(II)$(ZI_)$(_I) $(C_) $(DEVSRC)gdevgprf.c
$(DEVOBJ)gdevgprf.$(OBJ) : $(DEVOBJ)gdevgprf_$(SHARE_ZLIB).$(OBJ) $(DEVS_MAK) $(MAKEDIRS)
diff --git a/devices/gdevcmykog.c b/devices/gdevcmykog.c
index a7801f4ae..06b94006d 100644
--- a/devices/gdevcmykog.c
+++ b/devices/gdevcmykog.c
@@ -213,6 +213,9 @@ cmykog_dev_spec_op(gx_device *dev_, int op, void *data, int datasize)
if (code != gs_error_undefined)
return code;
}
+ if (op == gxdso_supports_devn) {
+ return true;
+ }
return gx_default_dev_spec_op(dev_, op, data, datasize);
}
diff --git a/devices/gdevgprf.c b/devices/gdevgprf.c
index 2fd0fe8c7..e47ed2ddd 100644
--- a/devices/gdevgprf.c
+++ b/devices/gdevgprf.c
@@ -35,6 +35,7 @@
#include "gdevppla.h"
#include "gxdownscale.h"
#include "gdevdevnprn.h"
+#include "gxdevsop.h"
#ifndef MAX_CHAN
# define MAX_CHAN 15
@@ -89,6 +90,15 @@ static RELOC_PTRS_WITH(gprf_device_reloc_ptrs, gprf_device *pdev)
}
RELOC_PTRS_END
+static int
+gprf_spec_op(gx_device *dev_, int op, void *data, int datasize)
+{
+ if (op == gxdso_supports_devn) {
+ return true;
+ }
+ return gx_default_dev_spec_op(dev_, op, data, datasize);
+}
+
/* Even though gprf_device_finalize is the same as gx_devn_prn_device_finalize,
* we need to implement it separately because st_composite_final
* declares all 3 procedures as private. */
@@ -167,7 +177,12 @@ gs_private_st_composite_final(st_gprf_device, gprf_device,
NULL, /* fill_linear_color_trapezoid */\
NULL, /* fill_linear_color_triangle */\
gx_devn_prn_update_spot_equivalent_colors, /* update_spot_equivalent_colors */\
- gx_devn_prn_ret_devn_params /* ret_devn_params */\
+ gx_devn_prn_ret_devn_params, /* ret_devn_params */\
+ NULL, /* fillpage */\
+ NULL, /* push_transparency_state */\
+ NULL, /* pop_transparency_state */\
+ NULL, /* put_image */\
+ gprf_spec_op /* dev_spec_op */\
}
#define gprf_device_body(procs, dname, ncomp, pol, depth, mg, mc, sl, cn)\
@@ -236,16 +251,16 @@ gprf_prn_open(gx_device * pdev)
pdev->log2_align_mod = 6;
#endif
- /* There are 2 approaches to the use of a DeviceN ICC output profile.
+ /* There are 2 approaches to the use of a DeviceN ICC output profile.
One is to simply limit our device to only output the colorants
- defined in the output ICC profile. The other is to use the
+ defined in the output ICC profile. The other is to use the
DeviceN ICC profile to color manage those N colorants and
- to let any other separations pass through unmolested. The define
+ to let any other separations pass through unmolested. The define
LIMIT_TO_ICC sets the option to limit our device to only the ICC
colorants defined by -sICCOutputColors (or to the ones that are used
- as default names if ICCOutputColors is not used). The pass through option
- (LIMIT_TO_ICC set to 0) makes life a bit more difficult since we don't
- know if the page_spot_colors overlap with any spot colorants that exist
+ as default names if ICCOutputColors is not used). The pass through option
+ (LIMIT_TO_ICC set to 0) makes life a bit more difficult since we don't
+ know if the page_spot_colors overlap with any spot colorants that exist
in the DeviceN ICC output profile. Hence we don't know how many planes
to use for our device. This is similar to the issue when processing
a PostScript file. So that I remember, the cases are
@@ -274,7 +289,7 @@ gprf_prn_open(gx_device * pdev)
pdev_gprf->warning_given = false;
/* With planar the depth can be more than 64. Update the color
info to reflect the proper depth and number of planes. Also note
- that the number of spot colors can change from page to page.
+ that the number of spot colors can change from page to page.
Update things so that we only output separations for the
inks on that page. */
@@ -321,14 +336,14 @@ gprf_prn_open(gx_device * pdev)
for (k = 0; k < GS_CLIENT_COLOR_MAX_COMPONENTS; k++) {
pdev_gprf->devn_params.separation_order_map[k] = k;
}
- pdev->color_info.depth = pdev->color_info.num_components *
+ pdev->color_info.depth = pdev->color_info.num_components *
pdev_gprf->devn_params.bitspercomponent;
pdev->color_info.separable_and_linear = GX_CINFO_SEP_LIN;
profile_struct->supports_devn = true;
code = gdev_prn_open_planar(pdev, true);
/* Take care of the ICC transform now. There are several possible ways
- * that this could go. One is that the CMYK colors are color managed
+ * that this could go. One is that the CMYK colors are color managed
* but the non-standard colorants are not. That is, we have specified
* a CMYK profile for our device but we have other spot colorants in
* the source file. In this case, we will do managed proofing for the
@@ -336,10 +351,10 @@ gprf_prn_open(gx_device * pdev)
* DeviceN colorants will be problematic in this case and we will do the
* the best we can with the tools given to us. The other possibility is
* that someone has given an NColor ICC profile for the device and we can
- * actually deal with the mapping directly. This is a much cleaner case
- * but as we know NColor profiles are not too common. Also we need to
- * deal with transparent colorants (e.g. varnish) in an intelligent manner.
- * Note that we require the post rendering profile to be RGB based for
+ * actually deal with the mapping directly. This is a much cleaner case
+ * but as we know NColor profiles are not too common. Also we need to
+ * deal with transparent colorants (e.g. varnish) in an intelligent manner.
+ * Note that we require the post rendering profile to be RGB based for
* this particular device. */
if (pdev_gprf->icclink == NULL && profile_struct->device_profile[0] != NULL
@@ -364,7 +379,7 @@ gprf_prn_open(gx_device * pdev)
* The following procedures are used to map the standard color spaces into
* the color components. This is not where the color management occurs. These
* may do a reordering of the colors following some ICC base color management
-* or they may be used in the case of -dUseFastColor as that relies upon the
+* or they may be used in the case of -dUseFastColor as that relies upon the
* device color mapping procedures
*/
static void
@@ -524,14 +539,14 @@ gprf_get_color_comp_index(gx_device * dev, const char * pname,
if (strncmp(pname, "None", name_size) == 0) return -1;
index = gx_devn_prn_get_color_comp_index(dev, pname, name_size,
component_type);
- /* This is a one shot deal. That is it will simply post a notice once that
+ /* This is a one shot deal. That is it will simply post a notice once that
some colorants will be converted due to a limit being reached. It will
- not list names of colorants since then I would need to keep track of
+ not list names of colorants since then I would need to keep track of
which ones I have already mentioned. Also, if someone is fooling with
num_order, then this warning is not given since they should know what
is going on already */
- if (index < 0 && component_type == SEPARATION_NAME &&
- pdev->warning_given == false &&
+ if (index < 0 && component_type == SEPARATION_NAME &&
+ pdev->warning_given == false &&
pdev->devn_params.num_separation_order_names == 0) {
dmlprintf(dev->memory, "**** Max spot colorants reached.\n");
dmlprintf(dev->memory, "**** Some colorants will be converted to equivalent CMYK values.\n");
@@ -603,7 +618,7 @@ gprf_setup(gprf_write_ctx *xc, gx_device_printer *pdev, FILE *file, int w, int h
* which planes are actually imaged. For the process color model channels
* we image the channels which are requested. Non requested process color
* model channels are simply filled with white. For spot colors we only
- * image the requested channels.
+ * image the requested channels.
*/
for (i = 0; i < xc->num_channels + xc->n_extra_channels; i++) {
xc->chnl_to_position[i] = i;
@@ -779,7 +794,7 @@ gprf_write_header(gprf_write_ctx *xc)
cmyk[3] = (k < 0 ? 0 : (k > 255 ? 255 : k));
}
- /* Convert color to RGBA. To get the A value, we are going to need to
+ /* Convert color to RGBA. To get the A value, we are going to need to
deal with the mixing hints information in the PDF content. A ToDo
project. At this point, everything has an alpha of 1.0 */
rgba[3] = 255;
@@ -975,14 +990,14 @@ compressAndWrite(gprf_write_ctx *xc, byte *data, int tile_w, int tile_h, int ras
}
deflate(&zstm, Z_FINISH);
deflateEnd(&zstm);
-
+
code = gprf_write(xc, xc->deflate_block, xc->deflate_bound - zstm.avail_out);
if (code < 0)
return_error(gs_error_ioerror);
return 0;
}
-/* If the profile is NULL or if the profile does not support the spot
+/* If the profile is NULL or if the profile does not support the spot
colors then we have to calculate the equivalent CMYK values and then color
manage. */
static void
@@ -1036,7 +1051,7 @@ build_cmyk_planar_raster(gprf_write_ctx *xc, byte *planes[], byte *cmyk_in,
/* Create RGB from CMYK the horribly slow way */
static void
-get_rgb_planar_line(gprf_write_ctx *xc, byte *c, byte *m, byte *y, byte *k,
+get_rgb_planar_line(gprf_write_ctx *xc, byte *c, byte *m, byte *y, byte *k,
byte *red_in, byte *green_in, byte *blue_in, int width)
{
int x_pos;
@@ -1280,7 +1295,7 @@ gprf_write_image_data(gprf_write_ctx *xc)
cleanup:
gx_downscaler_fin(&ds);
- gs_free_object(pdev->memory, planes[0],
+ gs_free_object(pdev->memory, planes[0],
"gprf_write_image_data");
gs_free_object(pdev->memory, rgb[0],
"gprf_write_image_data");
diff --git a/devices/gdevpsd.c b/devices/gdevpsd.c
index 8f871021d..05584d2f9 100644
--- a/devices/gdevpsd.c
+++ b/devices/gdevpsd.c
@@ -36,6 +36,7 @@
#include "gxdownscale.h"
#include "gdevdevnprn.h"
#include "gdevpsd.h"
+#include "gxdevsop.h"
#ifndef cmm_gcmmhlink_DEFINED
#define cmm_gcmmhlink_DEFINED
@@ -135,6 +136,15 @@ static RELOC_PTRS_WITH(psd_device_reloc_ptrs, psd_device *pdev)
}
RELOC_PTRS_END
+static int
+psd_spec_op(gx_device *dev_, int op, void *data, int datasize)
+{
+ if (op == gxdso_supports_devn) {
+ return true;
+ }
+ return gx_default_dev_spec_op(dev_, op, data, datasize);
+}
+
/* Even though psd_device_finalize is the same as gx_devn_prn_device_finalize,
* we need to implement it separately because st_composite_final
* declares all 3 procedures as private. */
@@ -213,7 +223,12 @@ gs_private_st_composite_final(st_psd_device, psd_device,
NULL, /* fill_linear_color_trapezoid */\
NULL, /* fill_linear_color_triangle */\
gx_devn_prn_update_spot_equivalent_colors, /* update_spot_equivalent_colors */\
- gx_devn_prn_ret_devn_params /* ret_devn_params */\
+ gx_devn_prn_ret_devn_params, /* ret_devn_params */\
+ NULL, /* fillpage */\
+ NULL, /* push_transparency_state */\
+ NULL, /* pop_transparency_state */\
+ NULL, /* put_image */\
+ psd_spec_op /* dev_spec_op */\
}
static fixed_colorant_name DeviceGrayComponents[] = {