diff options
Diffstat (limited to 'base/gdevepo.c')
-rw-r--r-- | base/gdevepo.c | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/base/gdevepo.c b/base/gdevepo.c index e3454273..7c9eb0b7 100644 --- a/base/gdevepo.c +++ b/base/gdevepo.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2020 Artifex Software, Inc. +/* Copyright (C) 2001-2021 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or @@ -193,16 +193,23 @@ gx_device_epo gs_epo_device = #undef MAX_COORD #undef MAX_RESOLUTION -static bool -is_device_installed(gx_device *dev, const char *name) +/* Starting at the top of the device chain (top parent) find */ +/* and return the epo device, or NULL if not found. */ +static gx_device * +find_installed_epo_device(gx_device *dev) { - while (dev) { - if (!strcmp(dev->dname, name)) { - return true; + gx_device *next_dev = dev; + + while (next_dev->parent != NULL) + next_dev = next_dev->parent; + + while (next_dev) { + if (next_dev->procs.fillpage == epo_fillpage) { + return next_dev; } - dev = dev->child; + next_dev = next_dev->child; } - return false; + return NULL; } /* See if this is a device we can optimize @@ -212,7 +219,12 @@ is_device_installed(gx_device *dev, const char *name) static bool device_wants_optimization(gx_device *dev) { - return (!gs_is_null_device(dev) && dev_proc(dev, fillpage) == gx_default_fillpage); + gx_device *terminal = dev; + + while(terminal->child != NULL) + terminal = terminal->child; + + return (!gs_is_null_device(terminal) && dev_proc(terminal, fillpage) == gx_default_fillpage); } /* Use this when debugging to enable/disable epo @@ -228,33 +240,31 @@ int epo_check_and_install(gx_device *dev) { int code = 0; - bool is_installed; + gx_device *installed_epo_device = NULL; bool can_optimize = false; - + /* Debugging mode to totally disable this */ if (gs_debug_c(gs_debug_flag_epo_disable)) { return code; } - + DPRINTF1(dev->memory, "current device is %s\n", dev->dname); - is_installed = is_device_installed(dev, EPO_DEVICENAME); - - if (is_installed) { + installed_epo_device = find_installed_epo_device(dev); + + if (installed_epo_device != NULL) { DPRINTF1(dev->memory, "device %s already installed\n", EPO_DEVICENAME); /* This is looking for the case where the device * changed into something we can't optimize, after it was already installed * (could be clist or some other weird thing) */ - if (dev->child) { - can_optimize = device_wants_optimization(dev->child); + if (installed_epo_device->child) { + can_optimize = device_wants_optimization(installed_epo_device->child); } if (!can_optimize) { - DPRINTF1(dev->memory, "child %s can't be optimized, uninstalling\n", dev->child->dname); - /* Not doing any pending fillpages because we are about to do - * a fillpage anyway - */ - gx_device_unsubclass(dev); + DPRINTF1(dev->memory, "child %s can't be optimized, uninstalling\n", installed_epo_device->child->dname); + /* Not doing any pending fillpages because we are about to do a fillpage anyway */ + gx_device_unsubclass(installed_epo_device); return code; } } else { @@ -262,7 +272,7 @@ epo_check_and_install(gx_device *dev) } /* Already installed, nothing to do */ - if (is_installed) { + if (installed_epo_device != NULL) { return code; } @@ -278,7 +288,7 @@ epo_check_and_install(gx_device *dev) DPRINTF1(dev->memory, "ERROR installing device %s\n", EPO_DEVICENAME); return code; } - + DPRINTF1(dev->memory, "SUCCESS installed device %s\n", dev->dname); return code; } @@ -288,7 +298,7 @@ epo_handle_erase_page(gx_device *dev) { erasepage_subclass_data *data = (erasepage_subclass_data *)dev->subclass_data; int code = 0; - + if (gs_debug_c(gs_debug_flag_epo_install_only)) { gx_device_unsubclass(dev); DPRINTF1(dev->memory, "Uninstall erasepage, device=%s\n", dev->dname); @@ -314,7 +324,7 @@ epo_handle_erase_page(gx_device *dev) int epo_fillpage(gx_device *dev, gs_gstate * pgs, gx_device_color *pdevc) { erasepage_subclass_data *data = (erasepage_subclass_data *)dev->subclass_data; - + if (gs_debug_c(gs_debug_flag_epo_install_only)) { return default_subclass_fillpage(dev, pgs, pdevc); } @@ -322,13 +332,13 @@ int epo_fillpage(gx_device *dev, gs_gstate * pgs, gx_device_color *pdevc) /* If color is not pure, don't defer this, uninstall and do it now */ if (!color_is_pure(pdevc)) { DPRINTF(dev->memory, "epo_fillpage(), color is not pure, uninstalling\n"); - gx_device_unsubclass(dev); + gx_device_unsubclass(dev); return dev_proc(dev, fillpage)(dev, pgs, pdevc); } - + /* Save the color being requested, and swallow the fillpage */ data->last_color = pdevc->colors.pure; - + DPRINTF(dev->memory, "Swallowing fillpage\n"); return 0; } |