Updated upstream fix for gdevcups RGBW handling (Ghostscript bug #691922).

This commit is contained in:
Tim Waugh 2011-08-22 10:56:09 +01:00
parent 41ebc2cdb2
commit ea33f65ef3
2 changed files with 82 additions and 43 deletions

View File

@ -1,6 +1,6 @@
diff -up ghostscript-9.04/cups/gdevcups.c.cups-rgbw ghostscript-9.04/cups/gdevcups.c diff -up ghostscript-9.04/cups/gdevcups.c.cups-rgbw ghostscript-9.04/cups/gdevcups.c
--- ghostscript-9.04/cups/gdevcups.c.cups-rgbw 2011-08-16 14:47:10.311813968 +0100 --- ghostscript-9.04/cups/gdevcups.c.cups-rgbw 2011-08-05 12:12:21.000000000 +0100
+++ ghostscript-9.04/cups/gdevcups.c 2011-08-16 14:48:02.291224871 +0100 +++ ghostscript-9.04/cups/gdevcups.c 2011-08-22 10:54:24.614010581 +0100
@@ -225,6 +225,7 @@ typedef struct gx_device_cups_s @@ -225,6 +225,7 @@ typedef struct gx_device_cups_s
unsigned short EncodeLUT[gx_max_color_value + 1];/* RGB value to output color LUT */ unsigned short EncodeLUT[gx_max_color_value + 1];/* RGB value to output color LUT */
int Density[CUPS_MAX_VALUE + 1];/* Density LUT */ int Density[CUPS_MAX_VALUE + 1];/* Density LUT */
@ -17,7 +17,7 @@ diff -up ghostscript-9.04/cups/gdevcups.c.cups-rgbw ghostscript-9.04/cups/gdevcu
3 /* cupsRasterVersion */ 3 /* cupsRasterVersion */
}; };
@@ -1183,15 +1185,18 @@ cups_map_cmyk(gx_device *pdev, /* I - D @@ -1182,15 +1184,18 @@ cups_map_cmyk(gx_device *pdev, /* I - D
case CUPS_CSPACE_RGB : case CUPS_CSPACE_RGB :
case CUPS_CSPACE_RGBW : case CUPS_CSPACE_RGBW :
@ -44,7 +44,7 @@ diff -up ghostscript-9.04/cups/gdevcups.c.cups-rgbw ghostscript-9.04/cups/gdevcu
} }
if (c0 < 0) if (c0 < 0)
@@ -1213,11 +1218,12 @@ cups_map_cmyk(gx_device *pdev, /* I - D @@ -1212,11 +1217,12 @@ cups_map_cmyk(gx_device *pdev, /* I - D
out[2] = frac_1 - (frac)cups->Density[c2]; out[2] = frac_1 - (frac)cups->Density[c2];
if (cups->header.cupsColorSpace == CUPS_CSPACE_RGBW) { if (cups->header.cupsColorSpace == CUPS_CSPACE_RGBW) {
@ -62,7 +62,7 @@ diff -up ghostscript-9.04/cups/gdevcups.c.cups-rgbw ghostscript-9.04/cups/gdevcu
} }
break; break;
@@ -2035,10 +2041,15 @@ cups_map_color_rgb(gx_device *pdev, @@ -2034,10 +2040,15 @@ cups_map_color_rgb(gx_device *pdev,
* cups->DecodeLUT actually maps to RGBW, not CMYK... * cups->DecodeLUT actually maps to RGBW, not CMYK...
*/ */
@ -82,7 +82,7 @@ diff -up ghostscript-9.04/cups/gdevcups.c.cups-rgbw ghostscript-9.04/cups/gdevcu
if (c > gx_max_color_value) if (c > gx_max_color_value)
prgb[0] = gx_max_color_value; prgb[0] = gx_max_color_value;
@@ -2283,20 +2294,20 @@ cups_map_rgb_color(gx_device *pdev, @@ -2282,20 +2293,20 @@ cups_map_rgb_color(gx_device *pdev,
switch (cups->header.cupsBitsPerColor) switch (cups->header.cupsBitsPerColor)
{ {
default : default :
@ -108,15 +108,19 @@ diff -up ghostscript-9.04/cups/gdevcups.c.cups-rgbw ghostscript-9.04/cups/gdevcu
break; break;
#endif /* GX_COLOR_INDEX_TYPE */ #endif /* GX_COLOR_INDEX_TYPE */
} }
@@ -2930,6 +2941,7 @@ cups_put_params(gx_device *pdev, /* @@ -2929,7 +2940,10 @@ cups_put_params(gx_device *pdev, /*
int xflip = 0, int xflip = 0,
yflip = 0; yflip = 0;
int found = 0; int found = 0;
-
+ gs_param_string icc_pro_dummy; + gs_param_string icc_pro_dummy;
+ int old_cmps = cups->color_info.num_components;
+ int old_depth = cups->color_info.depth;
+
#ifdef DEBUG #ifdef DEBUG
dprintf2("DEBUG2: cups_put_params(%p, %p)\n", pdev, plist); dprintf2("DEBUG2: cups_put_params(%p, %p)\n", pdev, plist);
@@ -3025,6 +3037,11 @@ cups_put_params(gx_device *pdev, /* #endif /* DEBUG */
@@ -3024,6 +3038,11 @@ cups_put_params(gx_device *pdev, /*
margins_set = param_read_float_array(plist, "Margins", &arrayval) == 0; margins_set = param_read_float_array(plist, "Margins", &arrayval) == 0;
color_set = param_read_int(plist, "cupsColorSpace", &intval) == 0 || color_set = param_read_int(plist, "cupsColorSpace", &intval) == 0 ||
param_read_int(plist, "cupsBitsPerColor", &intval) == 0; param_read_int(plist, "cupsBitsPerColor", &intval) == 0;
@ -128,7 +132,31 @@ diff -up ghostscript-9.04/cups/gdevcups.c.cups-rgbw ghostscript-9.04/cups/gdevcu
/* We set the old dimensions to 1 if we have a color depth change, so /* 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 that memory reallocation gets forced. This is perhaps not the correct
approach to prevent crashes like in bug 690435. We keep it for the approach to prevent crashes like in bug 690435. We keep it for the
@@ -4045,22 +4062,80 @@ cups_set_color_info(gx_device *pdev) /* @@ -3134,12 +3153,20 @@ cups_put_params(gx_device *pdev, /*
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...
*/
@@ -4044,22 +4071,88 @@ cups_set_color_info(gx_device *pdev) /*
for (k = 0; k <= CUPS_MAX_VALUE; k ++) for (k = 0; k <= CUPS_MAX_VALUE; k ++)
cups->Density[k] = k; cups->Density[k] = k;
} }
@ -156,12 +184,11 @@ diff -up ghostscript-9.04/cups/gdevcups.c.cups-rgbw ghostscript-9.04/cups/gdevcu
+ { + {
+ default : + default :
+ case CUPS_CSPACE_RGBW : + case CUPS_CSPACE_RGBW :
+ case CUPS_CSPACE_W :
+ case CUPS_CSPACE_WHITE :
+ case CUPS_CSPACE_RGB : + case CUPS_CSPACE_RGB :
+ case CUPS_CSPACE_RGBA : + case CUPS_CSPACE_RGBA :
+ case CUPS_CSPACE_CMY :
+ case CUPS_CSPACE_YMC :
+# ifdef CUPS_RASTER_HAVE_COLORIMETRIC +# ifdef CUPS_RASTER_HAVE_COLORIMETRIC
+ case CUPS_CSPACE_CIEXYZ :
+ case CUPS_CSPACE_CIELab : + case CUPS_CSPACE_CIELab :
+ case CUPS_CSPACE_ICC1 : + case CUPS_CSPACE_ICC1 :
+ case CUPS_CSPACE_ICC2 : + case CUPS_CSPACE_ICC2 :
@ -179,48 +206,57 @@ diff -up ghostscript-9.04/cups/gdevcups.c.cups-rgbw ghostscript-9.04/cups/gdevcu
+ case CUPS_CSPACE_ICCE : + case CUPS_CSPACE_ICCE :
+ case CUPS_CSPACE_ICCF : + case CUPS_CSPACE_ICCF :
+# endif /* CUPS_RASTER_HAVE_COLORIMETRIC */ +# endif /* CUPS_RASTER_HAVE_COLORIMETRIC */
+ if (pdev->icc_struct == NULL) { + 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); + pdev->icc_struct = gsicc_new_device_profile_array(pdev->memory);
+ } +
+ if (pdev->icc_struct->device_profile[gsDEFAULTPROFILE]) { + code = gsicc_set_device_profile(pdev, pdev->memory,
+ rc_decrement(pdev->icc_struct->device_profile[gsDEFAULTPROFILE], "cups_set_color_info"); + (char *)DEFAULT_RGB_ICC, gsDEFAULTPROFILE);
+ pdev->icc_struct->device_profile[gsDEFAULTPROFILE] = NULL; + }
+ }
+ code = gsicc_set_device_profile(pdev, pdev->memory,
+ (char *)DEFAULT_RGB_ICC, gsDEFAULTPROFILE);
+ break; + break;
+ +
+ case CUPS_CSPACE_W :
+ case CUPS_CSPACE_WHITE :
+ case CUPS_CSPACE_K : + case CUPS_CSPACE_K :
+ if (pdev->icc_struct == NULL) {
+ pdev->icc_struct = gsicc_new_device_profile_array(pdev->memory);
+ }
+ if (pdev->icc_struct->device_profile[gsDEFAULTPROFILE]) {
+ rc_decrement(pdev->icc_struct->device_profile[gsDEFAULTPROFILE], "cups_set_color_info");
+ pdev->icc_struct->device_profile[gsDEFAULTPROFILE] = NULL;
+ }
+ code = gsicc_set_device_profile(pdev, pdev->memory,
+ (char *)DEFAULT_GRAY_ICC, gsDEFAULTPROFILE);
+ break;
+ case CUPS_CSPACE_GOLD : + case CUPS_CSPACE_GOLD :
+ case CUPS_CSPACE_SILVER : + case CUPS_CSPACE_SILVER :
+ case CUPS_CSPACE_CMY : + if (!pdev->icc_struct || (pdev->icc_struct &&
+ case CUPS_CSPACE_YMC : + 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 : + case CUPS_CSPACE_KCMYcm :
+# ifdef CUPS_RASTER_HAVE_COLORIMETRIC
+ case CUPS_CSPACE_CIEXYZ :
+#endif
+ case CUPS_CSPACE_CMYK : + case CUPS_CSPACE_CMYK :
+ case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_YMCK :
+ case CUPS_CSPACE_KCMY : + case CUPS_CSPACE_KCMY :
+ case CUPS_CSPACE_GMCK : + case CUPS_CSPACE_GMCK :
+ case CUPS_CSPACE_GMCS : + case CUPS_CSPACE_GMCS :
+ if (pdev->icc_struct == NULL) { + 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); + pdev->icc_struct = gsicc_new_device_profile_array(pdev->memory);
+ } +
+ if (pdev->icc_struct->device_profile[gsDEFAULTPROFILE]) { + code = gsicc_set_device_profile(pdev, pdev->memory,
+ rc_decrement(pdev->icc_struct->device_profile[gsDEFAULTPROFILE], "cups_set_color_info"); + (char *)DEFAULT_CMYK_ICC, gsDEFAULTPROFILE);
+ pdev->icc_struct->device_profile[gsDEFAULTPROFILE] = NULL; + }
+ } + break;
+ code = gsicc_set_device_profile(pdev, pdev->memory,
+ (char *)DEFAULT_CMYK_ICC, gsDEFAULTPROFILE);
+ break;
+ } + }
} }
} }

View File

@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer
Name: ghostscript Name: ghostscript
Version: %{gs_ver} Version: %{gs_ver}
Release: 2%{?dist} Release: 3%{?dist}
# Included CMap data is Redistributable, no modification permitted, # Included CMap data is Redistributable, no modification permitted,
# see http://bugzilla.redhat.com/487510 # see http://bugzilla.redhat.com/487510
@ -335,6 +335,9 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/libgs.so %{_libdir}/libgs.so
%changelog %changelog
* Mon Aug 22 2011 Tim Waugh <twaugh@redhat.com> 9.04-3
- Updated upstream fix for gdevcups RGBW handling (Ghostscript bug #691922).
* Tue Aug 16 2011 Tim Waugh <twaugh@redhat.com> 9.04-2 * Tue Aug 16 2011 Tim Waugh <twaugh@redhat.com> 9.04-2
- Applied upstream fix for gdevcups handling of RGBW (Ghostscript - Applied upstream fix for gdevcups handling of RGBW (Ghostscript
bug #691922). bug #691922).