[gs-cvs] rev 8655 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Mon Apr 21 07:53:41 PDT 2008
Author: leonardo
Date: 2008-04-21 07:53:38 -0700 (Mon, 21 Apr 2008)
New Revision: 8655
Modified:
trunk/gs/src/gdevfax.c
trunk/gs/src/gsptype1.c
trunk/gs/src/gsptype1.h
trunk/gs/src/gsptype2.c
trunk/gs/src/gxclimag.c
trunk/gs/src/gxclist.c
trunk/gs/src/gxclist.h
trunk/gs/src/gxclrast.c
trunk/gs/src/gxclread.c
trunk/gs/src/gxdcolor.c
trunk/gs/src/gxdcolor.h
trunk/gs/src/gxp1fill.c
trunk/gs/src/gxpcmap.c
trunk/gs/src/gxpcolor.h
trunk/gs/src/lib.mak
Log:
Enhancement (graphics) : Delay applying big patterns until page clist interpretation.
DETAILS :
This is a preparation for fixing
the bug 689440 "PostScript file generates infinitely large temp file".
The old code decomposes the imagemask into rectangles,
each of which decomposed the pattern color into a huge list of rectangles.
See more about the old code in Comment #11 of the bug 689440.
Now we delay the decomposition until the page clist playback.
This patch reduces the clist file size for the bug 689440
from 355GB to an acceptable size of 316Mb. A further shortening
is possible as explained in (5) below. But the rasterization time is still
unacceptably long - more than 48 hours. It will be improved
in a next step with converting imagemask with pattern color
into a painting of a pattern color with a mask clip device.
1. The old functions gx_dc_pattern_write, gx_dc_pattern_read actually
are generic functions for multiple color types,
which simply return an error. Renamed them into
gx_dc_cannot_write, gx_dc_cannot_read.
2. Implemented new gx_dc_pattern_write, gx_dc_pattern_read for clist-based patterns.
They copy pattern clist data to/from page clist. Currently this code
doesn't try to compress the data, but probably we'll need to do that.
3. Changed a condition in gxclimag.c to pass imagemask
with a clist-based pattern color to clist writer.
Also moved some checks to provide image matrix to be computed
when the new condition is true.
4. Added more functions into gxclist.c, gxclist.h for accessing
data of a clist-based pattern.
5. gx_dc_pattern_read now constructs pattern cache and stores the
clist-based pattern "tile" to it. The clist reader releases the cache before exiting a band.
We will need an optimization agains redundant writing of patterns into page clist.
This necessary optimization to be done in a next step.
6. Propagated error codes in gxclread.c, gdevfax.c for easier debugging.
7. Improved debug printing in gxp1fill.c to designate
recursive calls to clist interpreter when a clist-based pattern
in interpreted while a page clist playback.
8. Added new accessors into gxpcmap.c, which are needed
to access pattern cache while a page clist interpretation.
9. Updated dependencies in makefiles.
10. Fixed the dependenco of gxdcolor.c on gxdevcli_h, which was missed before this change.
11. Added the pattern color type into the list in gxdcolor.c,
because now we need to write it into clist. An old comment
reads that it was not included against unuseful reference to
pattern stuff in a Postscript Language Level 1 build.
The reference now appears, and this is unfortunate.
We think that level 1 builds are not important in nowadays.
On necessity it may be improved in a separate change.
EXPECTED DIFFERENCES :
None.
Modified: trunk/gs/src/gdevfax.c
===================================================================
--- trunk/gs/src/gdevfax.c 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/gdevfax.c 2008-04-21 14:53:38 UTC (rev 8655)
@@ -197,7 +197,11 @@
uint left = r.limit - r.ptr;
memcpy(in, r.ptr + 1, left);
- gdev_prn_copy_scan_lines(pdev, lnum++, in + left, in_size);
+ code = gdev_prn_copy_scan_lines(pdev, lnum++, in + left, in_size);
+ if (code < 0) {
+ gs_note_error(code);
+ goto done;
+ }
/* Note: we use col_size here, not in_size. */
if (col_size > in_size) {
memset(in + left + in_size, 0, col_size - in_size);
Modified: trunk/gs/src/gsptype1.c
===================================================================
--- trunk/gs/src/gsptype1.c 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/gsptype1.c 2008-04-21 14:53:38 UTC (rev 8655)
@@ -14,6 +14,7 @@
/* $Id$ */
/* PatternType 1 pattern implementation */
#include "math_.h"
+#include "memory_.h"
#include "gx.h"
#include "gserrors.h"
#include "gsrop.h"
@@ -33,6 +34,7 @@
#include "gxpath.h"
#include "gxpcolor.h"
#include "gxp1impl.h" /* requires gxpcolor.h */
+#include "gxclist.h"
#include "gzstate.h"
#include "gsimage.h"
#include "gsiparm4.h"
@@ -490,6 +492,15 @@
return pdevc->type == &gx_dc_pattern;
}
+/* Check device color for Pattern Type 1. */
+bool
+gx_dc_is_pattern1_color_clist_based(const gx_device_color *pdevc)
+{
+ if (pdevc->type != &gx_dc_pattern)
+ return false;
+ return gx_pattern_tile_is_clist(pdevc->colors.pattern.p_tile);
+}
+
/*
* Perform actions required at setcolor time. This procedure resets the
* overprint information (almost) as required by the pattern. The logic
@@ -919,7 +930,7 @@
gx_dc_no_get_phase,
gx_dc_pure_masked_load, gx_dc_pure_masked_fill_rect,
gx_dc_default_fill_masked, gx_dc_pure_masked_equal,
- gx_dc_pattern_write, gx_dc_pattern_read,
+ gx_dc_cannot_write, gx_dc_cannot_read,
gx_dc_pure_get_nonzero_comps
};
@@ -932,7 +943,7 @@
gx_dc_ht_get_phase,
gx_dc_binary_masked_load, gx_dc_binary_masked_fill_rect,
gx_dc_default_fill_masked, gx_dc_binary_masked_equal,
- gx_dc_pattern_write, gx_dc_pattern_read,
+ gx_dc_cannot_write, gx_dc_cannot_read,
gx_dc_ht_binary_get_nonzero_comps
};
@@ -945,7 +956,7 @@
gx_dc_ht_get_phase,
gx_dc_colored_masked_load, gx_dc_colored_masked_fill_rect,
gx_dc_default_fill_masked, gx_dc_colored_masked_equal,
- gx_dc_pattern_write, gx_dc_pattern_read,
+ gx_dc_cannot_write, gx_dc_cannot_read,
gx_dc_ht_colored_get_nonzero_comps
};
@@ -1222,6 +1233,18 @@
pdevc1->mask.id == pdevc2->mask.id;
}
+
+typedef struct gx_dc_serialized_tile_s {
+ gs_id id;
+ int size_b, size_c;
+ gs_int_point size;
+ gs_matrix step_matrix;
+ gs_rect bbox;
+ byte depth;
+ byte tiling_type;
+ bool is_simple;
+} gx_dc_serialized_tile_t;
+
/* currently, patterns cannot be passed through the command list */
int
gx_dc_pattern_write(
@@ -1232,7 +1255,70 @@
byte * data,
uint * psize )
{
- return_error(gs_error_unknownerror);
+ gx_color_tile *ptile = pdevc->colors.pattern.p_tile;
+ int size_b, size_c;
+ byte *dp = data;
+ int left = *psize;
+ int offset1 = offset;
+ gx_dc_serialized_tile_t buf;
+ int code, l;
+
+ if (ptile->cdev == NULL) {
+ /* Currently we support clist-based patterns only. */
+ return_error(gs_error_unknownerror);
+ }
+ if (psdc->type == pdevc->type) {
+ if (psdc->colors.pattern.id == ptile->id) {
+ /* fixme : Do we need to check phase ? How ? */
+ return 1; /* Same as saved one, don't write. */
+ }
+ }
+ size_b = clist_data_size(ptile->cdev, 0);
+ if (size_b < 0)
+ return_error(gs_error_unregistered);
+ size_c = clist_data_size(ptile->cdev, 1);
+ if (size_c < 0)
+ return_error(gs_error_unregistered);
+ if (data == NULL) {
+ *psize = sizeof(buf) + size_b + size_c;
+ return 0;
+ }
+ if (offset1 == 0) { /* Serialize tile parameters: */
+ buf.id = ptile->id;
+ buf.size.x = ptile->cdev->common.width;
+ buf.size.y = ptile->cdev->common.height;
+ buf.size_b = size_b;
+ buf.size_c = size_c;
+ buf.step_matrix = ptile->step_matrix;
+ buf.bbox = ptile->bbox;
+ buf.depth = ptile->depth;
+ buf.tiling_type = ptile->tiling_type;
+ buf.is_simple = ptile->is_simple;
+ if (sizeof(buf) > left) {
+ /* For a while we require the client to provide enough buffer size. */
+ return_error(gs_error_unregistered); /* Must not happen. */
+ }
+ memcpy(dp, &buf, sizeof(buf));
+ left -= sizeof(buf);
+ dp += sizeof(buf);
+ offset1 += sizeof(buf);
+ }
+ if (offset1 <= sizeof(buf) + size_b) {
+ l = min(left, size_b - (offset1 - sizeof(buf)));
+ code = clist_get_data(ptile->cdev, 0, offset1 - sizeof(buf), dp, l);
+ if (code < 0)
+ return code;
+ left -= l;
+ offset1 += l;
+ dp += l;
+ }
+ if (left > 0) {
+ l = min(left, size_c - (offset1 - sizeof(buf) - size_b));
+ code = clist_get_data(ptile->cdev, 1, offset1 - sizeof(buf) - size_b, dp, l);
+ if (code < 0)
+ return code;
+ }
+ return 0;
}
int
@@ -1246,5 +1332,105 @@
uint size,
gs_memory_t * mem )
{
- return_error(gs_error_unknownerror);
+ gx_dc_serialized_tile_t buf;
+ int size_b, size_c = -1;
+ const byte *dp = data;
+ int left = size;
+ int offset1 = offset;
+ gx_color_tile *ptile;
+ int code, l;
+
+ if (offset == 0) {
+ if (sizeof(buf) > size) {
+ /* For a while we require the client to provide enough buffer size. */
+ return_error(gs_error_unregistered); /* Must not happen. */
+ }
+ memcpy(&buf, dp, sizeof(buf));
+ dp += sizeof(buf);
+ left -= sizeof(buf);
+ offset1 += sizeof(buf);
+
+ code = gx_pattern_cache_get_entry((gs_imager_state *)pis, /* Break 'const'. */
+ buf.id, &ptile);
+ if (code < 0)
+ return code;
+ pdevc->type = &gx_dc_pattern;
+ pdevc->colors.pattern.p_tile = ptile;
+ ptile->id = buf.id;
+ pdevc->mask.id = buf.id;
+ size_b = buf.size_b;
+ size_c = buf.size_c;
+ ptile->step_matrix = buf.step_matrix;
+ ptile->bbox = buf.bbox;
+ ptile->depth = buf.depth;
+ ptile->tiling_type = buf.tiling_type;
+ ptile->is_simple = buf.is_simple;
+ ptile->is_dummy = 0;
+ 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.
+ */
+ /* fixme: state.device below specifies a wrong color_info for PaintType 1.
+ It must be 1 bit per pixel. */
+ 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) {
+ 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
+ {
+ 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;
+ ptile->cdev = (gx_device_clist *)gx_pattern_accum_alloc(mem, mem,
+ &inst, "gx_dc_pattern_read");
+ if (ptile->cdev == NULL)
+ return_error(gs_error_VMerror);
+ code = dev_proc(&ptile->cdev->writer, open_device)((gx_device *)&ptile->cdev->writer);
+ if (code < 0)
+ return code;
+ }
+ } else {
+ ptile = pdevc->colors.pattern.p_tile;
+ size_b = ptile->tbits.size.x;
+ size_c = ptile->tbits.size.y;
+ }
+ if (offset1 <= sizeof(buf) + size_b) {
+ l = min(left, size_b - (offset1 - sizeof(buf)));
+ code = clist_put_data(ptile->cdev, 0, offset1 - sizeof(buf), dp, l);
+ if (code < 0)
+ return code;
+ l = code;
+ left -= l;
+ offset1 += l;
+ dp += l;
+ ptile->cdev->common.page_bfile_end_pos = offset1 - sizeof(buf);
+ }
+ if (left > 0) {
+ l = left;
+ code = clist_put_data(ptile->cdev, 1, offset1 - sizeof(buf) - size_b, dp, l);
+ if (code < 0)
+ return code;
+ l = code;
+ left -= l;
+ offset1 += l;
+ }
+ return size - left;
}
Modified: trunk/gs/src/gsptype1.h
===================================================================
--- trunk/gs/src/gsptype1.h 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/gsptype1.h 2008-04-21 14:53:38 UTC (rev 8655)
@@ -86,6 +86,9 @@
/* Check device color for Pattern Type 1. */
bool gx_dc_is_pattern1_color(const gx_device_color *pdevc);
+/* Check device color for clist-based Pattern Type 1. */
+bool gx_dc_is_pattern1_color_clist_based(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/gsptype2.c
===================================================================
--- trunk/gs/src/gsptype2.c 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/gsptype2.c 2008-04-21 14:53:38 UTC (rev 8655)
@@ -144,7 +144,7 @@
gx_dc_ht_get_phase,
gx_dc_pattern2_load, gx_dc_pattern2_fill_rectangle,
gx_dc_default_fill_masked, gx_dc_pattern2_equal,
- gx_dc_pattern_write, gx_dc_pattern_read,
+ gx_dc_cannot_write, gx_dc_cannot_read,
gx_dc_pattern_get_nonzero_comps
};
Modified: trunk/gs/src/gxclimag.c
===================================================================
--- trunk/gs/src/gxclimag.c 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/gxclimag.c 2008-04-21 14:53:38 UTC (rev 8655)
@@ -34,6 +34,7 @@
#include "gxcomp.h"
#include "gsserial.h"
#include "gxdhtserial.h"
+#include "gsptype1.h"
extern_gx_image_type_table();
@@ -391,8 +392,6 @@
cdev->image_enum_id != gs_no_id || /* Can't handle nested images */
/****** CAN'T HANDLE CIE COLOR YET ******/
base_index > gs_color_space_index_DeviceCMYK ||
- /****** CAN'T HANDLE NON-PURE COLORS YET ******/
- (uses_color && !gx_dc_is_pure(pdcolor)) ||
/****** CAN'T HANDLE IMAGES WITH ALPHA YET ******/
has_alpha ||
/****** CAN'T HANDLE IMAGES WITH IRREGULAR DEPTHS ******/
@@ -401,7 +400,9 @@
(code = gs_matrix_multiply(&mat, &ctm_only(pis), &mat)) < 0 ||
!(cdev->disable_mask & clist_disable_nonrect_hl_image ?
(is_xxyy(&mat) || is_xyyx(&mat)) :
- image_matrix_ok_to_band(&mat))
+ image_matrix_ok_to_band(&mat)) ||
+ /****** CAN'T HANDLE NON-PURE COLORS YET ******/
+ (uses_color && !gx_dc_is_pure(pdcolor) && !gx_dc_is_pattern1_color_clist_based(pdcolor))
)
goto use_default;
{
Modified: trunk/gs/src/gxclist.c
===================================================================
--- trunk/gs/src/gxclist.c 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/gxclist.c 2008-04-21 14:53:38 UTC (rev 8655)
@@ -965,3 +965,60 @@
}
return 0;
}
+
+/* Retrieve total size for cfile and bfile. */
+int clist_data_size(const gx_device_clist *cdev, int select)
+{
+ const gx_band_page_info_t *pinfo = &cdev->common.page_info;
+ clist_file_ptr pfile = (!select ? pinfo->bfile : pinfo->cfile);
+ const char *fname = (!select ? pinfo->bfname : pinfo->cfname);
+ int code, size;
+
+ code = pinfo->io_procs->fseek(pfile, 0, SEEK_END, fname);
+ if (code < 0)
+ return_error(gs_error_unregistered); /* Must not happen. */
+ code = pinfo->io_procs->ftell(pfile);
+ if (code < 0)
+ return_error(gs_error_unregistered); /* Must not happen. */
+ size = code;
+ return size;
+}
+
+/* Get command list data. */
+int
+clist_get_data(const gx_device_clist *cdev, int select, int offset, byte *buf, int length)
+{
+ const gx_band_page_info_t *pinfo = &cdev->common.page_info;
+ clist_file_ptr pfile = (!select ? pinfo->bfile : pinfo->cfile);
+ const char *fname = (!select ? pinfo->bfname : pinfo->cfname);
+ int code;
+
+ code = pinfo->io_procs->fseek(pfile, offset, SEEK_SET, fname);
+ if (code < 0)
+ return_error(gs_error_unregistered); /* Must not happen. */
+ /* This assumes that fread_chars doesn't return prematurely
+ when the buffer is not fully filled and the end of stream is not reached. */
+ return pinfo->io_procs->fread_chars(buf, length, pfile);
+}
+
+/* Put command list data. */
+int
+clist_put_data(const gx_device_clist *cdev, int select, int offset, const byte *buf, int length)
+{
+ const gx_band_page_info_t *pinfo = &cdev->common.page_info;
+ clist_file_ptr pfile = (!select ? pinfo->bfile : pinfo->cfile);
+ const char *fname = (!select ? pinfo->bfname : pinfo->cfname);
+ int code;
+
+ code = pinfo->io_procs->ftell(pfile);
+ if (code < 0)
+ return_error(gs_error_unregistered); /* Must not happen. */
+ if (code != offset) {
+ /* Assuming a consecutive writing only. */
+ return_error(gs_error_unregistered); /* Must not happen. */
+ }
+ /* This assumes that fwrite_chars doesn't return prematurely
+ when the buffer is not fully written, except with an error. */
+ return pinfo->io_procs->fwrite_chars(buf, length, pfile);
+}
+
Modified: trunk/gs/src/gxclist.h
===================================================================
--- trunk/gs/src/gxclist.h 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/gxclist.h 2008-04-21 14:53:38 UTC (rev 8655)
@@ -407,6 +407,13 @@
void
clist_copy_band_complexity(gx_band_complexity_t *this, const gx_band_complexity_t *from);
+/* Retrieve total size for cfile and bfile. */
+int clist_data_size(const gx_device_clist *cdev, int select);
+/* Get command list data. */
+int clist_get_data(const gx_device_clist *cdev, int select, int offset, byte *buf, int length);
+/* Put command list data. */
+int clist_put_data(const gx_device_clist *cdev, int select, int offset, const byte *buf, int length);
+
#ifdef DEBUG
#define clist_debug_rect clist_debug_rect_imp
void clist_debug_rect_imp(int x, int y, int width, int height);
Modified: trunk/gs/src/gxclrast.c
===================================================================
--- trunk/gs/src/gxclrast.c 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/gxclrast.c 2008-04-21 14:53:38 UTC (rev 8655)
@@ -1361,8 +1361,10 @@
} else
rdata = cbuf.data;
memmove(rdata, cbp, cleft);
- sgets(s, rdata + cleft, rleft,
- &rleft);
+ if (sgets(s, rdata + cleft, rleft, &rleft) < 0) {
+ code = gs_note_error(gs_error_unregistered); /* Must not happen. */
+ goto out;
+ }
planes[0].data = rdata;
cbp = cbuf.end; /* force refill */
}
@@ -1607,6 +1609,7 @@
case cmd_opv_ext_put_drawing_color:
{
uint color_size;
+ int left, offset, l;
const gx_device_color_type_t * pdct;
pdct = gx_get_dc_type_from_index(*cbp++);
@@ -1615,17 +1618,34 @@
goto out;
}
enc_u_getw(color_size, cbp);
- if (cbp + color_size > cbuf.limit) {
- code = top_up_cbuf(&cbuf, &cbp);
+ left = color_size;
+ offset = 0;
+ if (!left) {
+ /* We still need to call pdct->read because it may change dev_color.type -
+ see gx_dc_null_read.*/
+ code = pdct->read(&dev_color, &imager_state,
+ &dev_color, tdev, offset, cbp,
+ 0, mem);
if (code < 0)
- return code;
+ goto out;
}
- code = pdct->read(&dev_color, &imager_state,
- &dev_color, tdev, 0, cbp,
- color_size, mem);
- if (code < 0)
- goto out;
- cbp += color_size;
+ while (left) {
+ if (cbp + left > cbuf.limit) {
+ code = top_up_cbuf(&cbuf, &cbp);
+ if (code < 0)
+ return code;
+ }
+ l = min(left, cbuf.end - cbp);
+ code = pdct->read(&dev_color, &imager_state,
+ &dev_color, tdev, offset, cbp,
+ l, mem);
+ if (code < 0)
+ goto out;
+ l = code;
+ cbp += l;
+ offset += l;
+ left -= l;
+ }
code = gx_color_load(&dev_color,
&imager_state, tdev);
if (code < 0)
@@ -2022,6 +2042,10 @@
rc_decrement(pcs, "clist_playback_band");
gx_cpath_free(&clip_path, "clist_render_band exit");
gx_path_free(&path, "clist_render_band exit");
+ if (imager_state.pattern_cache != NULL) {
+ gx_pattern_cache_free(imager_state.pattern_cache);
+ imager_state.pattern_cache = NULL;
+ }
gs_imager_state_release(&imager_state);
gs_free_object(mem, data_bits, "clist_playback_band(data_bits)");
if (target != orig_target) {
Modified: trunk/gs/src/gxclread.c
===================================================================
--- trunk/gs/src/gxclread.c 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/gxclread.c 2008-04-21 14:53:38 UTC (rev 8655)
@@ -171,8 +171,13 @@
int bmin = ss->b_this.band_min;
int bmax = ss->b_this.band_max;
int64_t pos = ss->b_this.pos;
+ int nread;
- io_procs->fread_chars(&ss->b_this, sizeof(ss->b_this), bfile);
+ nread = io_procs->fread_chars(&ss->b_this, sizeof(ss->b_this), bfile);
+ if (nread < sizeof(ss->b_this)) {
+ gs_note_error(gs_error_unregistered); /* Must not happen. */
+ return ERRC;
+ }
if (!(ss->band_last >= bmin && ss->band_first <= bmax))
goto rb;
io_procs->fseek(cfile, pos, SEEK_SET, ss->page_cfname);
Modified: trunk/gs/src/gxdcolor.c
===================================================================
--- trunk/gs/src/gxdcolor.c 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/gxdcolor.c 2008-04-21 14:53:38 UTC (rev 8655)
@@ -18,6 +18,7 @@
#include "gserrors.h"
#include "gsbittab.h"
#include "gxdcolor.h"
+#include "gxpcolor.h"
#include "gxdevice.h"
#include "gxdevcli.h"
@@ -178,7 +179,7 @@
gx_dc_type_none, /* unset device color */
gx_dc_type_null, /* blank (transparent) device color */
gx_dc_type_pure, /* pure device color */
- /* gx_dc_type_pattern, */ /* patterns - not used in command list */
+ gx_dc_type_pattern, /* patterns */
gx_dc_type_ht_binary, /* binary halftone device colors */
gx_dc_type_ht_colored, /* general halftone device colors */
gx_dc_type_wts /* well-tempered screen device colors */
@@ -303,6 +304,32 @@
return 0;
}
+int
+gx_dc_cannot_write(
+ const gx_device_color * pdevc, /* ignored */
+ const gx_device_color_saved * psdc, /* ignored */
+ const gx_device * dev, /* ignored */
+ uint offset, /* ignored */
+ byte * data, /* ignored */
+ uint * psize )
+{
+ return_error(gs_error_unknownerror);
+}
+
+int
+gx_dc_cannot_read(
+ gx_device_color * pdevc,
+ const gs_imager_state * pis, /* ignored */
+ const gx_device_color * prior_devc, /* ignored */
+ const gx_device * dev, /* ignored */
+ uint offset, /* ignored */
+ const byte * pdata, /* ignored */
+ uint size, /* ignored */
+ gs_memory_t * mem ) /* ignored */
+{
+ return_error(gs_error_unknownerror);
+}
+
static int
gx_dc_no_get_nonzero_comps(
const gx_device_color * pdevc_ignored,
@@ -699,7 +726,7 @@
/* check for adequate space */
if (*psize < num_bytes) {
*psize = num_bytes;
- return gs_error_rangecheck;
+ return_error(gs_error_rangecheck);
}
*psize = num_bytes;
@@ -749,7 +776,7 @@
/* check that enough data has been provided */
if (size < 1 || (pdata[0] != 0xff && size < num_bytes))
- return gs_error_rangecheck;
+ return_error(gs_error_rangecheck);
/* check of gx_no_color_index */
if (pdata[0] == 0xff) {
Modified: trunk/gs/src/gxdcolor.h
===================================================================
--- trunk/gs/src/gxdcolor.h 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/gxdcolor.h 2008-04-21 14:53:38 UTC (rev 8655)
@@ -252,6 +252,9 @@
/* Define the default implementation of fill_masked. */
dev_color_proc_fill_masked(gx_dc_default_fill_masked);
+extern dev_color_proc_write(gx_dc_cannot_write);
+extern dev_color_proc_read(gx_dc_cannot_read);
+
extern_st(st_device_color);
/* public_st_device_color() is defined in gsdcolor.h */
Modified: trunk/gs/src/gxp1fill.c
===================================================================
--- trunk/gs/src/gxp1fill.c 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/gxp1fill.c 2008-04-21 14:53:38 UTC (rev 8655)
@@ -252,8 +252,11 @@
crdev->offset_map = NULL;
crdev->page_info.io_procs->rewind(crdev->page_info.bfile, false, NULL);
crdev->page_info.io_procs->rewind(crdev->page_info.cfile, false, NULL);
+
+ if_debug0('L', "Pattern clist playback begin\n");
code = clist_playback_file_bands(playback_action_render,
crdev, &crdev->page_info, dev, 0, 0, ptfs->xoff - x, ptfs->yoff - y);
+ if_debug0('L', "Pattern clist playback end\n");
return code;
}
Modified: trunk/gs/src/gxpcmap.c
===================================================================
--- trunk/gs/src/gxpcmap.c 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/gxpcmap.c 2008-04-21 14:53:38 UTC (rev 8655)
@@ -562,6 +562,16 @@
return 0;
}
+/* Free pattern cache and its components. */
+void
+gx_pattern_cache_free(gx_pattern_cache *pcache)
+{
+ pattern_cache_free_all(pcache);
+ gs_free_object(pcache->memory, pcache->tiles, "gx_pattern_cache_free");
+ pcache->tiles = NULL;
+ gs_free_object(pcache->memory, pcache, "gx_pattern_cache_free");
+}
+
/* Get and set the Pattern cache in a gstate. */
gx_pattern_cache *
gstate_pattern_cache(gs_state * pgs)
@@ -749,6 +759,24 @@
return 0;
}
+/* Get entry for reading a pattern from clist. */
+int
+gx_pattern_cache_get_entry(gs_imager_state * pis, gs_id id, gx_color_tile ** pctile)
+{
+ gx_pattern_cache *pcache;
+ gx_color_tile *ctile;
+ int code = ensure_pattern_cache(pis);
+
+ if (code < 0)
+ return code;
+ pcache = pis->pattern_cache;
+ ctile = &pcache->tiles[id % pcache->num_tiles];
+ gx_pattern_cache_free_entry(pis->pattern_cache, ctile);
+ ctile->id = id;
+ *pctile = ctile;
+ return 0;
+}
+
bool
gx_pattern_tile_is_clist(gx_color_tile *ptile)
{
Modified: trunk/gs/src/gxpcolor.h
===================================================================
--- trunk/gs/src/gxpcolor.h 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/gxpcolor.h 2008-04-21 14:53:38 UTC (rev 8655)
@@ -125,7 +125,9 @@
gx_dc_pattern,
gx_dc_pure_masked, gx_dc_binary_masked, gx_dc_colored_masked;
+#ifndef gx_dc_type_pattern
#define gx_dc_type_pattern (&gx_dc_pattern)
+#endif
/*
* These device color methods are shared amongst pattern types.
@@ -194,6 +196,8 @@
uint gx_pat_cache_default_tiles(void);
ulong gx_pat_cache_default_bits(void);
gx_pattern_cache *gx_pattern_alloc_cache(gs_memory_t *, uint, ulong);
+/* Free pattern cache and its components. */
+void gx_pattern_cache_free(gx_pattern_cache *pcache);
/* Get or set the Pattern cache in a gstate. */
gx_pattern_cache *gstate_pattern_cache(gs_state *);
@@ -237,6 +241,10 @@
int gx_pattern_cache_add_dummy_entry(gs_imager_state *pis, gs_pattern1_instance_t *pinst,
int depth);
+/* Get entry for reading a pattern from clist. */
+int gx_pattern_cache_get_entry(gs_imager_state * pis, gs_id id, gx_color_tile ** pctile);
+
+
/* Look up a pattern color in the cache. */
bool gx_pattern_cache_lookup(gx_device_color *, const gs_imager_state *,
gx_device *, gs_color_select_t);
Modified: trunk/gs/src/lib.mak
===================================================================
--- trunk/gs/src/lib.mak 2008-04-21 11:58:27 UTC (rev 8654)
+++ trunk/gs/src/lib.mak 2008-04-21 14:53:38 UTC (rev 8655)
@@ -593,7 +593,8 @@
$(GLCC) $(GLO_)gxdcconv.$(OBJ) $(C_) $(GLSRC)gxdcconv.c
$(GLOBJ)gxdcolor.$(OBJ) : $(GLSRC)gxdcolor.c $(GX)\
- $(memory__h) $(gsbittab_h) $(gserrors_h) $(gxdcolor_h) $(gxdevice_h)
+ $(memory__h) $(gsbittab_h) $(gserrors_h) $(gxdcolor_h) $(gxpcolor_h)\
+ $(gxdevice_h) $(gxdevcli_h)
$(GLCC) $(GLO_)gxdcolor.$(OBJ) $(C_) $(GLSRC)gxdcolor.c
$(GLOBJ)gxhldevc.$(OBJ) : $(GLSRC)gxhldevc.c $(GX)\
@@ -1705,7 +1706,7 @@
$(gxarith_h) $(gxcldev_h) $(gxclpath_h) $(gxcspace_h)\
$(gxdevice_h) $(gxdevmem_h) $(gxfmap_h) $(gxiparam_h) $(gxpath_h)\
$(sisparam_h) $(stream_h) $(strimpl_h) $(gxcomp_h) $(gsserial_h)\
- $(gxdhtserial_h)
+ $(gxdhtserial_h) $(gsptype1_h)
$(GLCC) $(GLO_)gxclimag.$(OBJ) $(C_) $(GLSRC)gxclimag.c
$(GLOBJ)gxclpath.$(OBJ) : $(GLSRC)gxclpath.c $(GXERR)\
@@ -2058,11 +2059,11 @@
$(gxpath_h) $(gxpcolor_h) $(gzstate_h) $(stream_h)
$(GLCC) $(GLO_)gspcolor.$(OBJ) $(C_) $(GLSRC)gspcolor.c
-$(GLOBJ)gsptype1.$(OBJ) : $(GLSRC)gsptype1.c $(math__h) $(GXERR)\
+$(GLOBJ)gsptype1.$(OBJ) : $(GLSRC)gsptype1.c $(math__h) $(memory__h) $(GXERR)\
$(gsrop_h) $(gsstruct_h) $(gsutil_h)\
$(gxarith_h) $(gxfixed_h) $(gxmatrix_h) $(gxcoord_h) $(gxcspace_h)\
$(gxcolor2_h) $(gxdcolor_h) $(gxdevice_h) $(gxdevmem_h) $(gxclip2_h)\
- $(gspath_h) $(gxpath_h) $(gxpcolor_h) $(gxp1impl_h) $(gzstate_h)\
+ $(gspath_h) $(gxpath_h) $(gxpcolor_h) $(gxp1impl_h) $(gxclist_h) $(gzstate_h)\
$(gsimage_h) $(gsiparm4_h) $(gsovrc_h)
$(GLCC) $(GLO_)gsptype1.$(OBJ) $(C_) $(GLSRC)gsptype1.c
More information about the gs-cvs
mailing list