diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2016-04-19 11:18:40 +0100 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2016-04-19 11:18:40 +0100 |
commit | 69c20a21a5bd53284437029b5b9d316a408a7392 (patch) | |
tree | ecca97f5387ddeea15882d1405131ef94e074c74 /base | |
parent | e6ecf9ccab71740fddc70f2e6cb30bef3b831d61 (diff) | |
download | ghostpdl-69c20a21a5bd53284437029b5b9d316a408a7392.tar.gz |
Add a system to allow processing of individual pages and ranges of pages
Bug #692752 "Implement mechanism to specify a range (or ranges) of pages for txtwrite"
Documented in Use.htm, this introduces a new command line parameter
'PageList' which allows for ranges and individual pages to be specified
for processing.
Diffstat (limited to 'base')
-rw-r--r-- | base/gdevdflt.c | 9 | ||||
-rw-r--r-- | base/gdevflp.c | 685 | ||||
-rw-r--r-- | base/gdevflp.h | 7 | ||||
-rw-r--r-- | base/gdevkrnlsclass.c | 2 | ||||
-rw-r--r-- | base/gsdevice.c | 4 | ||||
-rw-r--r-- | base/gsdparam.c | 52 | ||||
-rw-r--r-- | base/gxdevcli.h | 7 | ||||
-rw-r--r-- | base/gxdevice.h | 5 |
8 files changed, 530 insertions, 241 deletions
diff --git a/base/gdevdflt.c b/base/gdevdflt.c index a096a19ef..8596775b4 100644 --- a/base/gdevdflt.c +++ b/base/gdevdflt.c @@ -1283,7 +1283,10 @@ int gx_device_subclass(gx_device *dev_to_subclass, gx_device *new_prototype, uns dev_to_subclass->procs.copy_planes = new_prototype->procs.copy_planes; dev_to_subclass->finalize = new_prototype->finalize; dev_to_subclass->dname = new_prototype->dname; - dev_to_subclass->icc_struct = NULL; + if (dev_to_subclass->icc_struct) + rc_increment(dev_to_subclass->icc_struct); + if (dev_to_subclass->PageList) + rc_increment(dev_to_subclass->PageList); /* In case the new device we're creating has already been initialised, copy * its additional data. @@ -1364,6 +1367,10 @@ int gx_device_unsubclass(gx_device *dev) * their child pointer can then be NULL. */ if (child) { + if (child->icc_struct) + rc_decrement(child->icc_struct, "gx_unsubclass_device, icc_struct"); + if (child->PageList) + rc_decrement(child->PageList, "gx_unsubclass_device, PageList"); /* we cannot afford to free the child device if its stype is not dynamic because * we can't 'null' the finalise routine, and we cannot permit the device to be finalised * because we have copied it up one level, not discarded it. diff --git a/base/gdevflp.c b/base/gdevflp.c index 1fac26e40..c1e46bf48 100644 --- a/base/gdevflp.c +++ b/base/gdevflp.c @@ -48,6 +48,7 @@ #include "gdevp14.h" /* Needed to patch up the procs after compositor creation */ #include "gdevsclass.h" #include "gdevflp.h" +#include <stdlib.h> /* GC descriptor */ public_st_device_flp(); @@ -56,13 +57,13 @@ private_st_flp_text_enum(); /* Device procedures, we need quite a lot of them */ static dev_proc_output_page(flp_output_page); +static dev_proc_close_device(flp_close_device); static dev_proc_fill_rectangle(flp_fill_rectangle); static dev_proc_tile_rectangle(flp_tile_rectangle); static dev_proc_copy_mono(flp_copy_mono); static dev_proc_copy_color(flp_copy_color); static dev_proc_draw_line(flp_draw_line); static dev_proc_get_bits(flp_get_bits); -//static dev_proc_get_params(flp_get_params); static dev_proc_get_params(flp_put_params); static dev_proc_get_alpha_bits(flp_get_alpha_bits); static dev_proc_copy_alpha(flp_copy_alpha); @@ -138,7 +139,7 @@ gx_device_flp gs_flp_device = default_subclass_get_initial_matrix, default_subclass_sync_output, /* sync_output */ flp_output_page, - default_subclass_close_device, + flp_close_device, default_subclass_map_rgb_color, default_subclass_map_color_rgb, flp_fill_rectangle, @@ -213,30 +214,204 @@ gx_device_flp gs_flp_device = #undef MAX_COORD #undef MAX_RESOLUTION -int flp_output_page(gx_device *dev, int num_copies, int flush) +static int ParsePageList(gx_device *dev, first_last_subclass_data *psubclass_data, char *PageList) +{ + char *str, *oldstr, *workstr, c, *ArgCopy; + int LastPage, Page, byte, bit, i; + + psubclass_data->ProcessedPageList = true; + if (strcmp(PageList, "even") == 0) { + psubclass_data->EvenOdd = even; + } else { + if (strcmp(PageList, "odd") == 0) { + psubclass_data->EvenOdd = odd; + } else { + psubclass_data->EvenOdd = none; + + /* validation of parameter */ + str = PageList; + do { + /* Must be digit, ',' or - */ + if (*str != ',' && *str != '-' && (*str < 0x30 || *str > 0x39)) { + return (gs_note_error(gs_error_typecheck)); + } + /* Check we don't have 2 special characters (, or -) in a row */ + if ((*str == ',' || *str == '-') && (*(str+1) == ',' || *(str+1) == '-')) + return (gs_note_error(gs_error_typecheck)); + } while(*(++str)); + + str = PageList; + oldstr = str; + do { + str = strchr(oldstr, ','); + /* Check for trailing ',' in parameter, zap it if we find one. */ + if (str) { + if (*(str + 1)) + oldstr = ++str; + else { + *str = 0x00; + break; + } + } + }while (str); + + /* In case last set is a page range */ + str = strchr(oldstr, '-'); + if (!str) + str = oldstr; + else { + /* We permit a trailing '-' to indicate all pages from this one to the end */ + if (*(str + 1)) + str++; + else { + *str = 0x00; + str = oldstr; + psubclass_data->FromToEnd = atoi(str); + } + } + /* str should now point to the last page number (we hope!) */ + LastPage = atoi(str); + + psubclass_data->PageArraySize = (LastPage + 7) / 8; + psubclass_data->PageArray = gs_alloc_bytes(dev->memory->non_gc_memory, psubclass_data->PageArraySize, "array of pages selected"); + if (!psubclass_data->PageArray) { + psubclass_data->PageArraySize = 0; + return (gs_note_error(gs_error_VMerror)); + } + memset(psubclass_data->PageArray, 0x00, psubclass_data->PageArraySize); + + oldstr = ArgCopy = (char *)gs_alloc_bytes(dev->memory->non_gc_memory, strlen(PageList) + 1, "temp working string"); + if (!ArgCopy) { + gs_free_object(dev->memory->non_gc_memory, psubclass_data->PageArray, "free array of pages selected"); + psubclass_data->PageArray = 0; + psubclass_data->PageArraySize = 0; + return (gs_note_error(gs_error_VMerror)); + } + memcpy(ArgCopy, PageList, strlen(PageList) + 1); + do { + str = strchr(oldstr, ','); + if (str) + *str++ = 0x00; + /* oldstr now points to a null terminated string and is either a number or a number pair */ + workstr = strchr(oldstr, '-'); + if (workstr) { + *workstr++ = 0x00; + /* oldstr points to null terminated string of start, workstr to null terminated string of end */ + Page = atoi(oldstr) - 1; + LastPage = atoi(workstr) - 1; + for (i=Page; i<= LastPage;i++) { + byte = (int)(i / 8); + bit = i % 8; + c = 0x01 << bit; + ((char *)psubclass_data->PageArray)[byte] |= c; + } + } else { + Page = atoi(oldstr) - 1; + byte = (int)(Page / 8); + bit = Page % 8; + c = 0x01 << bit; + ((char *)psubclass_data->PageArray)[byte] |= c; + } + oldstr = str; + } while (str); + gs_free_object(dev->memory->non_gc_memory, ArgCopy, "free temp working string"); + } + } + return 0; +} + +static int SkipPage(gx_device *dev) { first_last_subclass_data *psubclass_data = dev->subclass_data; + int code; - psubclass_data->PageCount++; + /* If we're disabled, don't skip any pages, and don't bother parsing the PageList */ + if (dev->DisablePageHandler) + return 0; + + /* If we haven't parsed any extant PageList, do it now */ + if (dev->PageList && !psubclass_data->ProcessedPageList) { + code = ParsePageList(dev, psubclass_data, dev->PageList->Pages); + if (code < 0) + return code; + psubclass_data->ProcessedPageList = true; + } - if (psubclass_data->PageCount >= dev->FirstPage || dev->DisablePageHandler) { - if (!dev->LastPage || psubclass_data->PageCount <= dev->LastPage || dev->DisablePageHandler) { - return default_subclass_output_page(dev, num_copies, flush); + if (psubclass_data->PageArray) { + if (psubclass_data->FromToEnd != 0 && psubclass_data->PageCount >= psubclass_data->FromToEnd) + return 0; + else { + int byte, bit; + char c; + + byte = (int)((psubclass_data->PageCount) / 8); + bit = (psubclass_data->PageCount) % 8; + c = 0x01 << bit; + if (((char *)psubclass_data->PageArray)[byte] & c) + return 0; + else + return 1; + } + } else { + if (psubclass_data->EvenOdd != none) { + /* Page count is 0 based so the even/odd tests are 'upside down' */ + if (psubclass_data->PageCount % 2 == 0) { + if (psubclass_data->EvenOdd == odd) + return 0; + else + return 1; + } else { + if (psubclass_data->EvenOdd == even) + return 0; + else + return 1; + } + } else { + if (psubclass_data->PageCount >= dev->FirstPage) + if (!dev->LastPage || psubclass_data->PageCount <= dev->LastPage) + return 0; } } + return 1; +} - return 0; +int flp_output_page(gx_device *dev, int num_copies, int flush) +{ + int code = 0; + + first_last_subclass_data *psubclass_data = dev->subclass_data; + + if (!SkipPage(dev)) + code = default_subclass_output_page(dev, num_copies, flush); + + psubclass_data->PageCount++; + + return code; } -int flp_fill_rectangle(gx_device *dev, int x, int y, int width, int height, gx_color_index color) +int flp_close_device(gx_device *dev) { first_last_subclass_data *psubclass_data = dev->subclass_data; - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_fill_rectangle(dev, x, y, width, height, color); + if (psubclass_data->PageArraySize) + { + gs_free(dev->memory->non_gc_memory, psubclass_data->PageArray, 1, , "array of pages selected"); + psubclass_data->PageArray = 0; + psubclass_data->PageArraySize = 0; } + return default_subclass_close_device(dev); +} + +int flp_fill_rectangle(gx_device *dev, int x, int y, int width, int height, gx_color_index color) +{ + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_fill_rectangle(dev, x, y, width, height, color); + return 0; } @@ -244,12 +419,12 @@ int flp_tile_rectangle(gx_device *dev, const gx_tile_bitmap *tile, int x, int y, gx_color_index color0, gx_color_index color1, int phase_x, int phase_y) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_tile_rectangle(dev, tile, x, y, width, height, color0, color1, phase_x, phase_y); - } + if (code < 0) + return code; + if (!code) + return default_subclass_tile_rectangle(dev, tile, x, y, width, height, color0, color1, phase_x, phase_y); return 0; } @@ -258,12 +433,12 @@ int flp_copy_mono(gx_device *dev, const byte *data, int data_x, int raster, gx_b int x, int y, int width, int height, gx_color_index color0, gx_color_index color1) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_copy_mono(dev, data, data_x, raster, id, x, y, width, height, color0, color1); - } + if (code < 0) + return code; + if (!code) + return default_subclass_copy_mono(dev, data, data_x, raster, id, x, y, width, height, color0, color1); return 0; } @@ -271,35 +446,37 @@ int flp_copy_mono(gx_device *dev, const byte *data, int data_x, int raster, gx_b int flp_copy_color(gx_device *dev, const byte *data, int data_x, int raster, gx_bitmap_id id,\ int x, int y, int width, int height) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_copy_color(dev, data, data_x, raster, id, x, y, width, height); - } + if (code < 0) + return code; + if (!code) + return default_subclass_copy_color(dev, data, data_x, raster, id, x, y, width, height); return 0; } int flp_draw_line(gx_device *dev, int x0, int y0, int x1, int y1, gx_color_index color) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_draw_line(dev, x0, y0, x1, y1, color); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_draw_line(dev, x0, y0, x1, y1, color); - } return 0; } int flp_get_bits(gx_device *dev, int y, byte *data, byte **actual_data) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_get_bits(dev, y, data, actual_data); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_get_bits(dev, y, data, actual_data); - } return gx_default_get_bits(dev, y, data, actual_data); } @@ -325,12 +502,13 @@ flp_put_params(gx_device * dev, gs_param_list * plist) int flp_get_alpha_bits(gx_device *dev, graphics_object_type type) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_get_alpha_bits(dev, type); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_get_alpha_bits(dev, type); - } return 0; } @@ -338,23 +516,25 @@ int flp_copy_alpha(gx_device *dev, const byte *data, int data_x, int raster, gx_bitmap_id id, int x, int y, int width, int height, gx_color_index color, int depth) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_copy_alpha(dev, data, data_x, raster, id, x, y, width, height, color, depth); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_copy_alpha(dev, data, data_x, raster, id, x, y, width, height, color, depth); - } return 0; } int flp_get_band(gx_device *dev, int y, int *band_start) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_get_band(dev, y, band_start); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_get_band(dev, y, band_start); - } return gx_default_get_band(dev, y, band_start); } @@ -364,12 +544,13 @@ int flp_copy_rop(gx_device *dev, const byte *sdata, int sourcex, uint sraster, g int x, int y, int width, int height, int phase_x, int phase_y, gs_logical_operation_t lop) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_copy_rop(dev, sdata, sourcex, sraster, id, scolors, texture, tcolors, x, y, width, height, phase_x, phase_y, lop); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_copy_rop(dev, sdata, sourcex, sraster, id, scolors, texture, tcolors, x, y, width, height, phase_x, phase_y, lop); - } return 0; } @@ -377,12 +558,13 @@ int flp_fill_path(gx_device *dev, const gs_imager_state *pis, gx_path *ppath, const gx_fill_params *params, const gx_drawing_color *pdcolor, const gx_clip_path *pcpath) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_fill_path(dev, pis, ppath, params, pdcolor, pcpath); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_fill_path(dev, pis, ppath, params, pdcolor, pcpath); - } return 0; } @@ -390,12 +572,13 @@ int flp_stroke_path(gx_device *dev, const gs_imager_state *pis, gx_path *ppath, const gx_stroke_params *params, const gx_drawing_color *pdcolor, const gx_clip_path *pcpath) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_stroke_path(dev, pis, ppath, params, pdcolor, pcpath); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_stroke_path(dev, pis, ppath, params, pdcolor, pcpath); - } return 0; } @@ -404,12 +587,13 @@ int flp_fill_mask(gx_device *dev, const byte *data, int data_x, int raster, gx_b const gx_drawing_color *pdcolor, int depth, gs_logical_operation_t lop, const gx_clip_path *pcpath) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_fill_mask(dev, data, data_x, raster, id, x, y, width, height, pdcolor, depth, lop, pcpath); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_fill_mask(dev, data, data_x, raster, id, x, y, width, height, pdcolor, depth, lop, pcpath); - } return 0; } @@ -417,36 +601,39 @@ int flp_fill_trapezoid(gx_device *dev, const gs_fixed_edge *left, const gs_fixed fixed ybot, fixed ytop, bool swap_axes, const gx_drawing_color *pdcolor, gs_logical_operation_t lop) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_fill_trapezoid(dev, left, right, ybot, ytop, swap_axes, pdcolor, lop); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_fill_trapezoid(dev, left, right, ybot, ytop, swap_axes, pdcolor, lop); - } return 0; } int flp_fill_parallelogram(gx_device *dev, fixed px, fixed py, fixed ax, fixed ay, fixed bx, fixed by, const gx_drawing_color *pdcolor, gs_logical_operation_t lop) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_fill_parallelogram(dev, px, py, ax, ay, bx, by, pdcolor, lop); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_fill_parallelogram(dev, px, py, ax, ay, bx, by, pdcolor, lop); - } return 0; } int flp_fill_triangle(gx_device *dev, fixed px, fixed py, fixed ax, fixed ay, fixed bx, fixed by, const gx_drawing_color *pdcolor, gs_logical_operation_t lop) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_fill_triangle(dev, px, py, ax, ay, bx, by, pdcolor, lop); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_fill_triangle(dev, px, py, ax, ay, bx, by, pdcolor, lop); - } return 0; } @@ -454,12 +641,13 @@ int flp_draw_thin_line(gx_device *dev, fixed fx0, fixed fy0, fixed fx1, fixed fy const gx_drawing_color *pdcolor, gs_logical_operation_t lop, fixed adjustx, fixed adjusty) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_draw_thin_line(dev, fx0, fy0, fx1, fy1, pdcolor, lop, adjustx, adjusty); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_draw_thin_line(dev, fx0, fy0, fx1, fy1, pdcolor, lop, adjustx, adjusty); - } return 0; } @@ -468,35 +656,38 @@ int flp_begin_image(gx_device *dev, const gs_imager_state *pis, const gs_image_t const gx_drawing_color *pdcolor, const gx_clip_path *pcpath, gs_memory_t *memory, gx_image_enum_common_t **pinfo) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_begin_image(dev, pis, pim, format, prect, pdcolor, pcpath, memory, pinfo); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_begin_image(dev, pis, pim, format, prect, pdcolor, pcpath, memory, pinfo); - } return 0; } int flp_image_data(gx_device *dev, gx_image_enum_common_t *info, const byte **planes, int data_x, uint raster, int height) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_image_data(dev, info, planes, data_x, raster, height); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_image_data(dev, info, planes, data_x, raster, height); - } return 0; } int flp_end_image(gx_device *dev, gx_image_enum_common_t *info, bool draw_last) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_end_image(dev, info, draw_last); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_end_image(dev, info, draw_last); - } return 0; } @@ -504,12 +695,13 @@ int flp_strip_tile_rectangle(gx_device *dev, const gx_strip_bitmap *tiles, int x gx_color_index color0, gx_color_index color1, int phase_x, int phase_y) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_strip_tile_rectangle(dev, tiles, x, y, width, height, color0, color1, phase_x, phase_y); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_strip_tile_rectangle(dev, tiles, x, y, width, height, color0, color1, phase_x, phase_y); - } return 0; } @@ -519,12 +711,13 @@ int flp_strip_copy_rop(gx_device *dev, const byte *sdata, int sourcex, uint sras int x, int y, int width, int height, int phase_x, int phase_y, gs_logical_operation_t lop) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_strip_copy_rop(dev, sdata, sourcex, sraster, id, scolors, textures, tcolors, x, y, width, height, phase_x, phase_y, lop); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_strip_copy_rop(dev, sdata, sourcex, sraster, id, scolors, textures, tcolors, x, y, width, height, phase_x, phase_y, lop); - } return 0; } @@ -569,16 +762,15 @@ int flp_begin_typed_image(gx_device *dev, const gs_imager_state *pis, const gs_m const gx_drawing_color *pdcolor, const gx_clip_path *pcpath, gs_memory_t *memory, gx_image_enum_common_t **pinfo) { - first_last_subclass_data *psubclass_data = dev->subclass_data; flp_image_enum *pie; const gs_pixel_image_t *pim = (const gs_pixel_image_t *)pic; int num_components; + int code = SkipPage(dev); - - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_begin_typed_image(dev, pis, pmat, pic, prect, pdcolor, pcpath, memory, pinfo); - } + if (code < 0) + return code; + if (!code) + return default_subclass_begin_typed_image(dev, pis, pmat, pic, prect, pdcolor, pcpath, memory, pinfo); if (pic->type->index == 1) { const gs_image_t *pim1 = (const gs_image_t *)pic; @@ -608,24 +800,25 @@ int flp_begin_typed_image(gx_device *dev, const gs_imager_state *pis, const gs_m int flp_get_bits_rectangle(gx_device *dev, const gs_int_rect *prect, gs_get_bits_params_t *params, gs_int_rect **unread) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_get_bits_rectangle(dev, prect, params, unread); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_get_bits_rectangle(dev, prect, params, unread); - } return gx_default_get_bits_rectangle(dev->child, prect, params, unread); } int flp_create_compositor(gx_device *dev, gx_device **pcdev, const gs_composite_t *pcte, gs_imager_state *pis, gs_memory_t *memory, gx_device *cdev) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_create_compositor(dev, pcdev, pcte, pis, memory, cdev); - } + if (code < 0) + return code; + if (!code) + return default_subclass_create_compositor(dev, pcdev, pcte, pis, memory, cdev); return 0; } @@ -699,7 +892,7 @@ int flp_text_begin(gx_device *dev, gs_imager_state *pis, const gs_text_params_t { flp_text_enum_t *penum; int code; - first_last_subclass_data *psubclass_data = dev->subclass_data; + code = SkipPage(dev); /* We don't want to simply ignore stringwidth for 2 reasons; * firstly because following elelments may be positioned based on the value returned @@ -713,7 +906,10 @@ int flp_text_begin(gx_device *dev, gs_imager_state *pis, const gs_text_params_t */ return default_subclass_text_begin(dev, pis, text, font, path, pdcolor, pcpath, memory, ppte); - if (psubclass_data->PageCount >= dev->FirstPage - 1 && (!dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1)) + code = SkipPage(dev); + if (code < 0) + return code; + if (!code) return default_subclass_text_begin(dev, pis, text, font, path, pdcolor, pcpath, memory, ppte); rc_alloc_struct_1(penum, flp_text_enum_t, &st_flp_text_enum, memory, @@ -733,81 +929,88 @@ int flp_text_begin(gx_device *dev, gs_imager_state *pis, const gs_text_params_t int flp_begin_transparency_group(gx_device *dev, const gs_transparency_group_params_t *ptgp, const gs_rect *pbbox, gs_imager_state *pis, gs_memory_t *mem) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_begin_transparency_group(dev, ptgp, pbbox, pis, mem); - if (psubclass_data->PageCount >= dev->FirstPage - 1) { - if (!dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_begin_transparency_group(dev, ptgp, pbbox, pis, mem); - } return 0; } int flp_end_transparency_group(gx_device *dev, gs_imager_state *pis) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_end_transparency_group(dev, pis); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_end_transparency_group(dev, pis); - } return 0; } int flp_begin_transparency_mask(gx_device *dev, const gx_transparency_mask_params_t *ptmp, const gs_rect *pbbox, gs_imager_state *pis, gs_memory_t *mem) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_begin_transparency_mask(dev, ptmp, pbbox, pis, mem); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_begin_transparency_mask(dev, ptmp, pbbox, pis, mem); - } return 0; } int flp_end_transparency_mask(gx_device *dev, gs_imager_state *pis) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_end_transparency_mask(dev, pis); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_end_transparency_mask(dev, pis); - } return 0; } int flp_discard_transparency_layer(gx_device *dev, gs_imager_state *pis) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_discard_transparency_layer(dev, pis); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_discard_transparency_layer(dev, pis); - } return 0; } int flp_pattern_manage(gx_device *dev, gx_bitmap_id id, gs_pattern1_instance_t *pinst, pattern_manage_t function) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_pattern_manage(dev, id, pinst, function); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_pattern_manage(dev, id, pinst, function); - } return 0; } int flp_fill_rectangle_hl_color(gx_device *dev, const gs_fixed_rect *rect, const gs_imager_state *pis, const gx_drawing_color *pdcolor, const gx_clip_path *pcpath) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_fill_rectangle_hl_color(dev, rect, pis, pdcolor, pcpath); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_fill_rectangle_hl_color(dev, rect, pis, pdcolor, pcpath); - } return 0; } @@ -815,12 +1018,13 @@ int flp_fill_linear_color_scanline(gx_device *dev, const gs_fill_attributes *fa, int i, int j, int w, const frac31 *c0, const int32_t *c0_f, const int32_t *cg_num, int32_t cg_den) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_fill_linear_color_scanline(dev, fa, i, j, w, c0, c0_f, cg_num, cg_den); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_fill_linear_color_scanline(dev, fa, i, j, w, c0, c0_f, cg_num, cg_den); - } return 0; } @@ -830,12 +1034,13 @@ int flp_fill_linear_color_trapezoid(gx_device *dev, const gs_fill_attributes *fa const frac31 *c0, const frac31 *c1, const frac31 *c2, const frac31 *c3) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_fill_linear_color_trapezoid(dev, fa, p0, p1, p2, p3, c0, c1, c2, c3); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_fill_linear_color_trapezoid(dev, fa, p0, p1, p2, p3, c0, c1, c2, c3); - } return 0; } @@ -843,45 +1048,49 @@ int flp_fill_linear_color_triangle(gx_device *dev, const gs_fill_attributes *fa, const gs_fixed_point *p0, const gs_fixed_point *p1, const gs_fixed_point *p2, const frac31 *c0, const frac31 *c1, const frac31 *c2) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_fill_linear_color_triangle(dev, fa, p0, p1, p2, c0, c1, c2); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_fill_linear_color_triangle(dev, fa, p0, p1, p2, c0, c1, c2); - } return 0; } int flp_fillpage(gx_device *dev, gs_imager_state * pis, gx_device_color *pdevc) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_fillpage(dev, pis, pdevc); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_fillpage(dev, pis, pdevc); - } return 0; } int flp_push_transparency_state(gx_device *dev, gs_imager_state *pis) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_push_transparency_state(dev, pis); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_push_transparency_state(dev, pis); - } return 0; } int flp_pop_transparency_state(gx_device *dev, gs_imager_state *pis) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_pop_transparency_state(dev, pis); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_pop_transparency_state(dev, pis); - } return 0; } @@ -889,35 +1098,38 @@ int flp_put_image(gx_device *dev, const byte *buffer, int num_chan, int x, int y int width, int height, int row_stride, int plane_stride, int alpha_plane_index, int tag_plane_index) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_put_image(dev, buffer, num_chan, x, y, width, height, row_stride, plane_stride, alpha_plane_index, tag_plane_index); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_put_image(dev, buffer, num_chan, x, y, width, height, row_stride, plane_stride, alpha_plane_index, tag_plane_index); - } return 0; } int flp_copy_planes(gx_device *dev, const byte *data, int data_x, int raster, gx_bitmap_id id, int x, int y, int width, int height, int plane_height) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_copy_planes(dev, data, data_x, raster, id, x, y, width, height, plane_height); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_copy_planes(dev, data, data_x, raster, id, x, y, width, height, plane_height); - } return 0; } void flp_set_graphics_type_tag(gx_device *dev, gs_graphics_type_tag_t tag) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return; + if (!code) + default_subclass_set_graphics_type_tag(dev, tag); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - default_subclass_set_graphics_type_tag(dev, tag); - } return; } @@ -925,24 +1137,26 @@ int flp_strip_copy_rop2(gx_device *dev, const byte *sdata, int sourcex, uint sra const gx_color_index *scolors, const gx_strip_bitmap *textures, const gx_color_index *tcolors, int x, int y, int width, int height, int phase_x, int phase_y, gs_logical_operation_t lop, uint planar_height) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_strip_copy_rop2(dev, sdata, sourcex, sraster, id, scolors, textures, tcolors, x, y, width, height, phase_x, phase_y, lop, planar_height); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_strip_copy_rop2(dev, sdata, sourcex, sraster, id, scolors, textures, tcolors, x, y, width, height, phase_x, phase_y, lop, planar_height); - } return 0; } int flp_strip_tile_rect_devn(gx_device *dev, const gx_strip_bitmap *tiles, int x, int y, int width, int height, const gx_drawing_color *pdcolor0, const gx_drawing_color *pdcolor1, int phase_x, int phase_y) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_strip_tile_rect_devn(dev, tiles, x, y, width, height, pdcolor0, pdcolor1, phase_x, phase_y); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_strip_tile_rect_devn(dev, tiles, x, y, width, height, pdcolor0, pdcolor1, phase_x, phase_y); - } return 0; } @@ -950,23 +1164,24 @@ int flp_copy_alpha_hl_color(gx_device *dev, const byte *data, int data_x, int raster, gx_bitmap_id id, int x, int y, int width, int height, const gx_drawing_color *pdcolor, int depth) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_copy_alpha_hl_color(dev, data, data_x, raster, id, x, y, width, height, pdcolor, depth); - } + if (code < 0) + return code; + if (!code) + return default_subclass_copy_alpha_hl_color(dev, data, data_x, raster, id, x, y, width, height, pdcolor, depth); return 0; } int flp_process_page(gx_device *dev, gx_process_page_options_t *options) { - first_last_subclass_data *psubclass_data = dev->subclass_data; + int code = SkipPage(dev); + + if (code < 0) + return code; + if (!code) + return default_subclass_process_page(dev, options); - if (dev->DisablePageHandler || psubclass_data->PageCount >= dev->FirstPage - 1) { - if (dev->DisablePageHandler || !dev->LastPage || psubclass_data->PageCount <= dev->LastPage - 1) - return default_subclass_process_page(dev, options); - } return 0; } diff --git a/base/gdevflp.h b/base/gdevflp.h index 00fab06bd..e2b84bead 100644 --- a/base/gdevflp.h +++ b/base/gdevflp.h @@ -28,9 +28,16 @@ typedef struct gx_device_s gx_device_flp; /* Initialize a first/last page device. */ void gx_device_flp_init(gx_device_flp * dev); +typedef enum {none, even, odd} flp_EOType; + typedef struct { subclass_common; int PageCount; + int ProcessedPageList; + void *PageArray; + int PageArraySize; + int FromToEnd; + flp_EOType EvenOdd; } first_last_subclass_data; typedef struct flp_text_enum_s { diff --git a/base/gdevkrnlsclass.c b/base/gdevkrnlsclass.c index e3299b070..0982d2220 100644 --- a/base/gdevkrnlsclass.c +++ b/base/gdevkrnlsclass.c @@ -16,7 +16,7 @@ int install_internal_subclass_devices(gx_device **ppdev, int *devices_loaded) #if FORCE_TESTING_SUBCLASSING if (!dev->PageHandlerPushed) { #else - if (!dev->PageHandlerPushed && (dev->FirstPage != 0 || dev->LastPage != 0)) { + if (!dev->PageHandlerPushed && (dev->FirstPage != 0 || dev->LastPage != 0 || dev->PageList != 0)) { #endif code = gx_device_subclass(dev, (gx_device *)&gs_flp_device, sizeof(first_last_subclass_data)); if (code < 0) diff --git a/base/gsdevice.c b/base/gsdevice.c index 362d0f562..a8338e954 100644 --- a/base/gsdevice.c +++ b/base/gsdevice.c @@ -66,6 +66,10 @@ gx_device_finalize(const gs_memory_t *cmem, void *vptr) dev->child->parent = dev->parent; if (dev->parent) dev->parent->child = dev->child; + if (dev->PageList) { + rc_decrement(dev->PageList, "gx_device_finalize(PageList)"); + dev->PageList = 0; + } discard(gs_closedevice(dev)); if (dev->stype_is_dynamic) diff --git a/base/gsdparam.c b/base/gsdparam.c index 3e4ac2247..eb36bd9a7 100644 --- a/base/gsdparam.c +++ b/base/gsdparam.c @@ -438,6 +438,16 @@ int gx_default_get_param(gx_device *dev, char *Param, void *list) temp_bool = dev->DisablePageHandler; return param_write_bool(plist, "DisablePageHandler", &temp_bool); } + if (strcmp(Param, "PageList") == 0){ + gs_param_string pagelist; + if (dev->PageList) { + gdev_pagelist *p = (gdev_pagelist *)dev->PageList; + param_string_from_string(pagelist, p->Pages); + } + else + param_string_from_string(pagelist, null_str); + return param_write_string(plist, "PageList", &pagelist); + } if (strcmp(Param, "FILTERIMAGE") == 0) { temp_bool = dev->ObjectFilter & FILTERIMAGE; return param_write_bool(plist, "FILTERIMAGE", &temp_bool); @@ -464,7 +474,7 @@ gx_default_get_params(gx_device * dev, gs_param_list * plist) bool seprs = false; gs_param_string dns, pcms, profile_array[NUM_DEVICE_PROFILES]; - gs_param_string postren_profile; + gs_param_string postren_profile, pagelist; gs_param_string proof_profile, link_profile, icc_colorants; gsicc_rendering_intents_t profile_intents[NUM_DEVICE_PROFILES]; gsicc_blackptcomp_t blackptcomps[NUM_DEVICE_PROFILES]; @@ -693,6 +703,15 @@ gx_default_get_params(gx_device * dev, gs_param_list * plist) if ((code = param_write_bool(plist, "DisablePageHandler", &temp_bool)) < 0) return code; + if (dev->PageList) { + gdev_pagelist *p = (gdev_pagelist *)dev->PageList; + param_string_from_string(pagelist, p->Pages); + } + else + param_string_from_string(pagelist, null_str); + if ((code = param_write_name(plist, "PageList", &pagelist)) < 0) + return code; + temp_bool = dev->ObjectFilter & FILTERIMAGE; if ((code = param_write_bool(plist, "FILTERIMAGE", &temp_bool)) < 0) return code; @@ -1265,6 +1284,17 @@ gx_default_put_icc(gs_param_string *icc_pro, gx_device * dev, return code; } +static void +rc_free_pages_list(gs_memory_t * mem, void *ptr_in, client_name_t cname) +{ + gdev_pagelist *PageList = (gdev_pagelist *)ptr_in; + + if (PageList->rc.ref_count <= 1) { + gs_free(mem->non_gc_memory, PageList->Pages, 1, PagesSize, "free page list"); + gs_free(mem->non_gc_memory, PageList, 1, sizeof(gdev_pagelist), "free structure to hold page list"); + } +} + /* Set standard parameters. */ /* Note that setting the size or resolution closes the device. */ /* Window devices that don't want this to happen must temporarily */ @@ -1305,7 +1335,7 @@ gx_default_put_params(gx_device * dev, gs_param_list * plist) int rend_intent[NUM_DEVICE_PROFILES]; int blackptcomp[NUM_DEVICE_PROFILES]; int blackpreserve[NUM_DEVICE_PROFILES]; - gs_param_string cms; + gs_param_string cms, pagelist; int leadingedge = dev->LeadingEdge; int k; bool devicegraytok = true; @@ -1787,6 +1817,24 @@ label:\ if (code == 0) dev->DisablePageHandler = temp_bool; + if ((code = param_read_string(plist, "PageList", &pagelist)) != 1 && pagelist.size > 0) { + if (dev->PageList) + rc_decrement(dev->PageList, "default put_params PageList"); + dev->PageList = (gdev_pagelist *)gs_alloc_bytes(dev->memory->non_gc_memory, sizeof(gdev_pagelist), "structure to hold page list"); + if (!dev->PageList) + return gs_note_error(gs_error_VMerror); + dev->PageList->Pages = (void *)gs_alloc_bytes(dev->memory->non_gc_memory, pagelist.size + 1, "String to hold page list"); + if (!dev->PageList->Pages){ + gs_free(dev->memory->non_gc_memory, dev->PageList, 1, sizeof(gdev_pagelist), "free structure to hold page list"); + dev->PageList = 0; + return gs_note_error(gs_error_VMerror); + } + memset(dev->PageList->Pages, 0x00, pagelist.size + 1); + memcpy(dev->PageList->Pages, pagelist.data, pagelist.size); + dev->PageList->PagesSize = pagelist.size + 1; + rc_init_free(dev->PageList, dev->memory->non_gc_memory, 1, rc_free_pages_list); + } + code = param_read_bool(plist, "FILTERIMAGE", &temp_bool); if (code < 0) ecode = code; diff --git a/base/gxdevcli.h b/base/gxdevcli.h index 0b98d2335..a14f19ad3 100644 --- a/base/gxdevcli.h +++ b/base/gxdevcli.h @@ -716,6 +716,12 @@ typedef struct gdev_space_params_s { gdev_banding_type banding_type; /* used to force banding or bitmap */ } gdev_space_params; +typedef struct gdev_pagelist_s { + rc_header rc; + char *Pages; + int PagesSize; +} gdev_pagelist; + #define gx_device_common\ int params_size; /* OBSOLETE if stype != 0: */\ /* size of this structure */\ @@ -735,6 +741,7 @@ typedef struct gdev_space_params_s { gx_device *parent;\ gx_device *child;\ void *subclass_data; /* Must be immovable, non-GC memory, used to store subclass data */\ + gdev_pagelist *PageList;\ bool is_open; /* true if device has been opened */\ int max_fill_band; /* limit on band size for fill, */\ /* must be 0 or a power of 2 */\ diff --git a/base/gxdevice.h b/base/gxdevice.h index 1e7c01ec3..aa4266d6e 100644 --- a/base/gxdevice.h +++ b/base/gxdevice.h @@ -98,10 +98,11 @@ * Note also that the macro does not initialize procs, which is * the next element of the structure. */ -#define std_device_part1_(devtype, ptr_procs, dev_name, stype, open_init)\ + #define std_device_part1_(devtype, ptr_procs, dev_name, stype, open_init)\ sizeof(devtype), ptr_procs, dev_name,\ 0 /*memory*/, stype, 0 /*stype_is_dynamic*/, 0 /*finalize*/,\ - { 0 } /*rc*/, 0 /*retained*/, 0 /* parent */, 0 /* child */, 0 /* subclass_data */, open_init() /*is_open, max_fill_band*/ + { 0 } /*rc*/, 0 /*retained*/, 0 /* parent */, 0 /* child */, 0 /* subclass_data */, 0, /* PageList */\ + open_init() /*is_open, max_fill_band*/ /* color_info goes here */ /* * The MetroWerks compiler has some bizarre bug that produces a spurious |