[gs-cvs] rev 8862 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Mon Jul 21 23:24:14 PDT 2008
Author: leonardo
Date: 2008-07-21 23:24:14 -0700 (Mon, 21 Jul 2008)
New Revision: 8862
Modified:
trunk/gs/src/gdevprn.c
trunk/gs/src/gxclbits.c
trunk/gs/src/gxclist.h
trunk/gs/src/gxclrast.c
Log:
Fix (transparency) : A mask buffer could left unreleased due to banding.
DETAILS :
Bug 689944 "Reference to free object".
See comment in code.
EXPECTED DIFFERENCES :
None.
Modified: trunk/gs/src/gdevprn.c
===================================================================
--- trunk/gs/src/gdevprn.c 2008-07-22 00:32:19 UTC (rev 8861)
+++ trunk/gs/src/gdevprn.c 2008-07-22 06:24:14 UTC (rev 8862)
@@ -57,6 +57,8 @@
int old_width, int old_height,
bool old_page_uses_transparency);
+extern dev_proc_open_device(pattern_clist_open_device);
+
/* ------ Open/close ------ */
/* Open a generic printer device. */
Modified: trunk/gs/src/gxclbits.c
===================================================================
--- trunk/gs/src/gxclbits.c 2008-07-22 00:32:19 UTC (rev 8861)
+++ trunk/gs/src/gxclbits.c 2008-07-22 06:24:14 UTC (rev 8862)
@@ -237,9 +237,10 @@
/* Add a command to set the tile size and depth. */
static uint
-cmd_size_tile_params(const gx_strip_bitmap * tile)
+cmd_size_tile_params(const gx_strip_bitmap * tile, bool for_pattern)
{
- return 2 + cmd_size_w(tile->rep_width) + cmd_size_w(tile->rep_height) +
+ return 2 + (for_pattern ? cmd_size_w(tile->id) : 0) +
+ cmd_size_w(tile->rep_width) + cmd_size_w(tile->rep_height) +
(tile->rep_width == tile->size.x ? 0 :
cmd_size_w(tile->size.x / tile->rep_width)) +
(tile->rep_height == tile->size.y ? 0 :
@@ -248,12 +249,14 @@
}
static void
cmd_store_tile_params(byte * dp, const gx_strip_bitmap * tile, int depth,
- uint csize)
+ uint csize, bool for_pattern)
{
byte *p = dp + 2;
byte bd = cmd_depth_to_code(depth);
*dp = cmd_count_op(cmd_opv_set_tile_size, csize);
+ if (for_pattern)
+ p = cmd_put_w(tile->id, p);
p = cmd_put_w(tile->rep_width, p);
p = cmd_put_w(tile->rep_height, p);
if (tile->rep_width != tile->size.x) {
@@ -550,6 +553,8 @@
#undef max_tile_bytes
}
+extern dev_proc_open_device(pattern_clist_open_device);
+
/* Change tile for clist_tile_rectangle. */
int
clist_change_tile(gx_device_clist_writer * cldev, gx_clist_state * pcls,
@@ -569,6 +574,7 @@
int band_index = pcls - cldev->states;
byte *bptr = ts_mask(loc.tile) + (band_index >> 3);
byte bmask = 1 << (band_index & 7);
+ bool for_pattern = IS_CLIST_FOR_PATTERN(cldev);
if (*bptr & bmask) { /* Already known. Just set the index. */
if (pcls->tile_index == loc.index)
@@ -578,8 +584,8 @@
} else {
uint extra = 0;
- if tile_params_differ
- (cldev, tiles, depth) { /*
+ if (tile_params_differ(cldev, tiles, depth) ||
+ for_pattern) { /*
* We have a cached tile whose parameters differ from
* the current ones. Because of the way tile IDs are
* managed, this is currently only possible when mixing
@@ -603,7 +609,7 @@
cldev->tile_known_max = -1;
}
if (!(pcls->known & tile_params_known)) { /* We're going to have to write the tile parameters. */
- extra = cmd_size_tile_params(&cldev->tile_params);
+ extra = cmd_size_tile_params(&cldev->tile_params, for_pattern);
} { /*
* This band doesn't know this tile yet, so output the
* bits. Note that the offset we write is the one used by
@@ -632,7 +638,7 @@
return code;
if (extra) { /* Write the tile parameters before writing the bits. */
cmd_store_tile_params(dp, &cldev->tile_params, depth,
- extra);
+ extra, for_pattern);
dp += extra;
/* This band now knows the parameters. */
pcls->known |= tile_params_known;
Modified: trunk/gs/src/gxclist.h
===================================================================
--- trunk/gs/src/gxclist.h 2008-07-22 00:32:19 UTC (rev 8861)
+++ trunk/gs/src/gxclist.h 2008-07-22 06:24:14 UTC (rev 8862)
@@ -184,6 +184,12 @@
gx_band_page_info_t page_info; /* page information */\
int nbands /* # of bands */
+/*
+ * Chech whether a clist is used for storing a pattern command stream.
+ * Useful for both reader and writer.
+ */
+#define IS_CLIST_FOR_PATTERN(cdev) (cdev->procs.open_device == pattern_clist_open_device)
+
typedef struct gx_device_clist_common_s {
gx_device_clist_common_members;
} gx_device_clist_common;
Modified: trunk/gs/src/gxclrast.c
===================================================================
--- trunk/gs/src/gxclrast.c 2008-07-22 00:32:19 UTC (rev 8861)
+++ trunk/gs/src/gxclrast.c 2008-07-22 06:24:14 UTC (rev 8862)
@@ -226,7 +226,7 @@
* Render one band to a specified target device. Note that if
* action == setup, target may be 0.
*/
-static int read_set_tile_size(command_buf_t *pcb, tile_slot *bits);
+static int read_set_tile_size(command_buf_t *pcb, tile_slot *bits, bool for_pattern);
static int read_set_bits(command_buf_t *pcb, tile_slot *bits,
int compress, gx_clist_state *pcls,
gx_strip_bitmap *tile, tile_slot **pslot,
@@ -640,7 +640,8 @@
continue;
case cmd_opv_set_tile_size:
cbuf.ptr = cbp;
- code = read_set_tile_size(&cbuf, &tile_bits);
+ code = read_set_tile_size(&cbuf, &tile_bits,
+ IS_CLIST_FOR_PATTERN(cdev));
cbp = cbuf.ptr;
if (code < 0)
goto out;
@@ -2088,13 +2089,15 @@
*/
static int
-read_set_tile_size(command_buf_t *pcb, tile_slot *bits)
+read_set_tile_size(command_buf_t *pcb, tile_slot *bits, bool for_pattern)
{
const byte *cbp = pcb->ptr;
uint rep_width, rep_height;
byte bd = *cbp++;
bits->cb_depth = cmd_code_to_depth(bd);
+ if (for_pattern)
+ cmd_getw(bits->id, cbp);
cmd_getw(rep_width, cbp);
cmd_getw(rep_height, cbp);
if (bd & 0x20) {
More information about the gs-cvs
mailing list