File gdevcups.c.dif of Package ghostscript-library
diff -U 3 -H -d -r -N -x .svn -- old/cups/gdevcups.c new/cups/gdevcups.c
--- old/cups/gdevcups.c 2011-08-05 13:12:21.000000000 +0200
+++ new/cups/gdevcups.c 2012-01-13 19:16:03.000000000 +0100
@@ -77,6 +77,10 @@
#include <cups/ppd.h>
#include <math.h>
+/* the extremely noisy DEBUG2 messages are now dependent on CUPS_DEBUG2 */
+/* this can be enabled during the 'make' or by uncommenting the following */
+/* #define CUPS_DEBUG2 */
+
#undef private
#define private
@@ -171,7 +175,7 @@
private dev_proc_open_device(cups_open);
private int cups_print_pages(gx_device_printer *, FILE *, int);
private int cups_put_params(gx_device *, gs_param_list *);
-private void cups_set_color_info(gx_device *);
+private int cups_set_color_info(gx_device *);
private dev_proc_sync_output(cups_sync_output);
private prn_dev_proc_get_space_params(cups_get_space_params);
@@ -225,6 +229,7 @@
unsigned short EncodeLUT[gx_max_color_value + 1];/* RGB value to output color LUT */
int Density[CUPS_MAX_VALUE + 1];/* Density LUT */
int Matrix[3][3][CUPS_MAX_VALUE + 1];/* Color transform matrix LUT */
+ int user_icc;
int cupsRasterVersion;
/* Used by cups_put_params(): */
@@ -425,7 +430,10 @@
{0x00}, /* DecodeLUT */
{0x00}, /* EncodeLUT */
{0x00}, /* Density */
- {0x00}, /* Matrix */
+ {{{0x00},{0x00},{0x00}},
+ {{0x00},{0x00},{0x00}},
+ {{0x00},{0x00},{0x00}}}, /* Matrix */
+ 0, /* user_icc */
3 /* cupsRasterVersion */
};
@@ -451,9 +459,9 @@
private int
cups_close(gx_device *pdev) /* I - Device info */
{
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf1("DEBUG2: cups_close(%p)\n", pdev);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
dprintf("INFO: Rendering completed\n");
@@ -549,9 +557,9 @@
i ++)
ci = (ci << shift) | cups->EncodeLUT[cv[i]];
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf2("DEBUG2: cv[0]=%d -> %llx\n", cv[0], ci);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
/*
* Handle 6-color output...
@@ -731,6 +739,8 @@
else
return -1;
break;
+ default:
+ break;
}
return -1;
}
@@ -756,9 +766,9 @@
cups_get_matrix(gx_device *pdev, /* I - Device info */
gs_matrix *pmat) /* O - Physical transform matrix */
{
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf2("DEBUG2: cups_get_matrix(%p, %p)\n", pdev, pmat);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
/*
* Set the raster width and height...
@@ -776,9 +786,9 @@
/*
* Do landscape orientation...
*/
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf("DEBUG2: Landscape matrix: XX=0 XY=+1 YX=+1 YY=0\n");
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
pmat->xx = 0.0;
pmat->xy = (float)cups->header.HWResolution[1] / 72.0;
pmat->yx = (float)cups->header.HWResolution[0] / 72.0;
@@ -791,9 +801,9 @@
/*
* Do portrait orientation...
*/
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf("DEBUG2: Portrait matrix: XX=+1 XY=0 YX=0 YY=-1\n");
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
pmat->xx = (float)cups->header.HWResolution[0] / 72.0;
pmat->xy = 0.0;
pmat->yx = 0.0;
@@ -815,7 +825,7 @@
}
#endif /* CUPS_RASTER_SYNCv1 */
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf2("DEBUG2: width = %d, height = %d\n", cups->header.cupsWidth,
cups->header.cupsHeight);
dprintf4("DEBUG2: PageSize = [ %d %d ], HWResolution = [ %d %d ]\n",
@@ -826,7 +836,7 @@
pdev->HWMargins[3]);
dprintf6("DEBUG2: matrix = [ %.3f %.3f %.3f %.3f %.3f %.3f ]\n",
pmat->xx, pmat->xy, pmat->yx, pmat->yy, pmat->tx, pmat->ty);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
}
@@ -847,24 +857,24 @@
bool b; /* Temporary boolean value */
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf2("DEBUG2: cups_get_params(%p, %p)\n", pdev, plist);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
/*
* First process the "standard" page device parameters...
*/
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf("DEBUG2: before gdev_prn_get_params()\n");
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
if ((code = gdev_prn_get_params(pdev, plist)) < 0)
return (code);
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf("DEBUG2: after gdev_prn_get_params()\n");
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
/*
* Then write the CUPS parameters...
@@ -1052,9 +1062,9 @@
return (code);
#endif /* CUPS_RASTER_SYNCv1 */
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf("DEBUG2: Leaving cups_get_params()\n");
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
return (0);
}
@@ -1075,9 +1085,9 @@
cache_units[255]; /* Cache size units */
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf2("DEBUG2: cups_get_space_params(%p, %p)\n", pdev, space_params);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
if ((cache_env = getenv("RIP_MAX_CACHE")) != NULL)
{
@@ -1106,9 +1116,9 @@
if (cache_size == 0)
return;
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf1("DEBUG2: cache_size = %.0f\n", cache_size);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
space_params->MaxBitmap = (long)cache_size;
space_params->BufferSpace = (long)cache_size;
@@ -1156,10 +1166,10 @@
ciel, ciea, cieb; /* CIE Lab colors */
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf6("DEBUG2: cups_map_cmyk(%p, %d, %d, %d, %d, %p)\n",
pdev, c, m, y, k, out);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
/*
* Convert the CMYK color to the destination colorspace...
@@ -1182,15 +1192,18 @@
case CUPS_CSPACE_RGB :
case CUPS_CSPACE_RGBW :
+ c0 = c + k;
+ c1 = m + k;
+ c2 = y + k;
if (cups->header.cupsColorSpace == CUPS_CSPACE_RGBW) {
- c0 = c;
- c1 = m;
- c2 = y;
- c3 = k;
- } else {
- c0 = c + k;
- c1 = m + k;
- c2 = y + k;
+ if ((k >= frac_1 - 1) ||
+ ((c0 >= frac_1) && (c1 >= frac_1) && (c2 >= frac_1))) {
+ c0 = frac_1;
+ c1 = frac_1;
+ c2 = frac_1;
+ c3 = frac_1;
+ } else
+ c3 = 0;
}
if (c0 < 0)
@@ -1212,11 +1225,12 @@
out[2] = frac_1 - (frac)cups->Density[c2];
if (cups->header.cupsColorSpace == CUPS_CSPACE_RGBW) {
- if (c3 < 0)
- c3 = 0;
- else if (c3 > frac_1)
- c3 = frac_1;
- out[3] = frac_1 - (frac)cups->Density[c3];
+ if (c3 == 0)
+ out[3] = frac_1;
+ else if (c3 == frac_1)
+ out[3] = 0;
+ else
+ out[3] = frac_1;
}
break;
@@ -1578,7 +1592,7 @@
# endif /* CUPS_RASTER_HAVE_COLORIMETRIC */
}
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
switch (cups->color_info.num_components)
{
default :
@@ -1596,7 +1610,7 @@
out[0], out[1], out[2], out[3]);
break;
}
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
}
@@ -1609,10 +1623,10 @@
frac g, /* I - Grayscale value */
frac *out) /* O - Device colors */
{
-#ifdef DEBUG2
+#ifdef CUPS_DEBUG22
dprintf3("DEBUG2: cups_map_gray(%p, %d, %p)\n",
pdev, g, out);
-#endif /* DEBUG2 */
+#endif /* CUPS_DEBUG22 */
/*
* Just use the CMYK mapper...
@@ -1640,10 +1654,10 @@
int tc, tm, ty; /* Temporary color values */
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf6("DEBUG2: cups_map_rgb(%p, %p, %d, %d, %d, %p)\n",
pdev, pis, r, g, b, out);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
/*
* Compute CMYK values...
@@ -1732,17 +1746,19 @@
y = cv[2];
k = cv[3];
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf5("DEBUG2: cups_map_cmyk_color(%p, %d, %d, %d, %d)\n", pdev,
c, m, y, k);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
/*
* Setup the color info data as needed...
*/
- if (pdev->color_info.num_components == 0)
- cups_set_color_info(pdev);
+ if (pdev->color_info.num_components == 0) {
+ if (cups_set_color_info(pdev) < 0)
+ return(gx_no_color_index);
+ }
/*
* Density correct...
@@ -1862,10 +1878,10 @@
break;
}
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf9("DEBUG2: CMYK (%d,%d,%d,%d) -> CMYK %08x (%d,%d,%d,%d)\n",
c, m, y, k, (unsigned)i, ic, im, iy, ik);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
/*
* Make sure we don't get a CMYK color of 255, 255, 255, 255...
@@ -1892,21 +1908,23 @@
gx_color_value c, m, y, k, divk; /* Colors, Black & divisor */
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf3("DEBUG2: cups_map_color_rgb(%p, %d, %p)\n", pdev,
(unsigned)color, prgb);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
/*
* Setup the color info data as needed...
*/
- if (pdev->color_info.num_components == 0)
- cups_set_color_info(pdev);
+ if (pdev->color_info.num_components == 0) {
+ if (cups_set_color_info(pdev) < 0)
+ return(gx_no_color_index);
+ }
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf1("DEBUG2: COLOR %08x = ", (unsigned)color);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
/*
* Extract the color components from the color index...
@@ -2034,10 +2052,15 @@
* cups->DecodeLUT actually maps to RGBW, not CMYK...
*/
- k = cups->DecodeLUT[c3];
- c = cups->DecodeLUT[c0] + k - gx_max_color_value;
- m = cups->DecodeLUT[c1] + k - gx_max_color_value;
- y = cups->DecodeLUT[c2] + k - gx_max_color_value;
+ if (c3 == 0) {
+ c = 0;
+ m = 0;
+ y = 0;
+ } else {
+ c = cups->DecodeLUT[c0];
+ m = cups->DecodeLUT[c1];
+ y = cups->DecodeLUT[c2];
+ }
if (c > gx_max_color_value)
prgb[0] = gx_max_color_value;
@@ -2125,9 +2148,9 @@
# endif /* CUPS_RASTER_HAVE_COLORIMETRIC */
}
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf3("DEBUG2: RGB values: %d,%d,%d\n", prgb[0], prgb[1], prgb[2]);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
return (0);
}
@@ -2159,16 +2182,18 @@
g = cv[1];
b = cv[2];
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf4("DEBUG2: cups_map_rgb_color(%p, %d, %d, %d)\n", pdev, r, g, b);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
/*
* Setup the color info data as needed...
*/
- if (pdev->color_info.num_components == 0)
- cups_set_color_info(pdev);
+ if (pdev->color_info.num_components == 0) {
+ if (cups_set_color_info(pdev) < 0)
+ return(gx_no_color_index);
+ }
/*
* Do color correction as needed...
@@ -2282,20 +2307,20 @@
switch (cups->header.cupsBitsPerColor)
{
default :
- i = 0x0e;
+ i = 0x00;
break;
case 2 :
- i = 0xfc;
+ i = 0x00;
break;
case 4 :
- i = 0xfff0;
+ i = 0x0000;
break;
case 8 :
- i = 0xffffff00;
+ i = 0x00000000;
break;
#ifdef GX_COLOR_INDEX_TYPE
case 16 :
- i = 0xffffffffffff0000;
+ i = 0x0000000000000000;
break;
#endif /* GX_COLOR_INDEX_TYPE */
}
@@ -2418,10 +2443,10 @@
#endif /* GX_COLOR_INDEX_TYPE */
}
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf8("DEBUG2: CMY (%d,%d,%d) -> CMYK %08x (%d,%d,%d,%d)\n",
r, g, b, (unsigned)i, ic, im, iy, ik);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
break;
case CUPS_CSPACE_YMCK :
@@ -2677,9 +2702,9 @@
# endif /* CUPS_RASTER_HAVE_COLORIMETRIC */
}
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf4("DEBUG2: RGB %d,%d,%d = %08x\n", r, g, b, (unsigned)i);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
return (i);
}
@@ -2695,9 +2720,9 @@
{
int code; /* Return status */
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf1("DEBUG2: cups_open(%p)\n", pdev);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
dprintf("INFO: Start rendering...\n");
cups->printer_procs.get_space_params = cups_get_space_params;
@@ -2708,7 +2733,9 @@
cups->page = 1;
}
- cups_set_color_info(pdev);
+ if ((code = cups_set_color_info(pdev)) < 0) {
+ return(code);
+ }
if ((code = gdev_prn_open(pdev)) != 0)
return (code);
@@ -2741,10 +2768,10 @@
(void)fp; /* reference unused file pointer to prevent compiler warning */
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf3("DEBUG2: cups_print_pages(%p, %p, %d)\n", pdev, fp,
num_copies);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
/*
* Figure out the number of bytes per line...
@@ -2780,11 +2807,11 @@
srcbytes = gdev_prn_raster(pdev);
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf4("DEBUG2: cupsBitsPerPixel = %d, cupsWidth = %d, cupsBytesPerLine = %d, srcbytes = %d\n",
cups->header.cupsBitsPerPixel, cups->header.cupsWidth,
cups->header.cupsBytesPerLine, srcbytes);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
src = (unsigned char *)gs_malloc(pdev->memory->non_gc_memory, srcbytes, 1, "cups_print_pages");
@@ -2813,9 +2840,9 @@
{
RasterVersion = ppdFindAttr(cups->PPD, "cupsRasterVersion", NULL);
if (RasterVersion) {
-#ifdef DEBUG
+#ifdef CUPS_DEBUG2
dprintf1("DEBUG2: cupsRasterVersion = %s\n", RasterVersion->value);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG2 */
cups->cupsRasterVersion = atoi(RasterVersion->value);
if ((cups->cupsRasterVersion != 2) &&
(cups->cupsRasterVersion != 3)) {
@@ -2847,11 +2874,11 @@
num_copies = 1;
}
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf3("DEBUG2: cupsWidth = %d, cupsHeight = %d, cupsBytesPerLine = %d\n",
cups->header.cupsWidth, cups->header.cupsHeight,
cups->header.cupsBytesPerLine);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
for (copy = num_copies; copy > 0; copy --)
{
@@ -2929,10 +2956,13 @@
int xflip = 0,
yflip = 0;
int found = 0;
-
-#ifdef DEBUG
+ gs_param_string icc_pro_dummy;
+ int old_cmps = cups->color_info.num_components;
+ int old_depth = cups->color_info.depth;
+
+#ifdef CUPS_DEBUG
dprintf2("DEBUG2: cups_put_params(%p, %p)\n", pdev, plist);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
/*
* Process other options for CUPS...
@@ -3024,6 +3054,11 @@
margins_set = param_read_float_array(plist, "Margins", &arrayval) == 0;
color_set = param_read_int(plist, "cupsColorSpace", &intval) == 0 ||
param_read_int(plist, "cupsBitsPerColor", &intval) == 0;
+
+ if (!cups->user_icc) {
+ cups->user_icc = param_read_string(plist, "OutputICCProfile", &icc_pro_dummy) == 0;
+ }
+
/* We set the old dimensions to 1 if we have a color depth change, so
that memory reallocation gets forced. This is perhaps not the correct
approach to prevent crashes like in bug 690435. We keep it for the
@@ -3125,7 +3160,9 @@
cups->Profile = strdup((char *)stringval.data);
}
- cups_set_color_info(pdev);
+ if ((code = cups_set_color_info(pdev)) < 0) {
+ return(code);
+ }
/*
* Then process standard page device options...
@@ -3134,12 +3171,20 @@
if ((code = gdev_prn_put_params(pdev, plist)) < 0)
return (code);
+ /* If cups_set_color_info() changed the color model of the device we want to
+ * force the raster memory to be recreated/reinitialized
+ */
+ if (cups->color_info.num_components != old_cmps || cups->color_info.depth != old_depth) {
+ width_old = 0;
+ height_old = 0;
+ }
+ else {
/* pdev->width/height may have been changed by the call to
* gdev_prn_put_params()
*/
- width_old = pdev->width;
- height_old = pdev->height;
-
+ width_old = pdev->width;
+ height_old = pdev->height;
+ }
/*
* Update margins/sizes as needed...
*/
@@ -3150,10 +3195,10 @@
* Compute the page margins...
*/
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf2("DEBUG: Updating PageSize to [%.0f %.0f]...\n",
cups->MediaSize[0], cups->MediaSize[1]);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
memset(margins, 0, sizeof(margins));
@@ -3161,31 +3206,31 @@
if (cups->PPD != NULL)
{
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex);
dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble);
dprintf1("DEBUG2: cups->page = %d\n", cups->page);
dprintf1("DEBUG2: cups->PPD = %p\n", cups->PPD);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
backside = ppdFindAttr(cups->PPD, "cupsBackSide", NULL);
if (backside) {
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
cups->PPD->flip_duplex = 0;
}
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf1("DEBUG2: cups->PPD->flip_duplex = %d\n", cups->PPD->flip_duplex);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
backsiderequiresflippedmargins =
ppdFindAttr(cups->PPD, "APDuplexRequiresFlippedMargin", NULL);
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
if (backsiderequiresflippedmargins)
dprintf1("DEBUG2: APDuplexRequiresFlippedMargin = %s\n",
backsiderequiresflippedmargins->value);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
if (cups->header.Duplex &&
(cups->header.Tumble &&
@@ -3195,14 +3240,14 @@
xflip = 1;
if (backsiderequiresflippedmargins &&
!strcasecmp(backsiderequiresflippedmargins->value, "False")) {
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf("DEBUG2: (1) Flip: X=1 Y=0\n");
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
yflip = 0;
} else {
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf("DEBUG2: (1) Flip: X=1 Y=1\n");
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
yflip = 1;
}
}
@@ -3214,14 +3259,14 @@
xflip = 0;
if (backsiderequiresflippedmargins &&
!strcasecmp(backsiderequiresflippedmargins->value, "False")) {
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf("DEBUG2: (2) Flip: X=0 Y=1\n");
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
yflip = 1;
} else {
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf("DEBUG2: (2) Flip: X=0 Y=0\n");
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
yflip = 0;
}
}
@@ -3236,22 +3281,22 @@
xflip = 1;
if (backsiderequiresflippedmargins &&
!strcasecmp(backsiderequiresflippedmargins->value, "True")) {
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf("DEBUG2: (3) Flip: X=1 Y=0\n");
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
yflip = 0;
} else {
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf("DEBUG2: (3) Flip: X=1 Y=1\n");
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
yflip = 1;
}
}
else
{
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf("DEBUG2: (4) Flip: X=0 Y=0\n");
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
xflip = 0;
yflip = 0;
}
@@ -3272,9 +3317,9 @@
}
if (found == 0) cups->header.cupsPageSizeName[0] = '\0';
}
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf1("DEBUG2: cups->header.cupsPageSizeName = %s\n", cups->header.cupsPageSizeName);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
#endif /* CUPS_RASTER_SYNCv1 */
/*
@@ -3312,9 +3357,9 @@
* Standard size...
*/
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf1("DEBUG: size = %s\n", size->name);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
gx_device_set_media_size(pdev, size->width, size->length);
@@ -3371,9 +3416,9 @@
* Standard size in landscape orientation...
*/
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf1("DEBUG: landscape size = %s\n", size->name);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
gx_device_set_media_size(pdev, size->length, size->width);
@@ -3398,9 +3443,9 @@
* Custom size...
*/
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf("DEBUG: size = Custom\n");
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
cups->landscape = 0;
@@ -3417,10 +3462,10 @@
}
}
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf4("DEBUG: margins[] = [ %f %f %f %f ]\n",
margins[0], margins[1], margins[2], margins[3]);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
}
/*
@@ -3479,10 +3524,10 @@
* Device is open and size has changed, so reallocate...
*/
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf4("DEBUG2: Reallocating memory, [%.0f %.0f] = %dx%d pixels...\n",
pdev->MediaSize[0], pdev->MediaSize[1], width, height);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
if ((code = gdev_prn_maybe_realloc_memory((gx_device_printer *)pdev,
&sp_old,
@@ -3490,10 +3535,10 @@
transp_old))
< 0)
return (code);
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf4("DEBUG2: Reallocated memory, [%.0f %.0f] = %dx%d pixels...\n",
pdev->MediaSize[0], pdev->MediaSize[1], width, height);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
}
else
{
@@ -3501,10 +3546,10 @@
* Device isn't yet open, so just save the new width and height...
*/
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf4("DEBUG: Setting initial media size, [%.0f %.0f] = %dx%d pixels...\n",
pdev->MediaSize[0], pdev->MediaSize[1], width, height);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
pdev->width = width;
pdev->height = height;
@@ -3610,7 +3655,7 @@
cups->header.cupsWidth = cups->width;
cups->header.cupsHeight = cups->height;
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf1("DEBUG2: ppd = %p\n", cups->PPD);
dprintf2("DEBUG2: PageSize = [ %.3f %.3f ]\n",
pdev->MediaSize[0], pdev->MediaSize[1]);
@@ -3624,7 +3669,7 @@
dprintf4("DEBUG2: HWMargins = [ %.3f %.3f %.3f %.3f ]\n",
pdev->HWMargins[0], pdev->HWMargins[1],
pdev->HWMargins[2], pdev->HWMargins[3]);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
return (0);
}
@@ -3634,7 +3679,7 @@
* the required output.
*/
-private void
+private int
cups_set_color_info(gx_device *pdev) /* I - Device info */
{
int i, j, k; /* Looping vars */
@@ -3643,11 +3688,11 @@
float m[3][3]; /* Color correction matrix */
char resolution[41]; /* Resolution string */
ppd_profile_t *profile; /* Color profile information */
- int code;
+ int code = 0;
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf1("DEBUG2: cups_set_color_info(%p)\n", pdev);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
#ifndef GX_COLOR_INDEX_TYPE
if (cups->header.cupsBitsPerColor > 8)
@@ -3901,22 +3946,22 @@
cups->EncodeLUT[i] = j;
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
if (i == 0 || cups->EncodeLUT[i] != cups->EncodeLUT[i - 1])
dprintf2("DEBUG2: cups->EncodeLUT[%d] = %d\n", i, (int)cups->EncodeLUT[i]);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
}
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf1("DEBUG2: cups->EncodeLUT[0] = %d\n", (int)cups->EncodeLUT[0]);
dprintf2("DEBUG2: cups->EncodeLUT[%d] = %d\n", gx_max_color_value,
(int)cups->EncodeLUT[gx_max_color_value]);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
for (i = 0; i < cups->color_info.dither_grays; i ++)
cups->DecodeLUT[i] = gx_max_color_value * i / max_lut;
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf2("DEBUG: num_components = %d, depth = %d\n",
cups->color_info.num_components, cups->color_info.depth);
dprintf2("DEBUG: cupsColorSpace = %d, cupsColorOrder = %d\n",
@@ -3927,7 +3972,7 @@
cups->color_info.max_gray, cups->color_info.dither_grays);
dprintf2("DEBUG: max_color = %d, dither_colors = %d\n",
cups->color_info.max_color, cups->color_info.dither_colors);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
/*
* Set the color profile as needed...
@@ -3941,9 +3986,9 @@
if (cups->Profile && cups->header.cupsBitsPerColor == 8)
#endif /* dev_t_proc_encode_color */
{
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf1("DEBUG: Using user-defined profile \"%s\"...\n", cups->Profile);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
if (sscanf(cups->Profile, "%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f", &d, &g,
m[0] + 0, m[0] + 1, m[0] + 2,
@@ -3998,9 +4043,9 @@
if (i < cups->PPD->num_profiles)
{
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf("DEBUG: Using color profile in PPD file!\n");
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
cups->HaveProfile = 1;
@@ -4019,11 +4064,11 @@
{
cups->Matrix[i][j][k] = (int)((float)k * m[i][j] + 0.5);
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
if ((k & 4095) == 0)
dprintf4("DEBUG2: cups->Matrix[%d][%d][%d] = %d\n",
i, j, k, cups->Matrix[i][j][k]);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
}
@@ -4033,10 +4078,10 @@
pow((float)k / (float)CUPS_MAX_VALUE, g) +
0.5);
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
if ((k & 4095) == 0)
dprintf2("DEBUG2: cups->Density[%d] = %d\n", k, cups->Density[k]);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
}
}
else
@@ -4044,23 +4089,90 @@
for (k = 0; k <= CUPS_MAX_VALUE; k ++)
cups->Density[k] = k;
}
- /* Set up the ICC profile for ghostscript to use based upon the color space.
- This is different than the PPD profile above which appears to be some sort
- of matrix based TRC profile */
- switch (cups->header.cupsColorSpace) {
- /* Use RGB profile for this */
- case CUPS_CSPACE_RGBW:
- if (pdev->icc_struct == NULL) {
- pdev->icc_struct = gsicc_new_device_profile_array(pdev->memory);
- }
- if (pdev->icc_struct->device_profile[gsDEFAULTPROFILE] == NULL) {
- code = gsicc_set_device_profile(pdev, pdev->memory,
- DEFAULT_RGB_ICC, gsDEFAULTPROFILE);
- }
- break;
- default:
- break;
+ if (!cups->user_icc) {
+ /* Set up the ICC profile for ghostscript to use based upon the color space.
+ This is different than the PPD profile above which appears to be some sort
+ of matrix based TRC profile */
+ switch (cups->header.cupsColorSpace)
+ {
+ default :
+ case CUPS_CSPACE_RGBW :
+ case CUPS_CSPACE_RGB :
+ case CUPS_CSPACE_RGBA :
+ case CUPS_CSPACE_CMY :
+ case CUPS_CSPACE_YMC :
+# ifdef CUPS_RASTER_HAVE_COLORIMETRIC
+ case CUPS_CSPACE_CIELab :
+ case CUPS_CSPACE_ICC1 :
+ case CUPS_CSPACE_ICC2 :
+ case CUPS_CSPACE_ICC3 :
+ case CUPS_CSPACE_ICC4 :
+ case CUPS_CSPACE_ICC5 :
+ case CUPS_CSPACE_ICC6 :
+ case CUPS_CSPACE_ICC7 :
+ case CUPS_CSPACE_ICC8 :
+ case CUPS_CSPACE_ICC9 :
+ case CUPS_CSPACE_ICCA :
+ case CUPS_CSPACE_ICCB :
+ case CUPS_CSPACE_ICCC :
+ case CUPS_CSPACE_ICCD :
+ case CUPS_CSPACE_ICCE :
+ case CUPS_CSPACE_ICCF :
+# endif /* CUPS_RASTER_HAVE_COLORIMETRIC */
+ if (!pdev->icc_struct || (pdev->icc_struct &&
+ pdev->icc_struct->device_profile[gsDEFAULTPROFILE]->data_cs != gsRGB)) {
+
+ if (pdev->icc_struct) {
+ rc_decrement(pdev->icc_struct, "cups_set_color_info");
+ }
+ pdev->icc_struct = gsicc_new_device_profile_array(pdev->memory);
+
+ code = gsicc_set_device_profile(pdev, pdev->memory,
+ (char *)DEFAULT_RGB_ICC, gsDEFAULTPROFILE);
+ }
+ break;
+
+ case CUPS_CSPACE_W :
+ case CUPS_CSPACE_WHITE :
+ case CUPS_CSPACE_K :
+ case CUPS_CSPACE_GOLD :
+ case CUPS_CSPACE_SILVER :
+ if (!pdev->icc_struct || (pdev->icc_struct &&
+ pdev->icc_struct->device_profile[gsDEFAULTPROFILE]->data_cs != gsGRAY)) {
+
+ if (pdev->icc_struct) {
+ rc_decrement(pdev->icc_struct, "cups_set_color_info");
+ }
+ pdev->icc_struct = gsicc_new_device_profile_array(pdev->memory);
+
+ code = gsicc_set_device_profile(pdev, pdev->memory->non_gc_memory,
+ (char *)DEFAULT_GRAY_ICC, gsDEFAULTPROFILE);
+ }
+ break;
+ case CUPS_CSPACE_KCMYcm :
+# ifdef CUPS_RASTER_HAVE_COLORIMETRIC
+ case CUPS_CSPACE_CIEXYZ :
+#endif
+ case CUPS_CSPACE_CMYK :
+ case CUPS_CSPACE_YMCK :
+ case CUPS_CSPACE_KCMY :
+ case CUPS_CSPACE_GMCK :
+ case CUPS_CSPACE_GMCS :
+ if (!pdev->icc_struct || (pdev->icc_struct &&
+ pdev->icc_struct->device_profile[gsDEFAULTPROFILE]->data_cs != gsCMYK)) {
+
+ if (pdev->icc_struct) {
+ rc_decrement(pdev->icc_struct, "cups_set_color_info");
+ }
+ pdev->icc_struct = gsicc_new_device_profile_array(pdev->memory);
+
+ code = gsicc_set_device_profile(pdev, pdev->memory,
+ (char *)DEFAULT_CMYK_ICC, gsDEFAULTPROFILE);
+ }
+ break;
+ }
}
+ return(code);
}
/*
@@ -4099,19 +4211,19 @@
ystart, yend, ystep; /* Loop control for scanline order */
ppd_attr_t *backside = NULL;
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex);
dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble);
dprintf1("DEBUG2: cups->page = %d\n", cups->page);
dprintf1("DEBUG2: cups->PPD = %p\n", cups->PPD);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
if (cups->PPD) {
backside = ppdFindAttr(cups->PPD, "cupsBackSide", NULL);
if (backside) {
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
cups->PPD->flip_duplex = 0;
}
}
@@ -4145,10 +4257,10 @@
ystep = 1;
}
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf3("DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n",
xflip, yflip, cups->height);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
/*
* Loop through the page bitmap and write chunked pixels, reversing as
@@ -4326,19 +4438,19 @@
ystart, yend, ystep; /* Loop control for scanline order */
ppd_attr_t *backside = NULL;
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex);
dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble);
dprintf1("DEBUG2: cups->page = %d\n", cups->page);
dprintf1("DEBUG2: cups->PPD = %p\n", cups->PPD);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
if (cups->PPD) {
backside = ppdFindAttr(cups->PPD, "cupsBackSide", NULL);
if (backside) {
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
cups->PPD->flip_duplex = 0;
}
}
@@ -4372,10 +4484,10 @@
ystep = 1;
}
-#ifdef DEBUG
+#ifdef CUPS_DEBUG
dprintf3("DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n",
xflip, yflip, cups->height);
-#endif /* DEBUG */
+#endif /* CUPS_DEBUG */
/*
* Loop through the page bitmap and write banded pixels... We have