summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2021-08-17 12:29:54 +0100
committerRobin Watts <Robin.Watts@artifex.com>2021-09-03 17:01:27 +0100
commit9ba1ef79d9a053a8faebe3807e3a489fccff0ec2 (patch)
tree5d16859628d7c51b662ad399deb0ab170fdb53d7
parent563d6a808730a3c470c03ebd85f9ca386b292b63 (diff)
downloadghostpdl-nup-endpage.tar.gz
Tweak beginpage/endpage for subclassing.nup-endpage
Our Postscript BeginPage/EndPage handling is done by having default BeginPage/EndPage routines that call .callbeginpage and .callendpage. This means that any Postscript that overrides BeginPage/EndPage will prevent calls to .callbeginpage and .callendpage being made. This seems strange to me, but never mind... These functions find the 'page_device', and then call the respective page_proc on them. This means subclassing has no way to intercept and act on these procs. For example, in a typical situation, I might have the Nup device wrapping the epo device wrapping the png16m page device. zcallbeginpage is called with dev = Nup. get_page_device returns png16m, and we then call beginpage on that. Nup never gets a chance to be informed. So, we need to alter this. There are 3 possible routes I can see to change this, and it's not clear to me which is best. 1) We could change get_page_device on the Nup device to claim that Nup is the page device. We would then need to ensure that all parent devices forward the page calls down to child devices. This should already be the case for subclassing devices, but I am unsure of the other potential ramifications for changing the 'page device' away from being the bottommost device, so not choosing this option. 2) We could get the page_device, then run up the dev->parent chain to find the topmost device, and call the page_proc on that, relying on that passing the page calls down to child devices. This works, but begs the question, why go to that effort when 3 is simpler? 3) We could drop the get_page_device call entirely, and just call the page_proc on the topmost device, relying on it passing down to child devices properly. Here we implement 3. If we ever find a problem with this, we can reconsider the other options.
-rw-r--r--psi/zdevice2.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/psi/zdevice2.c b/psi/zdevice2.c
index dab9e6b9f..046c58196 100644
--- a/psi/zdevice2.c
+++ b/psi/zdevice2.c
@@ -150,14 +150,12 @@ zcallbeginpage(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gx_device *dev = gs_currentdevice(igs);
+ int code;
check_type(*op, t_integer);
- if ((dev = (*dev_proc(dev, get_page_device))(dev)) != 0) {
- int code = (*dev->page_procs.begin_page)(dev, igs);
-
- if (code < 0)
+ code = (*dev->page_procs.begin_page)(dev, igs);
+ if (code < 0)
return code;
- }
pop(1);
return 0;
}
@@ -172,15 +170,11 @@ zcallendpage(i_ctx_t *i_ctx_p)
check_type(op[-1], t_integer);
check_type(*op, t_integer);
- if ((dev = (*dev_proc(dev, get_page_device))(dev)) != 0) {
- code = (*dev->page_procs.end_page)(dev, (int)op->value.intval, igs);
- if (code < 0)
- return code;
- if (code > 1)
- return_error(gs_error_rangecheck);
- } else {
- code = (op->value.intval == 2 ? 0 : 1);
- }
+ code = (*dev->page_procs.end_page)(dev, (int)op->value.intval, igs);
+ if (code < 0)
+ return code;
+ if (code > 1)
+ return_error(gs_error_rangecheck);
make_bool(op - 1, code);
pop(1);
return 0;