[gs-commits] rev 10969 - branches/icc_work/base

mvrhel at ghostscript.com mvrhel at ghostscript.com
Thu Mar 25 17:36:20 UTC 2010


Author: mvrhel
Date: 2010-03-25 17:36:19 +0000 (Thu, 25 Mar 2010)
New Revision: 10969

Modified:
   branches/icc_work/base/gdevp14.c
   branches/icc_work/base/gdevpbm.c
   branches/icc_work/base/gstrans.c
Log:
Fix for crash with IA3Z4663.pdf pbmraw.300  Caused by pdf14 device information not getting updated during a softmask push.

Modified: branches/icc_work/base/gdevp14.c
===================================================================
--- branches/icc_work/base/gdevp14.c	2010-03-24 21:36:20 UTC (rev 10968)
+++ branches/icc_work/base/gdevp14.c	2010-03-25 17:36:19 UTC (rev 10969)
@@ -282,8 +282,8 @@
 /* Uses color procs stack so that it can be used with clist writer */
 static int
 pdf14_update_device_color_procs_push_c(gx_device *dev,
-			      gs_transparency_color_t group_color,
-			      gs_imager_state *pis);
+			      gs_transparency_color_t group_color, int64_t icc_hashcode,
+			      gs_imager_state *pis, cmm_profile_t *iccprofile);
 
 static int
 pdf14_update_device_color_procs_pop_c(gx_device *dev,gs_imager_state *pis);
@@ -933,7 +933,6 @@
 {
     pdf14_buf *buf;
     unsigned char *curr_ptr, gray;
-    unsigned char background_init;
     
     if_debug2('v', "[v]pdf14_push_transparency_mask, idle=%d, replacing=%d\n", 
                     idle, replacing);
@@ -2758,8 +2757,8 @@
    for transparency groups */
 static int
 pdf14_update_device_color_procs_push_c(gx_device *dev,
-			      gs_transparency_color_t group_color,
-			      gs_imager_state *pis)
+			      gs_transparency_color_t group_color, int64_t icc_hashcode,
+			      gs_imager_state *pis, cmm_profile_t *icc_profile)
 {
     pdf14_device *pdevproto;
     pdf14_device *pdev = (pdf14_device *)dev;
@@ -2774,18 +2773,10 @@
     byte comp_shift[] = {0,0,0,0};
     int k;
     gs_state *pgs;
-    cmm_profile_t *cmm_icc_profile_data;
     
-    if (pis->is_gstate) {
-        pgs = (gs_state *)pis;
-        cmm_icc_profile_data = pgs->color_space->cmm_icc_profile_data;
-    } else {
-        pgs = NULL;
-        cmm_icc_profile_data = NULL;
-        if (group_color == ICC ) {
-            return gs_rethrow(gs_error_undefinedresult, 
-                "Missing ICC data");
-        }
+    if (group_color == ICC && icc_profile == NULL) {
+        return gs_rethrow(gs_error_undefinedresult, 
+            "Missing ICC data");
     }
     if_debug0('v', "[v]pdf14_update_device_color_procs_push_c\n");
    /* Check if we need to alter the device procs at this
@@ -2857,10 +2848,10 @@
             case ICC:
                 /* Check if the profile is different. */
                 if (pis->icc_manager->device_profile->hashcode != 
-                                        cmm_icc_profile_data->hashcode) {
+                                        icc_profile->hashcode) {
                     update_color_info = true;
-                    new_num_comps = cmm_icc_profile_data->num_comps;
-                    new_depth = cmm_icc_profile_data->num_comps*8;
+                    new_num_comps = icc_profile->num_comps;
+                    new_depth = icc_profile->num_comps*8;
                     switch (new_num_comps) {
                     case 1:
                         new_polarity = GX_CINFO_POLARITY_ADDITIVE;
@@ -2930,7 +2921,7 @@
                device in the ICC manager.  We already stored in in pdf14_parent_color_t.
                That will be stored in the clist and restored during the reading phase. */
            if (group_color == ICC) {
-                pis->icc_manager->device_profile = cmm_icc_profile_data;
+                pis->icc_manager->device_profile = icc_profile;
             }
             if (pdev->ctx) {
                pdev->ctx->additive = new_additive; 
@@ -5371,7 +5362,9 @@
                     (strcmp(pdev->dname, "pdf14clistcmykspot") == 0);
                 if (!sep_target)
                    code = pdf14_update_device_color_procs_push_c(dev,
-			          pdf14pct->params.group_color,pis);
+                                  pdf14pct->params.group_color,
+			          pdf14pct->params.icc_hash, pis,
+                                  pdf14pct->params.iccprofile);
                /* Note that our initial device buffer may have had a different color space
                    than the first transparency group.  In such a case, we really should force
                    this first group to be isolated, anytime that the parent color space is 
@@ -5397,7 +5390,9 @@
                 pdf14_push_parent_color(dev, pis);
                 /* Now update the device procs */
                code = pdf14_update_device_color_procs_push_c(dev,
-			      pdf14pct->params.group_color,pis);
+                                  pdf14pct->params.group_color,
+			          pdf14pct->params.icc_hash, pis,
+                                  pdf14pct->params.iccprofile);
                /* Also, if the BC is a value that may end up as
                   something other than transparent. We must
                   use the parent colors bounding box in

Modified: branches/icc_work/base/gdevpbm.c
===================================================================
--- branches/icc_work/base/gdevpbm.c	2010-03-24 21:36:20 UTC (rev 10968)
+++ branches/icc_work/base/gdevpbm.c	2010-03-25 17:36:19 UTC (rev 10969)
@@ -559,6 +559,7 @@
                       gs_memory_t *memory, gx_image_enum_common_t **pinfo)
 {
     gx_device_pbm * const bdev = (gx_device_pbm *)dev;
+    bool has_gray_icc;
 
     /* Conservatively guesses whether this operation causes color usage 
        that might not be otherwise captured by ppm_map_color_rgb. */
@@ -569,7 +570,14 @@
 	    const gs_pixel_image_t *pim1 = (const gs_pixel_image_t *)pim;
 
 	    if (pim1->ColorSpace) {
-		if (gs_color_space_get_index(pim1->ColorSpace) == gs_color_space_index_DeviceGray) {
+                has_gray_icc = false;
+                if (pim1->ColorSpace->cmm_icc_profile_data) {
+                    if (pim1->ColorSpace->cmm_icc_profile_data->num_comps == 1) {
+                        has_gray_icc = true;
+                    } 
+                }
+		if (gs_color_space_get_index(pim1->ColorSpace) == 
+                            gs_color_space_index_DeviceGray || has_gray_icc) {
 		    if (pim1->BitsPerComponent > 1)
 			bdev->uses_color |= 1;
 		} else 

Modified: branches/icc_work/base/gstrans.c
===================================================================
--- branches/icc_work/base/gstrans.c	2010-03-24 21:36:20 UTC (rev 10968)
+++ branches/icc_work/base/gstrans.c	2010-03-25 17:36:19 UTC (rev 10969)
@@ -171,7 +171,6 @@
 void
 gs_trans_group_params_init(gs_transparency_group_params_t *ptgp)
 {
-
     ptgp->ColorSpace = NULL;	/* bogus, but can't do better */
     ptgp->Isolated = false;
     ptgp->Knockout = false;
@@ -188,9 +187,6 @@
     gs_pdf14trans_params_t params = { 0 };
     const gs_color_space *blend_color_space;
     gs_imager_state * pis = (gs_imager_state *)pgs;
-
-
-
     /*
      * Put parameters into a compositor parameter and then call the
      * create_compositor.  This will pass the data to the PDF 1.4
@@ -203,31 +199,22 @@
     params.opacity = pgs->opacity;
     params.shape = pgs->shape;
     params.blend_mode = pgs->blend_mode;
-
     /* The blending procs must be based upon the current color space */
     /* Note:  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 */ 
-
     /* Note that we currently will use the concrete space for any space other than a 
         device space.  However, if the device is a sep device it will blend
         in DeviceN color space as required.  */
-
     if (gs_color_space_get_index(pgs->color_space) <= gs_color_space_index_DeviceCMYK) {
-
         blend_color_space = pgs->color_space;
-
     } else {
-
        /* ICC and CIE based color space.  With upcoming code changes
           all CIE based spaces will actually be ICC based spaces and
           ICC spaces are already concrete. So this will return the
           ICC color space. */
-
         blend_color_space = cs_concrete_space(pgs->color_space, pis);
-
     }
-
     /* Note that if the /CS parameter was not present in the push 
        of the transparency group, then we must actually inherent 
        the previous group color space, or the color space of the
@@ -235,32 +222,23 @@
        to set it as a unknown type for clist writing, as we .  We will later 
        during clist reading 
        */
-
     if (ptgp->ColorSpace == NULL) {
-
         params.group_color = UNKNOWN;
         params.group_color_numcomps = 0;
-    
     } else {
-
         if ( gs_color_space_is_ICC(blend_color_space) ) {
-
             /* Blending space is ICC based.  If we 
                are doing c-list rendering we will need
                to write this color space into the clist.
                MJV ToDo.
                */
-
             params.group_color = ICC;
             params.group_color_numcomps = 
                 blend_color_space->cmm_icc_profile_data->num_comps;
-
             /* Get the ICC profile */
-
             params.iccprofile = blend_color_space->cmm_icc_profile_data;
-
+            params.icc_hash = blend_color_space->cmm_icc_profile_data->hashcode;
         } else {
-
             switch (cs_num_components(blend_color_space)) {
                 case 1:				
                     params.group_color = GRAY_SCALE;       
@@ -275,28 +253,20 @@
                     params.group_color_numcomps = 4; 
                 break;
                 default:
-                    
                     /* We can end up here if we are in
                        a deviceN color space and 
                        we have a sep output device */
-
                     params.group_color = DEVICEN;
                     params.group_color_numcomps = cs_num_components(blend_color_space);
-
                 break;
-
              }  
-
         }
-
     }
-
 #ifdef DEBUG
     if (gs_debug_c('v')) {
 	static const char *const cs_names[] = {
 	    GS_COLOR_SPACE_TYPE_NAMES
 	};
-
 	dlprintf6("[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);
 	if (ptgp->ColorSpace)
@@ -309,7 +279,6 @@
 		 ptgp->Isolated, ptgp->Knockout);
     }
 #endif
-
     params.bbox = *pbbox;
     return gs_state_update_pdf14trans(pgs, &params);
 }



More information about the gs-commits mailing list