[gs-cvs] rev 7855 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Mon Apr 16 11:53:13 PDT 2007
Author: leonardo
Date: 2007-04-16 11:53:12 -0700 (Mon, 16 Apr 2007)
New Revision: 7855
Modified:
trunk/gs/src/gsptype1.c
trunk/gs/src/gsptype1.h
trunk/gs/src/gxfill.c
trunk/gs/src/gxp1fill.c
trunk/gs/src/gxpageq.c
trunk/gs/src/gxpcmap.c
trunk/gs/src/gxpcolor.h
trunk/gs/src/lib.mak
Log:
Implementing high level patterns, step 5.
DETAILS :
This is a preparation for fixing the bug 688396, step 5.
This change is algorithmically equivalent :
the new behavior is temporarily disabled with
MAX_BITMAP_PATTERN_SIZE macro.
This patch :
1. Implements the tiling.
2. Releases the clist buffer when the clist writer completes with a pattern stream.
3. Cleans warnings from Cygwin/gcc build.
4. Fixes a compilation error in gxpageq.c .
This code needs improvements :
1. The memory cleanup is not done when the clist-based pattern cache entry purges.
2. Large uncolored patterns work as colored (not tested yet).
3. Get rid of non_gc_memory in the pattern clist writer.
EXPECTED DIFFERENCES :
None.
Modified: trunk/gs/src/gsptype1.c
===================================================================
--- trunk/gs/src/gsptype1.c 2007-04-16 14:45:42 UTC (rev 7854)
+++ trunk/gs/src/gsptype1.c 2007-04-16 18:53:12 UTC (rev 7855)
@@ -449,6 +449,13 @@
&((const gs_pattern1_instance_t *)pinst)->template;
}
+/* Check device color for Pattern Type 1. */
+bool
+gx_dc_is_pattern1_color(const gx_device_color *pdevc)
+{
+ return pdevc->type == &gx_dc_pattern;
+}
+
/*
* Perform actions required at setcolor time. This procedure resets the
* overprint information (almost) as required by the pattern. The logic
Modified: trunk/gs/src/gsptype1.h
===================================================================
--- trunk/gs/src/gsptype1.h 2007-04-16 14:45:42 UTC (rev 7854)
+++ trunk/gs/src/gsptype1.h 2007-04-16 18:53:12 UTC (rev 7855)
@@ -20,6 +20,11 @@
#include "gspcolor.h"
#include "gxbitmap.h"
+#ifndef gx_device_color_DEFINED
+# define gx_device_color_DEFINED
+typedef struct gx_device_color_s gx_device_color;
+#endif
+
/* ---------------- Types and structures ---------------- */
/* PatternType 1 template */
@@ -78,6 +83,9 @@
const gs_matrix *, gs_state *, gs_memory_t *);
const gs_client_pattern *gs_getpattern(const gs_client_color *);
+/* Check device color for Pattern Type 1. */
+bool gx_dc_is_pattern1_color(const gx_device_color *pdevc);
+
/*
* Make a pattern from a bitmap or pixmap. The pattern may be colored or
* uncolored, as determined by the mask operand. This code is intended
Modified: trunk/gs/src/gxfill.c
===================================================================
--- trunk/gs/src/gxfill.c 2007-04-16 14:45:42 UTC (rev 7854)
+++ trunk/gs/src/gxfill.c 2007-04-16 18:53:12 UTC (rev 7855)
@@ -41,7 +41,9 @@
#include "gxpaint.h" /* for prototypes */
#include "gxfdrop.h"
#include "gxfill.h"
+#include "gsptype1.h"
#include "gsptype2.h"
+#include "gxpcolor.h"
#include "gdevddrw.h"
#include "gzspotan.h" /* Only for gx_san_trap_store. */
#include "memory_.h"
@@ -565,7 +567,10 @@
{
int code;
- if ((gx_dc_is_pattern2_color(pdevc) || pdevc->type == &gx_dc_type_data_ht_colored)) {
+ if (gx_dc_is_pattern2_color(pdevc)
+ || pdevc->type == &gx_dc_type_data_ht_colored
+ || (gx_dc_is_pattern1_color(pdevc) && gx_pattern_tile_is_clist(pdevc->colors.pattern.p_tile))
+ ) {
/* Optimization for shading and halftone fill :
The general filling algorithm subdivides the fill region into
trapezoid or rectangle subregions and then paints each subregion
@@ -589,7 +594,7 @@
(gs_imager_state *)pis, params);
/* Do fill : */
if (code >= 0) {
- if (pdevc->type == &gx_dc_type_data_ht_colored) {
+ 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;
Modified: trunk/gs/src/gxp1fill.c
===================================================================
--- trunk/gs/src/gxp1fill.c 2007-04-16 14:45:42 UTC (rev 7854)
+++ trunk/gs/src/gxp1fill.c 2007-04-16 18:53:12 UTC (rev 7855)
@@ -237,13 +237,23 @@
return code;
}
-private int
-clist_fopen_dummy(char fname[gp_file_name_sizeof], const char *fmode,
- clist_file_ptr * pcf,
- gs_memory_t * mem, gs_memory_t *data_mem,
- bool ok_to_compress)
+/* Fill a rectangle with a colored Pattern. */
+/* Note that we treat this as "texture" for RasterOp. */
+private int
+tile_pattern_clist(const tile_fill_state_t * ptfs,
+ int x, int y, int w, int h)
{
- return 0;
+ gx_color_tile *ptile = ptfs->pdevc->colors.pattern.p_tile;
+ gx_device_clist *cdev = ptile->cdev;
+ gx_device_clist_reader *crdev = (gx_device_clist_reader *)cdev;
+ gx_device *dev = ptfs->orig_dev;
+ int code;
+
+ crdev->page_info.io_procs->rewind(crdev->page_info.bfile, false, NULL);
+ crdev->page_info.io_procs->rewind(crdev->page_info.cfile, false, NULL);
+ code = clist_playback_file_bands(playback_action_render,
+ crdev, &crdev->page_info, dev, 0, 0, ptfs->xoff - x, ptfs->yoff - y);
+ return code;
}
int
@@ -263,29 +273,11 @@
return 0;
if (rop_source == NULL)
set_rop_no_source(rop_source, no_source, dev);
- if (ptile->cdev != NULL) {
- gs_memory_t *mem = dev->memory;
- gx_device_clist *cdev = ptile->cdev;
- gx_device_clist_reader *crdev = (gx_device_clist_reader *)cdev;
- int x0 = 0, y0 = 0;
- gx_device_buf_procs_t buf_procs = {0};
-
- crdev->yplane.depth = 0; /* Don't know what to set here. */
- crdev->yplane.shift = 0;
- crdev->yplane.index = -1;
- crdev->pages = NULL;
- crdev->num_pages = 1;
- crdev->page_info.io_procs->rewind(crdev->page_info.bfile, false, NULL);
- crdev->page_info.io_procs->rewind(crdev->page_info.cfile, false, NULL);
- code = clist_playback_file_bands(playback_action_render,
- crdev, &crdev->page_info, dev, 0, 0, x0, y0);
- return code;
- }
bits = &ptile->tbits;
code = tile_fill_init(&state, pdevc, dev, false);
if (code < 0)
return code;
- if (ptile->is_simple) {
+ if (ptile->is_simple && ptile->cdev == NULL) {
int px =
imod(-(int)(ptile->step_matrix.tx - state.phase.x + 0.5),
bits->rep_width);
@@ -310,9 +302,27 @@
state.lop = lop;
state.source = source;
state.rop_source = rop_source;
- state.orig_dev = dev;
- code = tile_by_steps(&state, x, y, w, h, ptile,
- &ptile->tbits, tile_colored_fill);
+ state.orig_dev = dev;
+ if (ptile->cdev == NULL) {
+ code = tile_by_steps(&state, x, y, w, h, ptile,
+ &ptile->tbits, tile_colored_fill);
+ } else {
+ gx_device_clist *cdev = ptile->cdev;
+ gx_device_clist_reader *crdev = (gx_device_clist_reader *)cdev;
+ gx_strip_bitmap tbits;
+
+ crdev->yplane.depth = 0; /* Don't know what to set here. */
+ crdev->yplane.shift = 0;
+ crdev->yplane.index = -1;
+ crdev->pages = NULL;
+ crdev->num_pages = 1;
+ state.orig_dev = dev;
+ tbits = ptile->tbits;
+ tbits.size.x = crdev->width;
+ tbits.size.y = crdev->height;
+ code = tile_by_steps(&state, x, y, w, h, ptile,
+ &tbits, tile_pattern_clist);
+ }
}
return code;
}
Modified: trunk/gs/src/gxpageq.c
===================================================================
--- trunk/gs/src/gxpageq.c 2007-04-16 14:45:42 UTC (rev 7854)
+++ trunk/gs/src/gxpageq.c 2007-04-16 18:53:12 UTC (rev 7855)
@@ -298,7 +298,7 @@
entry->page_info = *page_info;
else {
entry->page_info = null_page_info;
- entry->page_info.io_procs = pcwdev->io_procs;
+ entry->page_info.io_procs = pcwdev->page_info.io_procs;
}
entry->num_copies = page_count;
Modified: trunk/gs/src/gxpcmap.c
===================================================================
--- trunk/gs/src/gxpcmap.c 2007-04-16 14:45:42 UTC (rev 7854)
+++ trunk/gs/src/gxpcmap.c 2007-04-16 18:53:12 UTC (rev 7855)
@@ -29,6 +29,7 @@
#include "gxpcolor.h"
#include "gxp1impl.h"
#include "gxclist.h"
+#include "gxcldev.h"
#include "gzstate.h"
/* Define the default size of the Pattern cache. */
@@ -198,8 +199,6 @@
adev->bitmap_memory = storage_memory;
fdev = (gx_device_forward *)adev;
} else {
- int code;
- int save_height = tdev->height;
gx_device_buf_procs_t buf_procs = {dummy_create_buf_device,
dummy_size_buf_device, dummy_setup_buf_device, dummy_destroy_buf_device};
gx_device_clist *cdev = gs_alloc_struct(mem, gx_device_clist,
@@ -719,6 +718,13 @@
ctile->tmask.size.x = 0;
ctile->tmask.size.y = 0;
ctile->cdev = cdev;
+ gs_free_object(cwdev->bandlist_memory, cwdev->data, "gx_pattern_cache_add_entry");
+ cwdev->data = NULL;
+ cwdev->states = NULL;
+ cwdev->cbuf = NULL;
+ cwdev->cnext = NULL;
+ cwdev->cend = NULL;
+ cwdev->ccl = NULL;
/* Prevent freeing files on pattern_paint_cleanup : */
cwdev->do_not_open_or_close_bandfiles = true;
}
@@ -727,6 +733,12 @@
return 0;
}
+bool
+gx_pattern_tile_is_clist(gx_color_tile *ptile)
+{
+ return ptile->cdev != NULL;
+}
+
/* Add a dummy Pattern cache entry. Stubs a pattern tile for interpreter when
device handles high level patterns. */
int
Modified: trunk/gs/src/gxpcolor.h
===================================================================
--- trunk/gs/src/gxpcolor.h 2007-04-16 14:45:42 UTC (rev 7854)
+++ trunk/gs/src/gxpcolor.h 2007-04-16 18:53:12 UTC (rev 7855)
@@ -246,4 +246,8 @@
bool (*)(gx_color_tile *, void *),
void *);
+bool gx_pattern_tile_is_clist(gx_color_tile *ptile);
+
+dev_proc_open_device(pattern_clist_open_device);
+
#endif /* gxpcolor_INCLUDED */
Modified: trunk/gs/src/lib.mak
===================================================================
--- trunk/gs/src/lib.mak 2007-04-16 14:45:42 UTC (rev 7854)
+++ trunk/gs/src/lib.mak 2007-04-16 18:53:12 UTC (rev 7855)
@@ -607,7 +607,7 @@
$(GLOBJ)gxfill.$(OBJ) : $(GLSRC)gxfill.c $(GXERR)\
$(gsstruct_h)\
$(gxdcolor_h) $(gxdevice_h) $(gxfixed_h) $(gxhttile_h)\
- $(gxistate_h) $(gxpaint_h) $(gxfill_h) $(gxfdrop_h) $(gsptype2_h)\
+ $(gxistate_h) $(gxpaint_h) $(gxfill_h) $(gxfdrop_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
@@ -2070,7 +2070,7 @@
$(GLOBJ)gxpcmap.$(OBJ) : $(GLSRC)gxpcmap.c $(GXERR) $(math__h) $(memory__h)\
$(gsstruct_h) $(gsutil_h)\
$(gxcolor2_h) $(gxcspace_h) $(gxdcolor_h) $(gxdevice_h) $(gxdevmem_h)\
- $(gxfixed_h) $(gxmatrix_h) $(gxpcolor_h) $(gxclist_h)\
+ $(gxfixed_h) $(gxmatrix_h) $(gxpcolor_h) $(gxclist_h) $(gxcldev_h)\
$(gzstate_h)
$(GLCC) $(GLO_)gxpcmap.$(OBJ) $(C_) $(GLSRC)gxpcmap.c
More information about the gs-cvs
mailing list