[gs-cvs] rev 8019 - in branches/gs-esp-gpl-merger: imdi lib src toolbin/tests

till at ghostscript.com till at ghostscript.com
Tue Jun 5 08:53:52 PDT 2007


Author: till
Date: 2007-06-05 08:53:48 -0700 (Tue, 05 Jun 2007)
New Revision: 8019

Modified:
   branches/gs-esp-gpl-merger/imdi/arch.h
   branches/gs-esp-gpl-merger/lib/gs_devn.ps
   branches/gs-esp-gpl-merger/lib/pdfopt.ps
   branches/gs-esp-gpl-merger/src/devs.mak
   branches/gs-esp-gpl-merger/src/gdevbit.c
   branches/gs-esp-gpl-merger/src/gdevdevn.c
   branches/gs-esp-gpl-merger/src/gdevdflt.c
   branches/gs-esp-gpl-merger/src/gdevnfwd.c
   branches/gs-esp-gpl-merger/src/gdevpdfb.c
   branches/gs-esp-gpl-merger/src/gdevpsd.c
   branches/gs-esp-gpl-merger/src/gdevwts.c
   branches/gs-esp-gpl-merger/src/gscolor3.c
   branches/gs-esp-gpl-merger/src/gsptype2.c
   branches/gs-esp-gpl-merger/src/gsptype2.h
   branches/gs-esp-gpl-merger/src/gsshade.c
   branches/gs-esp-gpl-merger/src/gsshade.h
   branches/gs-esp-gpl-merger/src/gxclmem.c
   branches/gs-esp-gpl-merger/src/gxclread.c
   branches/gs-esp-gpl-merger/src/gxcpath.c
   branches/gs-esp-gpl-merger/src/gxdevcli.h
   branches/gs-esp-gpl-merger/src/gxdevice.h
   branches/gs-esp-gpl-merger/src/gxfill.c
   branches/gs-esp-gpl-merger/src/gximask.c
   branches/gs-esp-gpl-merger/src/gxpath.h
   branches/gs-esp-gpl-merger/src/gxshade1.c
   branches/gs-esp-gpl-merger/src/gxshade4.h
   branches/gs-esp-gpl-merger/src/gxshade6.c
   branches/gs-esp-gpl-merger/src/lib.mak
   branches/gs-esp-gpl-merger/src/openvms.mak
   branches/gs-esp-gpl-merger/src/watcw32.mak
   branches/gs-esp-gpl-merger/toolbin/tests/fuzzy.c
Log:
Merged in changes from trunk up to rev 8018.


Modified: branches/gs-esp-gpl-merger/imdi/arch.h
===================================================================
--- branches/gs-esp-gpl-merger/imdi/arch.h	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/imdi/arch.h	2007-06-05 15:53:48 UTC (rev 8019)
@@ -14,7 +14,7 @@
 #ifdef ALLOW64
 
 /* Detect machine/compiler specifics here */
-#if defined(NT)
+#if defined(NT) || defined(__WIN32__)
 #define longlong __int64
 #else	/* !NT, assume standard */
 #define longlong long long

Modified: branches/gs-esp-gpl-merger/lib/gs_devn.ps
===================================================================
--- branches/gs-esp-gpl-merger/lib/gs_devn.ps	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/lib/gs_devn.ps	2007-06-05 15:53:48 UTC (rev 8019)
@@ -200,10 +200,17 @@
       {
         .usealternate
           {
-            pop currentcolor
+            pop
+    	    % "QuarkXPress pictwpstops filter 1.0" generates a document, 
+    	    % which places an extra value on the operand stack
+	    % and tintTransform replaces it - see bug 549307 
+	    % and the test case of bug 688584.
+	    % Here we use mark...cleartomark for providing a tolerance.
+            mark 
+            true % An extra value for bogus Adobe tintTransform 
+            currentcolor
             currentcolorspace 3 get exec
-            currentcolorspace 2 get
-            //clear_setcolor_operands exec
+            cleartomark
           }
           { pop }
         ifelse

Modified: branches/gs-esp-gpl-merger/lib/pdfopt.ps
===================================================================
--- branches/gs-esp-gpl-merger/lib/pdfopt.ps	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/lib/pdfopt.ps	2007-06-05 15:53:48 UTC (rev 8019)
@@ -387,7 +387,7 @@
     dup /OpenAction .knownget { omvisitnopage } if
     Trailer /Encrypt .knownget { omvisit } if
     dup /Threads .knownget {
-      omforce { omvisit } forall
+        omforce dup //null ne { { omvisit } forall } { pop } ifelse
     } if
     dup /AcroForm .knownget { omvisit } if
     pop

Modified: branches/gs-esp-gpl-merger/src/devs.mak
===================================================================
--- branches/gs-esp-gpl-merger/src/devs.mak	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/devs.mak	2007-06-05 15:53:48 UTC (rev 8019)
@@ -1538,7 +1538,7 @@
 $(DD)wtscmyk.dev : $(DEVS_MAK) $(wts_) $(GLD)page.dev
 	$(SETPDEV2) $(DD)wtscmyk $(wts_)
 
-$(DD)wtsimdi.dev : $(DEVS_MAK) $(wts_) $(GLD)page.dev
+$(DD)wtsimdi.dev : $(DEVS_MAK) $(wts_) $(GLD)sicclib.dev $(GLD)simdi.dev $(GLD)page.dev
 	$(SETPDEV2) $(DD)wtsimdi $(wts_)
 	$(ADDMOD) $(DD)wtsimdi -include $(GLD)sicclib
 	$(ADDMOD) $(DD)wtsimdi -include $(GLD)simdi

Modified: branches/gs-esp-gpl-merger/src/gdevbit.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gdevbit.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gdevbit.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -263,6 +263,8 @@
         0 ,
         0 ,
         0 ,
+	0,
+	0,
         { 
             gx_default_install,
             gx_default_begin_page,
@@ -621,7 +623,7 @@
     int line_size = gdev_mem_bytes_per_scan_line((gx_device *) pdev);
     byte *in = gs_alloc_bytes(pdev->memory, line_size, "bit_print_page(in)");
     byte *data;
-    int nul = !strcmp(pdev->fname, "nul");
+    int nul = !strcmp(pdev->fname, "nul") || !strcmp(pdev->fname, "/dev/null");
     int lnum = 0, bottom = pdev->height;
 
     if (in == 0)

Modified: branches/gs-esp-gpl-merger/src/gdevdevn.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gdevdevn.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gdevdevn.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -1826,7 +1826,7 @@
     return length;
 }
 
-private int write_pcx_file(gx_device_printer * pdev, char * filename, int ncomp,
+private int devn_write_pcx_file(gx_device_printer * pdev, char * filename, int ncomp,
 			    int bpc, int pcmlinelength);
 /* 
  * This is an example print page routine for a DeviceN device.  This routine
@@ -1933,14 +1933,14 @@
 
     /* Now convert the bit image files into PCX files */
     if (npcmcolors) {
-	code = write_pcx_file(pdev, (char *) &pdevn->fname,
+	code = devn_write_pcx_file(pdev, (char *) &pdevn->fname,
 				npcmcolors, bpc, pcmlinelength);
 	if (code < 0)
 	    return code;
     }
     for(i = 0; i < nspot; i++) {
 	sprintf(spotname, "%ss%d", pdevn->fname, i);
-	code = write_pcx_file(pdev, spotname, 1, bpc, linelength[i]);
+	code = devn_write_pcx_file(pdev, spotname, 1, bpc, linelength[i]);
 	if (code < 0)
 	    return code;
     }
@@ -2024,8 +2024,8 @@
 
 
 /* Forward declarations */
-private void pcx_write_rle(const byte *, const byte *, int, FILE *);
-private int pcx_write_page(gx_device_printer * pdev, FILE * infile,
+private void devn_pcx_write_rle(const byte *, const byte *, int, FILE *);
+private int devn_pcx_write_page(gx_device_printer * pdev, FILE * infile,
     int linesize, FILE * outfile, pcx_header * phdr, bool planar, int depth);
 
 static const byte pcx_cmyk_palette[16 * 3] =
@@ -2060,7 +2060,7 @@
  *   num_planes - The number of planes.
  */
 private bool
-setup_pcx_header(gx_device_printer * pdev, pcx_header * phdr, int num_planes, int bits_per_plane)
+devn_setup_pcx_header(gx_device_printer * pdev, pcx_header * phdr, int num_planes, int bits_per_plane)
 {
     bool planar = true; /* Invalid cases could cause an indeterminizm. */
  
@@ -2188,7 +2188,7 @@
  *   num_planes - The number of planes.
  */
 private int
-finish_pcx_file(gx_device_printer * pdev, FILE * file, pcx_header * header, int num_planes, int bits_per_plane)
+devn_finish_pcx_file(gx_device_printer * pdev, FILE * file, pcx_header * header, int num_planes, int bits_per_plane)
 {
     switch (num_planes) {
         case 1:
@@ -2262,7 +2262,7 @@
 
 /* Send the page to the printer. */
 private int
-write_pcx_file(gx_device_printer * pdev, char * filename, int ncomp,
+devn_write_pcx_file(gx_device_printer * pdev, char * filename, int ncomp,
 			    int bpc, int linesize)
 {
     pcx_header header;
@@ -2283,10 +2283,10 @@
 	return_error(gs_error_invalidfileaccess);
     }
 
-    planar = setup_pcx_header(pdev, &header, ncomp, bpc);
-    code = pcx_write_page(pdev, in, linesize, out, &header, planar, depth);
+    planar = devn_setup_pcx_header(pdev, &header, ncomp, bpc);
+    code = devn_pcx_write_page(pdev, in, linesize, out, &header, planar, depth);
     if (code >= 0)
-        code = finish_pcx_file(pdev, out, &header, ncomp, bpc);
+        code = devn_finish_pcx_file(pdev, out, &header, ncomp, bpc);
 
     fclose(in);
     fclose(out);
@@ -2297,7 +2297,7 @@
 /* This routine is used for all formats. */
 /* The caller has set header->bpp, nplanes, and palette. */
 private int
-pcx_write_page(gx_device_printer * pdev, FILE * infile, int linesize, FILE * outfile,
+devn_pcx_write_page(gx_device_printer * pdev, FILE * infile, int linesize, FILE * outfile,
 	       pcx_header * phdr, bool planar, int depth)
 {
     int raster = linesize;
@@ -2341,7 +2341,7 @@
 		*end = end[-1];
 		++end;
 	    }
-	    pcx_write_rle(row, end, 1, outfile);
+	    devn_pcx_write_rle(row, end, 1, outfile);
 	} else
 	    switch (depth) {
 
@@ -2371,7 +2371,7 @@
 			    /* We might be one byte short of rsize. */
 			    if (to < pend)
 				*to = to[-1];
-			    pcx_write_rle(plane, pend, 1, outfile);
+			    devn_pcx_write_rle(plane, pend, 1, outfile);
 			}
 		    }
 		    break;
@@ -2381,7 +2381,7 @@
 			int pnum;
 
 			for (pnum = 0; pnum < 3; ++pnum) {
-			    pcx_write_rle(row + pnum, row + raster, 3, outfile);
+			    devn_pcx_write_rle(row + pnum, row + raster, 3, outfile);
 			    if (pdev->width & 1)
 				fputc(0, outfile);		/* pad to even */
 			}
@@ -2406,7 +2406,7 @@
 
 /* Write one line in PCX run-length-encoded format. */
 private void
-pcx_write_rle(const byte * from, const byte * end, int step, FILE * file)
+devn_pcx_write_rle(const byte * from, const byte * end, int step, FILE * file)
 {  /*
     * The PCX format theoretically allows encoding runs of 63
     * identical bytes, but some readers can't handle repetition

Modified: branches/gs-esp-gpl-merger/src/gdevdflt.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gdevdflt.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gdevdflt.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -870,6 +870,10 @@
 gx_default_pattern_manage(gx_device *pdev, gx_bitmap_id id,
 		gs_pattern1_instance_t *pinst, pattern_manage_t function)
 {
+    if (function == pattern_manage__shfill_doesnt_need_path) {
+	if (pdev->procs.fill_path == gx_default_fill_path)
+	    return 1;
+    }
     return 0;
 }
 

Modified: branches/gs-esp-gpl-merger/src/gdevnfwd.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gdevnfwd.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gdevnfwd.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -751,9 +751,13 @@
 
     /* Note that clist sets fdev->target == fdev, 
        so this function is unapplicable to clist. */
-    if (tdev == 0)
+    if (tdev == 0) {
+	if (function == pattern_manage__shfill_doesnt_need_path) {
+	    if (dev->procs.fill_path == gx_default_fill_path)
+		return 1;
+	}
 	return 0;
-    else
+    } else
 	return dev_proc(tdev, pattern_manage)(tdev, id, pinst, function);
 }
 

Modified: branches/gs-esp-gpl-merger/src/gdevpdfb.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gdevpdfb.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gdevpdfb.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -123,7 +123,7 @@
 	      gx_color_index one, const gx_clip_path *pcpath)
 {
     int code;
-    gs_color_space *pcs;
+    gs_color_space *pcs = NULL;
     cos_value_t cs_value;
     cos_value_t *pcsvalue;
     byte palette[arch_sizeof_color_index * 2];

Modified: branches/gs-esp-gpl-merger/src/gdevpsd.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gdevpsd.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gdevpsd.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -320,6 +320,29 @@
     return code;
 }
 
+/* 2007/05/04
+psdgray device
+*/
+private void
+gray_cs_to_psdgray_cm(gx_device * dev, frac gray, frac out[])
+{
+    out[0] = gray;
+}
+
+private void
+rgb_cs_to_psdgray_cm(gx_device * dev, const gs_imager_state *pis,
+				   frac r, frac g, frac b, frac out[])
+{
+    out[0] = color_rgb_to_gray(r, g, b, NULL);
+}
+
+private void
+cmyk_cs_to_psdgray_cm(gx_device * dev, frac c, frac m, frac y, frac k, frac out[])
+{
+    out[0] = color_cmyk_to_gray(c, m, y, k, NULL);
+}
+
+
 /*
  * The following procedures are used to map the standard color spaces into
  * the color components for the psdrgb device.
@@ -456,6 +479,10 @@
     }
 }
 
+private const gx_cm_color_map_procs psdGray_procs = {/* 2007/05/04 Test */
+    gray_cs_to_psdgray_cm, rgb_cs_to_psdgray_cm, cmyk_cs_to_psdgray_cm
+};
+
 private const gx_cm_color_map_procs psdRGB_procs = {
     gray_cs_to_psdrgb_cm, rgb_cs_to_psdrgb_cm, cmyk_cs_to_psdrgb_cm
 };
@@ -489,6 +516,8 @@
 	return &psdCMYK_procs;
     else if (xdev->color_model == psd_DEVICE_N)
 	return &psdN_procs;
+    else if (xdev->color_model == psd_DEVICE_GRAY)
+    	return &psdGray_procs;
     else
 	return NULL;
 }

Modified: branches/gs-esp-gpl-merger/src/gdevwts.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gdevwts.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gdevwts.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -118,8 +118,10 @@
 			3, 24, 255, 255, 256, 256, wtsimdi_print_page)
 };
 
+#if DUMMY_WTS_HALFTONE_LINE
 private void
 wts_halftone_line(void **wts, int y, int width, int n_planes,
+		  long band_offset_x, long band_offset_y,
 		  byte **dst, const byte *src)
 {
     int x;
@@ -141,9 +143,11 @@
 	}
     }
 }
+#endif
 
 private void
 wts_halftone_line_16(wts_cooked_halftone *wch, int y, int width, int n_planes,
+		     long band_offset_x, long band_offset_y,
 		     byte **dst, const byte *src)
 {
     int x;
@@ -160,7 +164,7 @@
 	    int n_samples;
 	    int cx, cy;
 
-	    wts_get_samples(w, x, y, &cx, &cy, &n_samples);
+	    wts_get_samples(w, band_offset_x + x, band_offset_y + y, &cx, &cy, &n_samples);
 	    samples = w->samples + cy * w->cell_width + cx;
 
 	    imax = min(width - x, n_samples);
@@ -206,6 +210,7 @@
 
 private void
 wts_halftone_line_8(wts_cooked_halftone *wch, int y, int width, int n_planes,
+		    long band_offset_x, long band_offset_y,
 		    byte * dst, const byte * src)
 {
     int x;
@@ -225,7 +230,7 @@
 	    int n_samples;
 	    int cx, cy;
 
-	    wts_get_samples(w, x, y, &cx, &cy, &n_samples);
+	    wts_get_samples(w, band_offset_x + x, band_offset_y + y, &cx, &cy, &n_samples);
 	    samples = wch[plane_ix].cell + cy * width_padded + cx;
 
 	    imax = min(width - x, n_samples);
@@ -326,7 +331,7 @@
     int cmyk_bytes = gdev_mem_bytes_per_scan_line((gx_device *) pdev);
     /* Output bytes have to be padded to 16 bits. */
     int y;
-    char *cmyk_line = 0;
+    byte *cmyk_line = 0;
     byte *data;
     int code = 0;
     int pbm_bytes;
@@ -338,7 +343,7 @@
     /* Initialize the wts halftones. */
     wts_init_halftones(wdev, n_planes);
 
-    cmyk_line = gs_malloc(pdev->memory, cmyk_bytes, 1, "wtscmyk_print_page(in)");
+    cmyk_line = (byte *)gs_malloc(pdev->memory, cmyk_bytes, 1, "wtscmyk_print_page(in)");
     if (cmyk_line == 0) {
 	code = GS_NOTE_ERROR(pdev->memory, gs_error_VMerror);
 	goto out;
@@ -376,7 +381,8 @@
     /* For each raster line */
     for (y = 0; y < pdev->height; y++) {
 	gdev_prn_get_bits(pdev, y, cmyk_line, &data);
-	wts_halftone_line_8(wdev->wcooked, y, pdev->width, n_planes, dst, data);
+	wts_halftone_line_8(wdev->wcooked, y, pdev->width, n_planes, 
+			    wdev->band_offset_x, wdev->band_offset_y, dst, data);
 	for (i = 0; i < n_planes; i++)
 	    if (ostream[i])
 		fwrite(dst + i * pbm_bytes, 1, pbm_bytes, ostream[i]);
@@ -541,7 +547,7 @@
     gx_device_memory * const mdev = (gx_device_memory *)dev;
     gx_device_wtsimdi * idev = (gx_device_wtsimdi *)
 	    ((mdev->target) ? (gx_device_wts *)(mdev->target)
-			    : dev);
+			    : (gx_device_wts *)dev);
     wts_cooked_halftone * wch = idev->wcooked;
     int n_planes = 4;
     int code, comp_value;
@@ -609,7 +615,8 @@
 		    int cx, cy;
 		    int j;
 
-		    wts_get_samples(wch[plane_ix].wts, (x & -8) + (i << 3), y, &cx, &cy, &n_samples);
+		    wts_get_samples(wch[plane_ix].wts, ((dev->band_offset_x + x) & -8) + (i << 3),
+				    (dev->band_offset_y + y), &cx, &cy, &n_samples);
 		    samples = wch[plane_ix].cell + cy * width_padded + cx;
 
 		    imax = min((nfill + 1 - i) << 3, n_samples);
@@ -645,7 +652,7 @@
     gx_device_memory * const mdev = (gx_device_memory *)dev;
     gx_device_wtsimdi * idev = (gx_device_wtsimdi *)
 	    ((mdev->target) ? (gx_device_wts *)(mdev->target)
-			    : dev);
+			    : (gx_device_wts *)dev);
     wts_cooked_halftone * wch = idev->wcooked;
     int n_planes = 4;
     int code, comp_value;
@@ -732,7 +739,8 @@
 		    int cx, cy;
 		    int j;
 
-		    wts_get_samples(wch[plane_ix].wts, (x & -8) + (i << 3), y, &cx, &cy, &n_samples);
+		    wts_get_samples(wch[plane_ix].wts, ((dev->band_offset_x + x) & -8) + (i << 3),
+				    (dev->band_offset_y + y), &cx, &cy, &n_samples);
 		    samples = wch[plane_ix].cell + cy * width_padded + cx;
 
 		    imax = min((nfill + 1 - i) << 3, n_samples);
@@ -835,7 +843,7 @@
 	gx_device_memory * const mdev = (gx_device_memory *)dev;
         gx_device_wtsimdi * idev = (gx_device_wtsimdi *)
 	    ((mdev->target) ? (gx_device_wts *)(mdev->target)
-			    : dev);
+			    : (gx_device_wts *)dev);
 	int width = dev->width;
 	int n_planes = 4;
 	int r_last = -1, g_last = -1, b_last = -1, r, g, b;
@@ -874,8 +882,8 @@
 	    *cmyk_data++ = y;
 	    *cmyk_data++ = k;
 	}
-	wts_halftone_line_8(idev->wcooked, original_y, width,
-					    n_planes, buffer, cmyk_buffer);
+	wts_halftone_line_8(idev->wcooked, original_y, width, n_planes,
+			    idev->band_offset_x, idev->band_offset_y,  buffer, cmyk_buffer);
 	params->data[0] = buffer;
 	gs_free(dev->memory, cmyk_buffer, halftoned_bytes * n_planes, 1,
 		       	"wtsimdi_print_page(halftoned_data)");

Modified: branches/gs-esp-gpl-merger/src/gscolor3.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gscolor3.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gscolor3.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -58,7 +58,6 @@
      * shading with Background removed.
      */
     gs_pattern2_template_t pat;
-    gx_path cpath;
     gs_matrix imat;
     gs_client_color cc;
     gs_color_space *pcs;
@@ -98,12 +97,22 @@
     code = pcs->type->remap_color(&cc, pcs, &devc, (gs_imager_state *)pgs,
 				  pgs->device, gs_color_select_texture);
     if (code >= 0) {
-	gx_path_init_local(&cpath, pgs->memory);
-	code = gx_cpath_to_path(pgs->clip_path, &cpath);
-	if (code >= 0)
-	    code = gx_fill_path(&cpath, &devc, pgs, gx_rule_winding_number,
+	gx_device *dev = pgs->device;
+	bool need_path = !dev_proc(dev, pattern_manage)(dev, gs_no_id, NULL,
+		pattern_manage__shfill_doesnt_need_path);
+
+	if (need_path) {
+    	    gx_path cpath;
+
+	    gx_path_init_local(&cpath, pgs->memory);
+	    code = gx_cpath_to_path(pgs->clip_path, &cpath);
+	    if (code >= 0)
+		code = gx_fill_path(&cpath, &devc, pgs, gx_rule_winding_number,
+				    pgs->fill_adjust.x, pgs->fill_adjust.y);
+	    gx_path_free(&cpath, "gs_shfill");
+	} else 
+	    code = gx_fill_path(NULL, &devc, pgs, gx_rule_winding_number,
 				pgs->fill_adjust.x, pgs->fill_adjust.y);
-	gx_path_free(&cpath, "gs_shfill");
     }
     rc_decrement(pcs, "gs_shfill");
     gs_pattern_reference(&cc, -1);

Modified: branches/gs-esp-gpl-merger/src/gsptype2.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gsptype2.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gsptype2.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -218,6 +218,10 @@
 }
 
 /* Fill a rectangle with a PatternType 2 color. */
+/* WARNING: This function doesn't account the shading BBox
+   to allow the clipent to optimize the clipping 
+   with changing the order of clip patrhs and rects.
+   The client must clip with the shading BBOx before calling this function. */
 private int
 gx_dc_pattern2_fill_rectangle(const gx_device_color * pdevc, int x, int y,
                               int w, int h, gx_device * dev,
@@ -230,12 +234,15 @@
 	return dev_proc(dev, fill_rectangle)(dev, x, y, w, h, (gx_color_index)0/*any*/);
     } else {
 	gs_fixed_rect rect;
+	gs_pattern2_instance_t *pinst =
+	    (gs_pattern2_instance_t *)pdevc->ccolor.pattern;
 
 	rect.p.x = int2fixed(x);
 	rect.p.y = int2fixed(y);
 	rect.q.x = int2fixed(x + w);
 	rect.q.y = int2fixed(y + h);
-	return gx_dc_pattern2_fill_path(pdevc, NULL, &rect,  dev);
+	return gs_shading_do_fill_rectangle(pinst->template.Shading, &rect, dev,
+				    (gs_imager_state *)pinst->saved, !pinst->shfill);
     }
 }
 
@@ -303,6 +310,59 @@
     return 1;
 }
 
+int
+gx_dc_pattern2_color_has_bbox(const gx_device_color * pdevc)
+{
+    gs_pattern2_instance_t *pinst = (gs_pattern2_instance_t *)pdevc->ccolor.pattern;
+    const gs_shading_t *psh = pinst->template.Shading;
+
+    return psh->params.have_BBox;
+}
+
+/* Create a path from a PatternType 2 shading BBox to a path. */
+int
+gx_dc_shading_path_add_box(gx_path *ppath, const gx_device_color * pdevc)
+{
+    gs_pattern2_instance_t *pinst = (gs_pattern2_instance_t *)pdevc->ccolor.pattern;
+    const gs_shading_t *psh = pinst->template.Shading;
+
+    if (!psh->params.have_BBox)
+	return_error(gs_error_unregistered); /* Do not call in this case. */
+    else {
+	gs_state *pis = pinst->saved;
+
+	return shading_path_add_box(ppath, &psh->params.BBox, &pis->ctm);
+    }
+}
+
+/* Intersect a clipping path a shading BBox. */
+int
+gx_dc_pattern2_clip_with_bbox(const gx_device_color * pdevc, gx_device * pdev, 
+			      gx_clip_path *cpath_local, const gx_clip_path **ppcpath1)
+{
+    if (gx_dc_is_pattern2_color(pdevc) && gx_dc_pattern2_color_has_bbox(pdevc) &&
+	    (*dev_proc(pdev, pattern_manage))(pdev, gs_no_id, NULL, pattern_manage__shading_area) == 0) {
+	gs_pattern2_instance_t *pinst = (gs_pattern2_instance_t *)pdevc->ccolor.pattern;
+	gx_path box_path;
+	int code;
+
+	gx_path_init_local(&box_path, pdev->memory);
+	code = gx_dc_shading_path_add_box(&box_path, pdevc);
+	if (code == gs_error_limitcheck) {
+	    /* Ignore huge BBox - bug 689027. */
+	    code = 0;
+	} else {
+	    if (code >= 0) {
+		gx_cpath_init_local_shared(cpath_local, *ppcpath1, pdev->memory);
+		code = gx_cpath_intersect(cpath_local, &box_path, gx_rule_winding_number, (gs_imager_state *)pinst->saved);
+		*ppcpath1 = cpath_local;
+	    }
+	}
+	gx_path_free(&box_path, "gx_default_fill_path(path_bbox)");
+    }
+    return 0;
+}
+
 /* Get a shading color space. */
 const gs_color_space *
 gx_dc_pattern2_get_color_space(const gx_device_color * pdevc)

Modified: branches/gs-esp-gpl-merger/src/gsptype2.h
===================================================================
--- branches/gs-esp-gpl-merger/src/gsptype2.h	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gsptype2.h	2007-06-05 15:53:48 UTC (rev 8019)
@@ -75,6 +75,11 @@
 typedef struct gs_color_space_s gs_color_space;
 #endif
 
+#ifndef gx_clip_path_DEFINED
+#  define gx_clip_path_DEFINED
+typedef struct gx_clip_path_s gx_clip_path;
+#endif
+
 extern const gx_device_color_type_t gx_dc_pattern2;
 
 #define gx_dc_type_pattern2 (&gx_dc_pattern2)
@@ -107,6 +112,18 @@
 /* Get a shading bbox. Returns 1 on success. */
 int gx_dc_pattern2_get_bbox(const gx_device_color * pdevc, gs_fixed_rect *bbox);
 
+/* Checks whether a PatternType 2 has a shading BBox. */
+int gx_dc_pattern2_color_has_bbox(const gx_device_color * pdevc);
+
+/* Intersect a clipping path a shading BBox. */
+int gx_dc_pattern2_clip_with_bbox(const gx_device_color * pdevc, gx_device * pdev, 
+				  gx_clip_path *cpath_local, const gx_clip_path **cpath1);
+
+
+/* Create a path from a PatternType 2 shading BBox to a path. */
+int gx_dc_shading_path_add_box(gx_path *ppath, const gx_device_color * pdevc);
+
+
 /* Get a shading color space. */
 const gs_color_space *gx_dc_pattern2_get_color_space(const gx_device_color * pdevc);
 

Modified: branches/gs-esp-gpl-merger/src/gsshade.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gsshade.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gsshade.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -417,7 +417,7 @@
 /* ================ Shading rendering ================ */
 
 /* Add a user-space rectangle to a path. */
-private int
+int
 shading_path_add_box(gx_path *ppath, const gs_rect *pbox,
 		     const gs_matrix_fixed *pmat)
 {
@@ -441,12 +441,51 @@
 }
 
 /* Fill a path with a shading. */
+int
+gs_shading_do_fill_rectangle(const gs_shading_t *psh,
+		     const gs_fixed_rect *prect, gx_device *dev,
+		     gs_imager_state *pis, bool fill_background)
+{   /* If you need to fill a path, clip the output device before calling this function. */
+    const gs_matrix_fixed *pmat = &pis->ctm;
+    gs_fixed_rect path_box;
+    gs_rect path_rect;
+    gs_rect rect;
+    int code = 0;
+
+    dev_proc(dev, get_clipping_box)(dev, &path_box);
+    if (prect)
+	rect_intersect(path_box, *prect);
+    if (psh->params.Background && fill_background) {
+	const gs_color_space *pcs = psh->params.ColorSpace;
+	gs_client_color cc;
+	gx_device_color dev_color;
+
+	cc = *psh->params.Background;
+	(*pcs->type->restrict_color)(&cc, pcs);
+	(*pcs->type->remap_color)(&cc, pcs, &dev_color, pis,
+				  dev, gs_color_select_texture);
+
+	/****** WRONG IF NON-IDEMPOTENT RasterOp ******/
+	code = gx_shade_background(dev, &path_box, &dev_color, pis->log_op);
+    }
+    if (code >= 0) {
+	path_rect.p.x = fixed2float(path_box.p.x);
+	path_rect.p.y = fixed2float(path_box.p.y);
+	path_rect.q.x = fixed2float(path_box.q.x);
+	path_rect.q.y = fixed2float(path_box.q.y);
+	gs_bbox_transform_inverse(&path_rect, (const gs_matrix *)pmat, &rect);
+	code = gs_shading_fill_rectangle(psh, &rect, &path_box, dev, pis);
+    }
+    return code;
+}
+
+/* Fill a path with a shading. */
+/* Depricated. To be removed soon. */
 private int
 gs_shading_fill_path(const gs_shading_t *psh, /*const*/ gx_path *ppath,
 		     const gs_fixed_rect *prect, gx_device *orig_dev,
 		     gs_imager_state *pis, bool fill_background)
-{
-    gs_memory_t *mem = pis->memory;
+{   gs_memory_t *mem = pis->memory;
     const gs_matrix_fixed *pmat = &pis->ctm;
     gx_device *dev = orig_dev;
     gs_fixed_rect path_box;

Modified: branches/gs-esp-gpl-merger/src/gsshade.h
===================================================================
--- branches/gs-esp-gpl-merger/src/gsshade.h	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gsshade.h	2007-06-05 15:53:48 UTC (rev 8019)
@@ -253,8 +253,14 @@
 #  define gx_path_DEFINED
 typedef struct gx_path_s gx_path;
 #endif
+/* Fill a path with a shading. */
+/* Depricated. To be removed soon. */
 int gs_shading_fill_path_adjusted(const gs_shading_t *psh, /*const*/ gx_path *ppath,
 			 const gs_fixed_rect *prect, gx_device *dev,
 			 gs_imager_state *pis, bool fill_background);
 
+/* Fill a path with a shading. */
+int gs_shading_do_fill_rectangle(const gs_shading_t *psh, 
+			 const gs_fixed_rect *prect, gx_device *dev,
+			 gs_imager_state *pis, bool fill_background);
 #endif /* gsshade_INCLUDED */

Modified: branches/gs-esp-gpl-merger/src/gxclmem.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gxclmem.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gxclmem.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -131,7 +131,7 @@
    least as large as the fixed overhead of the compressor plus the
    decompressor, plus the expected compressed size of a block that size.
  */
-private const long COMPRESSION_THRESHOLD = 300000;
+private const long COMPRESSION_THRESHOLD = 32000000;
 
 #define NEED_TO_COMPRESS(f)\
   ((f)->ok_to_compress && (f)->total_space > COMPRESSION_THRESHOLD)

Modified: branches/gs-esp-gpl-merger/src/gxclread.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gxclread.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gxclread.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -469,6 +469,24 @@
     for (i = 0; i < num_pages && code >= 0; ++i) {
 	const gx_placed_page *ppage = &ppages[i];
 
+	/*
+	 * Set the band_offset_? values in case the buffer device
+	 * needs this. Example, wtsimdi device needs to adjust the 
+	 * phase of the dithering based on the page position, NOT
+	 * the position within the band buffer to avoid band stitch
+	 * lines in the dither pattern.
+	 *
+	 * The band_offset_x is not important for placed pages that
+	 * are nested on a 'master' page (imposition) since each
+	 * page expects to be dithered independently, but setting
+	 * this allows pages to be contiguous without a dithering
+	 * shift.
+	 *
+	 * The following sets the band_offset_? relative to the
+	 * master page.
+	 */
+	bdev->band_offset_x = ppage->offset.x;
+	bdev->band_offset_y = ppage->offset.y + (band_first * band_height);
 	code = clist_playback_file_bands(playback_action_render,
 					 crdev, &ppage->page->info,
 					 bdev, band_first, band_last,

Modified: branches/gs-esp-gpl-merger/src/gxcpath.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gxcpath.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gxcpath.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -375,56 +375,66 @@
 
 /* ------ Clipping path accessing ------ */
 
+/* Synthesize a path from a clipping path. */
+int
+gx_cpath_to_path_synthesize(const gx_clip_path * pcpath, gx_path * ppath)
+{
+    /* Synthesize a path. */
+    gs_cpath_enum cenum;
+    gs_fixed_point pts[3];
+    int code;
+
+    gx_cpath_enum_init(&cenum, pcpath);
+    while ((code = gx_cpath_enum_next(&cenum, pts)) != 0) {
+	switch (code) {
+	    case gs_pe_moveto:
+		code = gx_path_add_point(ppath, pts[0].x, pts[0].y);
+		break;
+	    case gs_pe_lineto:
+		code = gx_path_add_line_notes(ppath, pts[0].x, pts[0].y,
+					   gx_cpath_enum_notes(&cenum));
+		break;
+	    case gs_pe_curveto:
+		code = gx_path_add_curve_notes(ppath, pts[0].x, pts[0].y,
+					       pts[1].x, pts[1].y,
+					       pts[2].x, pts[2].y,
+					   gx_cpath_enum_notes(&cenum));
+		break;
+	    case gs_pe_closepath:
+		code = gx_path_close_subpath_notes(ppath,
+					   gx_cpath_enum_notes(&cenum));
+		break;
+	    default:
+		if (code >= 0)
+		    code = gs_note_error(gs_error_unregistered);
+	}
+	if (code < 0)
+	    break;
+    }
+    return 0;
+}
+
 /* Return the path of a clipping path. */
 int
 gx_cpath_to_path(gx_clip_path * pcpath, gx_path * ppath)
 {
     if (!pcpath->path_valid) {
-	/* Synthesize a path. */
-	gs_cpath_enum cenum;
-	gs_fixed_point pts[3];
 	gx_path rpath;
 	int code;
 
 	gx_path_init_local(&rpath, pcpath->path.memory);
-	gx_cpath_enum_init(&cenum, pcpath);
-	while ((code = gx_cpath_enum_next(&cenum, pts)) != 0) {
-	    switch (code) {
-		case gs_pe_moveto:
-		    code = gx_path_add_point(&rpath, pts[0].x, pts[0].y);
-		    break;
-		case gs_pe_lineto:
-		    code = gx_path_add_line_notes(&rpath, pts[0].x, pts[0].y,
-					       gx_cpath_enum_notes(&cenum));
-		    break;
-		case gs_pe_curveto:
-		    code = gx_path_add_curve_notes(&rpath, pts[0].x, pts[0].y,
-						   pts[1].x, pts[1].y,
-						   pts[2].x, pts[2].y,
-					       gx_cpath_enum_notes(&cenum));
-		    break;
-		case gs_pe_closepath:
-		    code = gx_path_close_subpath_notes(&rpath,
-					       gx_cpath_enum_notes(&cenum));
-		    break;
-		default:
-		    if (code >= 0)
-			code = gs_note_error(gs_error_unregistered);
-	    }
-	    if (code < 0)
-		break;
-	}
-	if (code >= 0)
-	    code = gx_path_assign_free(&pcpath->path, &rpath);
+	code = gx_cpath_to_path_synthesize(pcpath, &rpath);
 	if (code < 0) {
 	    gx_path_free(&rpath, "gx_cpath_to_path error");
 	    return code;
 	}
+	code = gx_path_assign_free(&pcpath->path, &rpath);
+	if (code < 0)
+	    return code;
 	pcpath->path_valid = true;
     }
     return gx_path_assign_preserve(ppath, &pcpath->path);
 }
-
 /* Return the inner and outer check rectangles for a clipping path. */
 /* Return true iff the path is a rectangle. */
 bool
@@ -474,7 +484,7 @@
 }
 /* Internal non-const version of the same accessor. */
 inline private gx_clip_list *
-gx_cpath_list_private(gx_clip_path *pcpath)
+gx_cpath_list_private(const gx_clip_path *pcpath)
 {
     return &pcpath->rect_list->list;
 }
@@ -760,7 +770,7 @@
 
 /* Start enumerating a clipping path. */
 int
-gx_cpath_enum_init(gs_cpath_enum * penum, gx_clip_path * pcpath)
+gx_cpath_enum_init(gs_cpath_enum * penum, const gx_clip_path * pcpath)
 {
     if ((penum->using_path = pcpath->path_valid)) {
 	gx_path_enum_init(&penum->path_enum, &pcpath->path);

Modified: branches/gs-esp-gpl-merger/src/gxdevcli.h
===================================================================
--- branches/gs-esp-gpl-merger/src/gxdevcli.h	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gxdevcli.h	2007-06-05 15:53:48 UTC (rev 8019)
@@ -704,6 +704,8 @@
 	bool IgnoreNumCopies;		/* if true, force num_copies = 1 */\
 	bool UseCIEColor;		/* for PS LL3 */\
 	bool LockSafetyParams;		/* If true, prevent unsafe changes */\
+	long band_offset_x;		/* offsets of clist band base to (mem device) buffer */\
+	long band_offset_y;		/* for rendering that is phase sensitive (wtsimdi) */\
 	gx_page_device_procs page_procs;	/* must be last */\
 		/* end of std_device_body */\
 	gx_device_procs procs	/* object procedures */
@@ -1222,7 +1224,8 @@
     pattern_manage__finish_accum,
     pattern_manage__load,
     pattern_manage__shading_area,
-    pattern_manage__is_cpath_accum
+    pattern_manage__is_cpath_accum,
+    pattern_manage__shfill_doesnt_need_path
 } pattern_manage_t;
 
 #define dev_t_proc_pattern_manage(proc, dev_t)\

Modified: branches/gs-esp-gpl-merger/src/gxdevice.h
===================================================================
--- branches/gs-esp-gpl-merger/src/gxdevice.h	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gxdevice.h	2007-06-05 15:53:48 UTC (rev 8019)
@@ -102,6 +102,7 @@
 #define std_device_part3_()\
 	0/*PageCount*/, 0/*ShowpageCount*/, 1/*NumCopies*/, 0/*NumCopies_set*/,\
 	0/*IgnoreNumCopies*/, 0/*UseCIEColor*/, 0/*LockSafetyParams*/,\
+	0/*band_offset_x*/, 0/*band_offset_y*/,\
 	{ gx_default_install, gx_default_begin_page, gx_default_end_page }
 /*
  * We need a number of different variants of the std_device_ macro simply

Modified: branches/gs-esp-gpl-merger/src/gxfill.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gxfill.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gxfill.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -41,6 +41,7 @@
 #include "gxpaint.h"		/* for prototypes */
 #include "gxfdrop.h"
 #include "gxfill.h"
+#include "gxpath.h"
 #include "gsptype1.h"
 #include "gsptype2.h"
 #include "gxpcolor.h"
@@ -565,7 +566,7 @@
 		     gx_path * ppath, const gx_fill_params * params,
 		 const gx_device_color * pdevc, const gx_clip_path * pcpath)
 {
-    int code;
+    int code = 0;
 
     if (gx_dc_is_pattern2_color(pdevc) 
 	|| pdevc->type == &gx_dc_type_data_ht_colored
@@ -585,60 +586,49 @@
 	/*  We need a single clipping path here, because shadings and
 	    halftones don't take 2 paths. Compute the clipping path intersection.
 	*/
-	gx_clip_path cpath_intersection;
-	gx_path path_intersection;
+	gx_clip_path cpath_intersection, cpath_with_shading_bbox;
+	const gx_clip_path *pcpath1, *pcpath2;
+	gs_imager_state *pis_noconst = (gs_imager_state *)pis; /* Break const. */
 
-	gx_path_init_local(&path_intersection, pdev->memory);
-	gx_cpath_init_local_shared(&cpath_intersection, pcpath, pdev->memory);
-	code = gx_cpath_intersect_with_params(&cpath_intersection, ppath, params->rule, 
-		    (gs_imager_state *)pis, params);
+	if (ppath != NULL) {
+	    gx_cpath_init_local_shared(&cpath_intersection, pcpath, pdev->memory);
+	    code = gx_cpath_intersect_with_params(&cpath_intersection, ppath, params->rule, 
+			pis_noconst, params);
+	    pcpath1 = &cpath_intersection;
+	} else
+	    pcpath1 = pcpath;
+
+
+	pcpath2 = pcpath1;
+	if (code >= 0)
+	    code = gx_dc_pattern2_clip_with_bbox(pdevc, pdev, &cpath_with_shading_bbox, &pcpath1);
 	/* Do fill : */
 	if (code >= 0) {
-	    if (pdevc->type == &gx_dc_type_data_ht_colored || gx_dc_is_pattern1_color(pdevc)) {
-		const gx_rop_source_t *rs = NULL;
-		gx_device *dev;
-		gx_device_clip cdev;
-		gs_fixed_rect clip_box;
-		gs_int_rect cb;
+	    const gx_rop_source_t *rs = NULL;
+	    gx_device *dev;
+	    gx_device_clip cdev;
+	    gs_fixed_rect clip_box;
+	    gs_int_rect cb;
 
-		gx_cpath_outer_box(&cpath_intersection, &clip_box);
-		gx_make_clip_path_device(&cdev, &cpath_intersection);
-		cdev.target = pdev;
-		dev = (gx_device *)&cdev;
-		(*dev_proc(dev, open_device))(dev);
-		cb.p.x = fixed2int_pixround(clip_box.p.x);
-		cb.p.y = fixed2int_pixround(clip_box.p.y);
-		cb.q.x = fixed2int_pixround(clip_box.q.x);
-		cb.q.y = fixed2int_pixround(clip_box.q.y);
-		code = pdevc->type->fill_rectangle(pdevc,
-			    cb.p.x, cb.p.y, cb.q.x - cb.p.x, cb.q.y - cb.p.y,
-			    dev, pis->log_op, rs);
-	    } else {
-		/* The shading fill algorithm fills an area restricted with a path,
-		   so we need to convert cpath into path.
-
-		   We can't set a clipping device here like we did for 
-		   gx_dc_type_data_ht_colored, because the shading itself
-		   may add another clipping with its BBox,
-		   which may be transformed into a parallelogram.
-		   We don't want two clipping devices chained consequently.
-		 */
-		if (params->rule != gx_rule_winding_number) {
-		    /* HACK : Rather cpath_intersection contains a valid path,
-		       it is not planarized to a simple winding path,
-		       so we can't use the contained path.
-		       Reset path_valid against using it.
-		    */
-		    cpath_intersection.path_valid = false;
-		}
-		code = gx_cpath_to_path(&cpath_intersection, &path_intersection);
-		if (code >= 0)
-		    code = gx_dc_pattern2_fill_path(pdevc, &path_intersection, NULL,  pdev);
-	    }
+	    gx_cpath_outer_box(pcpath1, &clip_box);
+	    gx_make_clip_path_device(&cdev, pcpath1);
+	    cdev.HWResolution[0] = pdev->HWResolution[0];
+	    cdev.HWResolution[1] = pdev->HWResolution[1];
+	    cdev.target = pdev;
+	    dev = (gx_device *)&cdev;
+	    (*dev_proc(dev, open_device))(dev);
+	    cb.p.x = fixed2int_pixround(clip_box.p.x);
+	    cb.p.y = fixed2int_pixround(clip_box.p.y);
+	    cb.q.x = fixed2int_pixround(clip_box.q.x);
+	    cb.q.y = fixed2int_pixround(clip_box.q.y);
+	    code = pdevc->type->fill_rectangle(pdevc,
+			cb.p.x, cb.p.y, cb.q.x - cb.p.x, cb.q.y - cb.p.y,
+			dev, pis->log_op, rs);
 	}
-	/* Destruct local data and return :*/
-	gx_path_free(&path_intersection, "shading_fill_path_intersection");
-	gx_cpath_free(&cpath_intersection, "shading_fill_cpath_intersection");
+	if (ppath != NULL)
+	    gx_cpath_free(&cpath_intersection, "shading_fill_cpath_intersection");
+	if (pcpath1 != pcpath2)
+	    gx_cpath_free(&cpath_with_shading_bbox, "shading_fill_cpath_intersection");
     } else {
 	bool got_dc = false;
         vd_save;

Modified: branches/gs-esp-gpl-merger/src/gximask.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gximask.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gximask.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -60,23 +60,30 @@
 gx_image_fill_masked_end(gx_device *dev, gx_device *tdev, const gx_device_color *pdevc)
 {
     gx_device_cpath_accum *pcdev = (gx_device_cpath_accum *)dev;
-    gx_clip_path cpath;
+    gx_clip_path cpath, cpath_with_shading_bbox;
+    const gx_clip_path *pcpath1 = &cpath;
     gx_device_clip cdev;
     int code, code1;
 
     gx_cpath_init_local(&cpath, pcdev->memory);
     code = gx_cpath_accum_end(pcdev, &cpath);
-    gx_make_clip_path_device(&cdev, &cpath);
-    cdev.target = tdev;
-    (*dev_proc(&cdev, open_device)) ((gx_device *) & cdev);
-    code1 = gx_device_color_fill_rectangle(pdevc, 
-		pcdev->bbox.p.x, pcdev->bbox.p.y, 
-		pcdev->bbox.q.x - pcdev->bbox.p.x, 
-		pcdev->bbox.q.y - pcdev->bbox.p.y, 
-		(gx_device *)&cdev, lop_default, 0);
-    if (code == 0)
-	code = code1;
-    gx_device_retain((gx_device *)pcdev, false);
+    if (code >= 0)
+	code = gx_dc_pattern2_clip_with_bbox(pdevc, tdev, &cpath_with_shading_bbox, &pcpath1);
+    if (code >= 0) {
+	gx_make_clip_path_device(&cdev, pcpath1);
+	cdev.target = tdev;
+	(*dev_proc(&cdev, open_device)) ((gx_device *) & cdev);
+	code1 = gx_device_color_fill_rectangle(pdevc, 
+		    pcdev->bbox.p.x, pcdev->bbox.p.y, 
+		    pcdev->bbox.q.x - pcdev->bbox.p.x, 
+		    pcdev->bbox.q.y - pcdev->bbox.p.y, 
+		    (gx_device *)&cdev, lop_default, 0);
+	if (code == 0)
+	    code = code1;
+	gx_device_retain((gx_device *)pcdev, false);
+    }
+    if (pcpath1 == &cpath_with_shading_bbox)
+	gx_cpath_free(&cpath_with_shading_bbox, "s_image_cleanup");
     gx_cpath_free(&cpath, "s_image_cleanup");
     return code;
 }

Modified: branches/gs-esp-gpl-merger/src/gxpath.h
===================================================================
--- branches/gs-esp-gpl-merger/src/gxpath.h	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gxpath.h	2007-06-05 15:53:48 UTC (rev 8019)
@@ -334,7 +334,8 @@
     gx_cpath_scale_exp2_shared(gx_clip_path *pcpath, int log2_scale_x,
 			       int log2_scale_y, bool list_shared,
 			       bool segments_shared),
-    gx_cpath_to_path(gx_clip_path *, gx_path *);
+    gx_cpath_to_path(gx_clip_path *, gx_path *),
+    gx_cpath_to_path_synthesize(const gx_clip_path * pcpath, gx_path * ppath);
 bool
     gx_cpath_inner_box(const gx_clip_path *, gs_fixed_rect *),
     gx_cpath_outer_box(const gx_clip_path *, gs_fixed_rect *),
@@ -345,7 +346,7 @@
 
 /* Enumerate a clipping path.  This interface does not copy the path. */
 /* However, it does write into the path's "visited" flags. */
-int gx_cpath_enum_init(gs_cpath_enum *, gx_clip_path *);
+int gx_cpath_enum_init(gs_cpath_enum *, const gx_clip_path *);
 int gx_cpath_enum_next(gs_cpath_enum *, gs_fixed_point[3]);		/* 0 when done */
 
 segment_notes

Modified: branches/gs-esp-gpl-merger/src/gxshade1.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gxshade1.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gxshade1.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -639,6 +639,27 @@
     return 0;
 }
 
+private int
+R_fill_rect_with_const_color(const patch_fill_state_t *pfs, const gs_fixed_rect *clip_rect, float t)
+{
+    patch_color_t pc;
+    const gs_color_space *pcs = pfs->direct_space;
+    gx_device_color dc;
+    int code;
+
+    code = gs_function_evaluate(pfs->Function, &t, pc.cc.paint.values);
+    if (code < 0)
+	return code;
+    pcs->type->restrict_color(&pc.cc, pcs);
+    code = patch_color_to_device_color(pfs, &pc, &dc);
+    if (code < 0)
+	return code;
+    return gx_fill_rectangle_device_rop(fixed2int_pixround(clip_rect->p.x), fixed2int_pixround(clip_rect->p.y), 
+					fixed2int_pixround(clip_rect->q.x) - fixed2int_pixround(clip_rect->p.x),
+					fixed2int_pixround(clip_rect->q.y) - fixed2int_pixround(clip_rect->p.y), 
+					&dc, pfs->dev, pfs->pis->log_op);
+}
+
 typedef struct radial_shading_attrs_s {
     double x0, y0;
     double x1, y1;
@@ -716,7 +737,6 @@
        t0 := (c - r0) / (cc + (r1 - r0))
        t1 := (c + r0) / (cc - (r1 - r0))
      */
-
     if (by_x) {
 	c = rsa->p[point_index].x - rsa->x0;
 	cc = rsa->x1 - rsa->x0;
@@ -1032,6 +1052,10 @@
 	    code = R_tensor_annulus(&pfs1, rect, x0, y0, r0, d0, x1, y1, r1, d1);
 	if (code >= 0)
 	    code = R_extensions(&pfs1, psh, rect, d0, d1, false, psh->params.Extend[1]);
+    } else if (span_type == 1) {
+	code = R_fill_rect_with_const_color(&pfs1, clip_rect, d0);
+    } else if (span_type == 8) {
+	code = R_fill_rect_with_const_color(&pfs1, clip_rect, d1);
     } else {
 	bool second_interval = true; 
 

Modified: branches/gs-esp-gpl-merger/src/gxshade4.h
===================================================================
--- branches/gs-esp-gpl-merger/src/gxshade4.h	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gxshade4.h	2007-06-05 15:53:48 UTC (rev 8019)
@@ -188,6 +188,9 @@
 int gx_shade_background(gx_device *pdev, const gs_fixed_rect *rect, 
 	const gx_device_color *pdevc, gs_logical_operation_t log_op);
 
+int patch_color_to_device_color(const patch_fill_state_t *pfs, 
+	const patch_color_t *c, gx_device_color *pdevc);
+
 byte *reserve_colors(patch_fill_state_t *pfs, patch_color_t *c0[], int n);
 void release_colors(patch_fill_state_t *pfs, byte *ptr, int n);
 

Modified: branches/gs-esp-gpl-merger/src/gxshade6.c
===================================================================
--- branches/gs-esp-gpl-merger/src/gxshade6.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/gxshade6.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -911,7 +911,7 @@
 #define DEBUG_COLOR_INDEX_CACHE 0
 
 private inline int
-patch_color_to_device_color(const patch_fill_state_t *pfs, const patch_color_t *c, gx_device_color *pdevc, frac31 *frac_values)
+patch_color_to_device_color_inline(const patch_fill_state_t *pfs, const patch_color_t *c, gx_device_color *pdevc, frac31 *frac_values)
 {
     /* Must return 2 if the color is not pure. 
        See try_device_linear_color.
@@ -954,6 +954,12 @@
     return 0;
 }
 
+int
+patch_color_to_device_color(const patch_fill_state_t *pfs, const patch_color_t *c, gx_device_color *pdevc)
+{
+    return patch_color_to_device_color_inline(pfs, c, pdevc, NULL);
+}
+
 private inline double
 color_span(const patch_fill_state_t *pfs, const patch_color_t *c0, const patch_color_t *c1)
 {
@@ -1032,7 +1038,7 @@
 	/* if (dbg_nofill)
 		return 0; */
 #   endif
-    code = patch_color_to_device_color(pfs, &c1, &dc, NULL);
+    code = patch_color_to_device_color_inline(pfs, &c1, &dc, NULL);
     if (code < 0)
 	return code;
     if (!VD_TRACE_DOWN)
@@ -1178,7 +1184,7 @@
 	    fa.lop = 0;
 	    fa.ystart = ybot;
 	    fa.yend = ytop;
-	    code = patch_color_to_device_color(pfs, c0, NULL, fc[0]);
+	    code = patch_color_to_device_color_inline(pfs, c0, NULL, fc[0]);
 	    if (code < 0)
 		goto out;
 	    if (code == 2) {
@@ -1186,7 +1192,7 @@
 		code=gs_note_error(gs_error_unregistered);
 		goto out;
 	    }
-	    code = patch_color_to_device_color(pfs, c1, NULL, fc[1]);
+	    code = patch_color_to_device_color_inline(pfs, c1, NULL, fc[1]);
 	    if (code < 0)
 		goto out;
 	    code = dev_proc(pdev, fill_linear_color_trapezoid)(pdev, &fa, 
@@ -1686,17 +1692,17 @@
 	fa.ht = NULL;
 	fa.swap_axes = false;
 	fa.lop = 0;
-	code = patch_color_to_device_color(pfs, p0->c, &dc[0], fc[0]);
+	code = patch_color_to_device_color_inline(pfs, p0->c, &dc[0], fc[0]);
 	if (code != 0)
 	    return code;
 	if (dc[0].type != &gx_dc_type_data_pure)
 	    return 2;
 	if (!wedge) {
-	    code = patch_color_to_device_color(pfs, p1->c, &dc[1], fc[1]);
+	    code = patch_color_to_device_color_inline(pfs, p1->c, &dc[1], fc[1]);
 	    if (code != 0)
 		return code;
 	}
-	code = patch_color_to_device_color(pfs, p2->c, &dc[2], fc[2]);
+	code = patch_color_to_device_color_inline(pfs, p2->c, &dc[2], fc[2]);
 	if (code != 0)
 	    return code;
 	draw_triangle(&p0->p, &p1->p, &p2->p, RGB(255, 0, 0));
@@ -2067,7 +2073,7 @@
 #   endif
     if (!VD_TRACE_DOWN)
         vd_disable;
-    code = patch_color_to_device_color(pfs, c, &dc, NULL);
+    code = patch_color_to_device_color_inline(pfs, c, &dc, NULL);
     if (code < 0)
 	return code;
     if (le->end.y < re->end.y) {
@@ -2153,7 +2159,7 @@
     patch_interpolate_color(c[1], p->p[0][0]->c, p->p[0][1]->c, pfs, 0.5);
     patch_interpolate_color(c[2], p->p[1][0]->c, p->p[1][1]->c, pfs, 0.5);
     patch_interpolate_color(c[0], c[1], c[2], pfs, 0.5);
-    code = patch_color_to_device_color(pfs, c[0], &dc, NULL);
+    code = patch_color_to_device_color_inline(pfs, c[0], &dc, NULL);
     if (code < 0)
 	return code;
     {	gs_fixed_point qq[4];
@@ -3771,8 +3777,10 @@
     kv[3] = curve_samples(pfs, &p.pole[0][3], 4, pfs->fixed_flat);
     kvm = max(max(kv[0], kv[1]), max(kv[2], kv[3]));
     ku[0] = curve_samples(pfs, p.pole[0], 1, pfs->fixed_flat);
+    ku[1] = curve_samples(pfs, p.pole[1], 1, pfs->fixed_flat);
+    ku[2] = curve_samples(pfs, p.pole[2], 1, pfs->fixed_flat);
     ku[3] = curve_samples(pfs, p.pole[3], 1, pfs->fixed_flat);
-    kum = max(ku[0], ku[3]);
+    kum = max(max(ku[0], ku[1]), max(ku[2], ku[3]));
     km = max(kvm, kum);
 #   if NOFILL_TEST
 	dbg_nofill = false;

Modified: branches/gs-esp-gpl-merger/src/lib.mak
===================================================================
--- branches/gs-esp-gpl-merger/src/lib.mak	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/lib.mak	2007-06-05 15:53:48 UTC (rev 8019)
@@ -607,9 +607,10 @@
 	$(GLCC) $(GLO_)gxhldevc.$(OBJ) $(C_) $(GLSRC)gxhldevc.c
 
 $(GLOBJ)gxfill.$(OBJ) : $(GLSRC)gxfill.c $(GXERR)\
- $(gsstruct_h)\
+ $(gsstruct_h) $(gsfixed_h)\
  $(gxdcolor_h) $(gxdevice_h) $(gxfixed_h) $(gxhttile_h)\
- $(gxistate_h) $(gxpaint_h) $(gxfill_h) $(gxfdrop_h) $(gsptype1_h) $(gsptype2_h) $(gxpcolor_h)\
+ $(gxistate_h) $(gxpaint_h) $(gxfdrop_h) $(gxfill_h) $(gxpath_h)\
+ $(gsptype1_h) $(gsptype2_h) $(gxpcolor_h)\
  $(gzcpath_h) $(gzpath_h) $(gzspotan_h) $(gdevddrw_h) $(memory__h) $(stdint_) $(vdtrace_h)\
  $(gxfilltr_h) $(gxfillsl_h) $(gxfillts_h)
 	$(GLCC) $(GLO_)gxfill.$(OBJ) $(C_) $(GLSRC)gxfill.c

Modified: branches/gs-esp-gpl-merger/src/openvms.mak
===================================================================
--- branches/gs-esp-gpl-merger/src/openvms.mak	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/openvms.mak	2007-06-05 15:53:48 UTC (rev 8019)
@@ -158,6 +158,11 @@
 #IJSSRCDIR=[.ijs]
 #IJSEXECTYPE=unix
 
+# Define the directory where the imdi source are stored.
+# See imdi.mak for more information
+
+IMDISRCDIR=[.imdi]
+
 # Note that built-in third-party libraries aren't available.
 
 SHARE_JPEG=0

Modified: branches/gs-esp-gpl-merger/src/watcw32.mak
===================================================================
--- branches/gs-esp-gpl-merger/src/watcw32.mak	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/src/watcw32.mak	2007-06-05 15:53:48 UTC (rev 8019)
@@ -140,7 +140,9 @@
 # Define the directory where the icclib source are stored.
 # See icclib.mak for more information
 
+!ifndef ICCSRCDIR
 ICCSRCDIR=icclib
+!endif
 
 # Define the directory where the ijs source is stored,
 # and the process forking method to use for the server.
@@ -149,6 +151,13 @@
 IJSSRCDIR=ijs
 IJSEXECTYPE=win
 
+# Define the directory where the imdi source are stored.
+# See imdi.mak for more information
+
+!ifndef IMDISRCDIR
+IMDISRCDIR=imdi
+!endif
+
 # Define any other compilation flags.
 
 CFLAGS=

Modified: branches/gs-esp-gpl-merger/toolbin/tests/fuzzy.c
===================================================================
--- branches/gs-esp-gpl-merger/toolbin/tests/fuzzy.c	2007-06-03 22:33:12 UTC (rev 8018)
+++ branches/gs-esp-gpl-merger/toolbin/tests/fuzzy.c	2007-06-05 15:53:48 UTC (rev 8019)
@@ -309,6 +309,7 @@
   }
   image = (ImagePnm *)malloc (sizeof(ImagePnm));
   image->f = f;
+  image->file_length = file_length(fileno(f));
   return image;
 }
 
@@ -364,7 +365,6 @@
   image->super.raster = n_chan * ((width * bpp + 7) >> 3);
   image->super.n_chan = n_chan;
   image->super.bpp = bpp;
-  image->file_length = file_length(fileno(image->f));
   return 0;
 }
 



More information about the gs-cvs mailing list