diff options
Diffstat (limited to 'base/gdevprn.c')
-rw-r--r-- | base/gdevprn.c | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/base/gdevprn.c b/base/gdevprn.c index 0cfb453f..296e9734 100644 --- a/base/gdevprn.c +++ b/base/gdevprn.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2021 Artifex Software, Inc. +/* Copyright (C) 2001-2022 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or @@ -278,6 +278,7 @@ gdev_prn_allocate(gx_device *pdev, gdev_space_params *new_space_params, bool save_is_command_list = false; /* Quiet compiler */ bool size_ok = 0; int ecode = 0; + int code; int pass; gs_memory_t *buffer_memory = (ppdev->buffer_memory == 0 ? pdev->memory->non_gc_memory : @@ -455,6 +456,7 @@ gdev_prn_allocate(gx_device *pdev, gdev_space_params *new_space_params, gs_free_object(buffer_memory, base, "printer buffer"); pdev->procs = ppdev->orig_procs; ppdev->orig_procs.open_device = 0; /* prevent uninit'd restore of procs */ + gs_free_object(pdev->memory->non_gc_memory, ppdev->bg_print, "prn bg_print"); return_error(code); } } @@ -492,14 +494,19 @@ gdev_prn_allocate(gx_device *pdev, gdev_space_params *new_space_params, #undef COPY_PROC /* If using a command list, already opened the device. */ if (is_command_list) - return ecode; + code = ecode; else - return (*dev_proc(pdev, open_device))(pdev); + /* If this open_device fails, do we need to free everything? */ + code = (*dev_proc(pdev, open_device))(pdev); } else { pdev->procs = ppdev->orig_procs; ppdev->orig_procs.open_device = 0; /* prevent uninit'd restore of procs */ - return ecode; + code = ecode; } + if (code < 0) { + gs_free_object(pdev->memory->non_gc_memory, ppdev->bg_print, "prn bg_print"); + } + return code; } int @@ -580,8 +587,9 @@ gdev_prn_get_param(gx_device *dev, char *Param, void *list) } if (strcmp(Param, "BandListStorage") == 0) { gs_param_string bls; + gs_lib_ctx_core_t *core = dev->memory->gs_lib_ctx->core; /* Force the default to 'memory' if clist file I/O is not included in this build */ - if (clist_io_procs_file_global == NULL) + if (core->clist_io_procs_file == NULL) ppdev->BLS_force_memory = true; if (ppdev->BLS_force_memory) { bls.data = (byte *)"memory"; @@ -629,6 +637,7 @@ gdev_prn_get_params(gx_device * pdev, gs_param_list * plist) gs_param_string bls; gs_param_string saved_pages; bool pageneutralcolor = false; + gs_lib_ctx_core_t *core = pdev->memory->gs_lib_ctx->core; if (pdev->icc_struct != NULL) pageneutralcolor = pdev->icc_struct->pageneutralcolor; @@ -646,7 +655,7 @@ gdev_prn_get_params(gx_device * pdev, gs_param_list * plist) return code; /* Force the default to 'memory' if clist file I/O is not included in this build */ - if (clist_io_procs_file_global == NULL) + if (core->clist_io_procs_file == NULL) ppdev->BLS_force_memory = true; if (ppdev->BLS_force_memory) { bls.data = (byte *)"memory"; @@ -709,6 +718,7 @@ gdev_prn_put_params(gx_device * pdev, gs_param_list * plist) gs_param_dict mdict; gs_param_string saved_pages; bool pageneutralcolor = false; + gs_lib_ctx_core_t *core = ppdev->memory->gs_lib_ctx->core; memset(&saved_pages, 0, sizeof(gs_param_string)); save_sp = ppdev->space_params; @@ -751,7 +761,7 @@ gdev_prn_put_params(gx_device * pdev, gs_param_list * plist) case 0: /* Only accept 'file' if the file procs are include in the build */ if ((bls.size > 1) && (bls.data[0] == 'm' || - (clist_io_procs_file_global != NULL && bls.data[0] == 'f'))) + (core->clist_io_procs_file != NULL && bls.data[0] == 'f'))) break; /* fall through */ default: @@ -1184,11 +1194,18 @@ gx_render_plane_init(gx_render_plane_t *render_plane, const gx_device *dev, int num_planes = dev->color_info.num_components; int plane_depth = dev->color_info.depth / num_planes; - if (index < 0 || index >= num_planes) + if (index < -1 || index >= num_planes) return_error(gs_error_rangecheck); render_plane->index = index; - render_plane->depth = plane_depth; - render_plane->shift = plane_depth * (num_planes - 1 - index); + if (index == -1) { + /* No plane, chunky results required. */ + render_plane->depth = dev->color_info.depth; + render_plane->shift = 0; + } else { + /* A single plane */ + render_plane->depth = plane_depth; + render_plane->shift = plane_depth * (num_planes - 1 - index); + } return 0; } @@ -1414,8 +1431,16 @@ gx_default_create_buf_device(gx_device **pbdev, gx_device *target, int y, #endif gx_device_fill_in_procs((gx_device *)mdev); } else { - gs_make_mem_device(mdev, mdproto, mem, (color_usage == NULL ? 1 : 0), - target); + gs_devn_params* pdevn_params; + + gs_make_mem_device(mdev, mdproto, mem, (color_usage == NULL ? 1 : 0), target); + /* mem devices may need to refer to the target's devn_params struct */ + /* if the device has separations already defined (by SeparationOrderNames), we */ + /* need to use them so the colorants are in the same order as the target device. */ + pdevn_params = dev_proc(target, ret_devn_params)(target); + if (pdevn_params != NULL) { + mdev->procs.ret_devn_params = gx_forward_ret_devn_params; + } } mdev->width = target->width; mdev->band_y = y; |