[gs-commits] rev 11613 - trunk/gs/base

ray at ghostscript.com ray at ghostscript.com
Fri Aug 6 20:21:12 UTC 2010


Author: ray
Date: 2010-08-06 20:21:11 +0000 (Fri, 06 Aug 2010)
New Revision: 11613

Modified:
   trunk/gs/base/gsptype1.c
   trunk/gs/base/gxcolor2.h
   trunk/gs/base/gxpcmap.c
Log:
Fix segfault seen with fts_17_1704.pdf when the clist playback of patterns
that had been stored as clists were attempted to be read from the clist
as bitmaps. This happened when -dMaxPatternBitmap=1000000 was used which
is smaller than the default, confusing a HACK that attempted to force
the use of the pattern-clist mode. Also remove some #if 0 idle code.


Modified: trunk/gs/base/gsptype1.c
===================================================================
--- trunk/gs/base/gsptype1.c	2010-08-06 17:22:16 UTC (rev 11612)
+++ trunk/gs/base/gsptype1.c	2010-08-06 20:21:11 UTC (rev 11613)
@@ -290,6 +290,7 @@
 	      inst.size.x, inst.size.y);
     /* Absent other information, instances always require a mask. */
     inst.uses_mask = true;
+    inst.is_clist = false;	/* automatically set clist (don't force use) */
     gx_translate_to_fixed(saved, float2fixed_rounded(inst.step_matrix.tx - bbox.p.x),
 			         float2fixed_rounded(inst.step_matrix.ty - bbox.p.y));
     inst.step_matrix.tx = bbox.p.x;
@@ -1491,7 +1492,7 @@
 
 
 
-/* Write a pattern into command list, possibly dividing intoi portions. */
+/* Write a pattern into command list, possibly dividing into portions. */
 int
 gx_dc_pattern_write(
     const gx_device_color *         pdevc,
@@ -1816,36 +1817,19 @@
 	size_c = buf.size_c;
 	ptile->tbits.size.x = size_b; /* HACK: Use unrelated field for saving size_b between calls. */
 	ptile->tbits.size.y = size_c; /* HACK: Use unrelated field for saving size_c between calls. */
-	{   /* HACK: Artificial arguments for gx_pattern_accum_alloc 
-	       to force a clist-based accummulator. 
-	       A better way would be to split gx_pattern_accum_alloc.
-	     */
+	{
 	    gs_state state;
 	    gs_pattern1_instance_t inst;
 
 	    memset(&state, 0, sizeof(state));
 	    memset(&inst, 0, sizeof(inst));
-#	    if 0 /* wrong. Currently PaintType 2 can't pass here. */
-	    if (buf.paint_type == 2) {
-		/* Convert to a raster pattern cell cropped with the current band. */
-		gx_device_memory *mdev = gs_alloc_struct(mem, gx_device_memory,
-				       &st_device_memory,
-				       "gx_dc_pattern_read");
-
-		if (mdev == 0)
-		    return_error(gs_error_VMerror);
-		gs_make_mem_device(mdev, gdev_mem_device_for_bits(1), mem, -1, NULL);
-		state.device = (gx_device *)mdev;
-		inst.template.PaintType = 2;
-	    } else 
-#	    endif
-	    {
+	    /* NB: Currently PaintType 2 can't pass here. */
 		state.device = (gx_device *)dev; /* Break 'const'. */
 		inst.template.PaintType = 1;
-	    }
 	    inst.size.x = buf.size.x;
 	    inst.size.y = buf.size.y;
 	    inst.saved = &state;
+	    inst.is_clist = buf.is_clist;	/* tell gx_pattern_accum_alloc to use clist */
 	    ptile->cdev = (gx_device_clist *)gx_pattern_accum_alloc(mem, mem, 
 			       &inst, "gx_dc_pattern_read");
 	    if (ptile->cdev == NULL)

Modified: trunk/gs/base/gxcolor2.h
===================================================================
--- trunk/gs/base/gxcolor2.h	2010-08-06 17:22:16 UTC (rev 11612)
+++ trunk/gs/base/gxcolor2.h	2010-08-06 20:21:11 UTC (rev 11613)
@@ -83,6 +83,7 @@
      * for bitmap patterns that don't have explicit transparent pixels.
      */
     bool uses_mask;	        /* if true, pattern mask must be created */
+    bool is_clist;		/* if false, automatically determine and set, if true, use_clist */
     gs_int_point size;		/* in device coordinates */
     gx_bitmap_id id;		/* key for cached bitmap (= id of mask) */
 };

Modified: trunk/gs/base/gxpcmap.c
===================================================================
--- trunk/gs/base/gxpcmap.c	2010-08-06 17:22:16 UTC (rev 11612)
+++ trunk/gs/base/gxpcmap.c	2010-08-06 20:21:11 UTC (rev 11613)
@@ -215,11 +215,10 @@
 	pattern_manage))((gx_device *)pinst->saved->device, 
 	0, pinst, pattern_manage__can_accum) == 1)
 	force_no_clist = 1;
-
     /* Do not allow pattern to be a clist if it uses transparency.  We
        will want to fix this at some point */
 
-    if (force_no_clist || size < max_pattern_bitmap || pinst->template.PaintType != 1 || 
+    if (force_no_clist || (size < max_pattern_bitmap && !pinst->is_clist) || pinst->template.PaintType != 1 || 
                         pinst->template.uses_transparency ) {
 
 	gx_device_pattern_accum *adev = gs_alloc_struct(mem, gx_device_pattern_accum,
@@ -227,6 +226,11 @@
 
 	if (adev == 0)
 	    return 0;
+#ifdef DEBUG
+	if (pinst->is_clist)
+	    eprintf("not using clist even though clist is requested\n");
+#endif
+	pinst->is_clist = false;
 	gx_device_init((gx_device *)adev,
 		       (const gx_device *)&gs_pattern_accum_device,
 		       mem, true);
@@ -259,6 +263,7 @@
 	    gs_free_object(mem, cdev, cname);
 	    return 0;
 	}
+	pinst->is_clist = true;
 	memset(cdev, 0, sizeof(*cdev));
 	cwdev->params_size = sizeof(gx_device_clist);
 	cwdev->static_procs = NULL;



More information about the gs-commits mailing list