summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2013-12-18 11:37:40 +0000
committerKen Sharp <ken.sharp@artifex.com>2013-12-18 12:10:46 +0000
commit5ddd13eda3853d53315b7ba656ccd32ad9814c34 (patch)
tree2f260ec24bb60217e7759c647ada2e9d459aa35a
parent2f8b73d56d667334e935071f24f1d6b1860a48e2 (diff)
ps2write - Don't emit a page size change if the last request failed (and was the same size)
Bug #694852 We check the current media size at the start of every page, and only emit a new request if the page is a different size to the current size. However, if the request fails (media not available) we keep on requesting the media via setpagedevice. This causes duplexing to be disabled, as each setpagedevice resets the device and ejects the previous page. This commit still checks the current page size, however, if it is not the size needed for the page, we then check to see if 'MediaRequested;' is known. If it is not we set the media, and set MediaRequested to the new media size. If MediaRequested is known, we check to see if the new media size is the same as the last one we requested. If it is there's no point in doing a new request as it will fail again,so we drop the request. If the new requested media is not the same as the last requested media, then we do emit a new request, which may or may not be satisfied of course. This should permit duplexing to work and be slightly faster in the case where requested media is not available.
-rw-r--r--gs/devices/vector/opdfread.h19
-rw-r--r--gs/lib/opdfread.ps20
2 files changed, 35 insertions, 4 deletions
diff --git a/gs/devices/vector/opdfread.h b/gs/devices/vector/opdfread.h
index 1ec2a02fd..f2e9c891c 100644
--- a/gs/devices/vector/opdfread.h
+++ b/gs/devices/vector/opdfread.h
@@ -734,10 +734,27 @@ const char *opdfread_ps [] = {
"0 0}ifelse\n",
"round cvi 2 index round cvi eq\n",
"exch round cvi 3 index round cvi eq and{\n",
+"//PDFR_DEBUG{(PageSize matches request) == flush}if\n",
"pop pop}{\n",
+"/MediaRequested where {\n",
+"//PDFR_DEBUG{(MediaRequested is true, check against new request) == flush}if\n",
+"/MediaRequested get aload pop\n",
+"round cvi 2 index round cvi eq\n",
+"exch round cvi 3 index round cvi eq and\n",
+"{//PDFR_DEBUG{(MediaRequested same as current request, ignore) == flush}if pop pop false}\n",
+"{//PDFR_DEBUG{(MediaRequested different to current request) == flush}if true}ifelse\n",
+"}{\n",
+"//PDFR_DEBUG{(No MediaRequested yet) == flush}if\n",
+"true\n",
+"}ifelse\n",
+"{\n",
+"//PDFR_DEBUG{(Setting pagesize) == flush}if\n",
"2 array astore\n",
+"dup /MediaRequested exch def\n",
"<< exch /PageSize exch >> setpagedevice\n",
-"} ifelse\n",
+"/pagesave save def\n",
+"}if\n",
+"}ifelse\n",
"userdict/PDFR_InitialGS gstate put\n",
"setglobal\n",
"}if\n",
diff --git a/gs/lib/opdfread.ps b/gs/lib/opdfread.ps
index 26b63872d..6ef1564ea 100644
--- a/gs/lib/opdfread.ps
+++ b/gs/lib/opdfread.ps
@@ -896,13 +896,27 @@ currentdict end readonly def
0 0 % dummy page size values if not known
}ifelse
% bw bh px0 py0 bw bh bool bw bh Width Height
- round cvi 2 index round cvi % bw bh px0 py0 bw bh bool bw bh Width bool
+ round cvi 2 index round cvi eq % bw bh px0 py0 bw bh bool bw bh Width bool
exch round cvi 3 index round cvi eq and % bw bh px0 py0 bw bh bool bw bh bool
{ % Page Size unchanged, do not emit setpagedevice
pop pop % bw bh px0 py0 bw bh bool
} {
- 2 array astore % bw bh px0 py0 bw bh bool []
- << exch /PageSize exch >> setpagedevice % bw bh px0 py0 bw bh bool
+ /MediaRequested where {
+ % bw bh px0 py0 bw bh
+ /MediaRequested get aload pop % bw bh px0 py0 bw bh Width Height
+ round cvi 2 index round cvi eq % bw bh px0 py0 bw bh bool bw bh Width bool
+ exch round cvi 3 index round cvi eq and % bw bh px0 py0 bw bh bool bw bh bool
+ {pop pop false} % We already requested this media size, so don't re-request
+ {true} ifelse % Media request different to last request
+ } {
+ true % No stored media request, so apply setpagedevice
+ } ifelse
+ {
+ 2 array astore % bw bh px0 py0 bw bh bool []
+ dup /MediaRequested exch def
+ << exch /PageSize exch >> setpagedevice % bw bh px0 py0 bw bh bool
+ /pagesave save def
+ } if
} ifelse
userdict /PDFR_InitialGS gstate put
setglobal % bw bh px0 py0 bw bh