Huw Davies : wineps: Use a tri-state to describe the passthrough state.
Alexandre Julliard
julliard at winehq.org
Wed Oct 3 18:23:29 CDT 2018
Module: wine
Branch: master
Commit: f7c15b9fcfc1ed5068f0c40f37087476894de61f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=f7c15b9fcfc1ed5068f0c40f37087476894de61f
Author: Huw Davies <huw at codeweavers.com>
Date: Wed Oct 3 11:39:19 2018 +0100
wineps: Use a tri-state to describe the passthrough state.
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wineps.drv/escape.c | 12 ++++++------
dlls/wineps.drv/graphics.c | 14 ++++++++------
dlls/wineps.drv/ps.c | 4 ++--
dlls/wineps.drv/psdrv.h | 10 ++++++++--
4 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/dlls/wineps.drv/escape.c b/dlls/wineps.drv/escape.c
index 636ad2a..f9616bc 100644
--- a/dlls/wineps.drv/escape.c
+++ b/dlls/wineps.drv/escape.c
@@ -269,11 +269,12 @@ INT PSDRV_ExtEscape( PHYSDEV dev, INT nEscape, INT cbInput, LPCVOID in_data,
* length of the string, rather than 2 more. So we'll use the WORD at
* in_data[0] instead.
*/
- if(!physDev->job.in_passthrough) {
- write_spool(dev, psbegindocument, sizeof(psbegindocument)-1);
- physDev->job.in_passthrough = TRUE;
+ if (physDev->job.passthrough_state == passthrough_none)
+ {
+ write_spool(dev, psbegindocument, sizeof(psbegindocument) - 1);
+ physDev->job.passthrough_state = passthrough_active;
}
- return write_spool(dev,((char*)in_data)+2,*(const WORD*)in_data);
+ return write_spool(dev, ((char*)in_data) + 2, *(const WORD*)in_data);
}
case POSTSCRIPT_IGNORE:
@@ -451,8 +452,7 @@ INT PSDRV_StartDoc( PHYSDEV dev, const DOCINFOW *doc )
physDev->job.OutOfPage = TRUE;
physDev->job.PageNo = 0;
physDev->job.quiet = FALSE;
- physDev->job.in_passthrough = FALSE;
- physDev->job.had_passthrough_rect = FALSE;
+ physDev->job.passthrough_state = passthrough_none;
physDev->job.doc_name = strdupW( doc->lpszDocName );
return physDev->job.id;
diff --git a/dlls/wineps.drv/graphics.c b/dlls/wineps.drv/graphics.c
index 4887bd0..66108d1 100644
--- a/dlls/wineps.drv/graphics.c
+++ b/dlls/wineps.drv/graphics.c
@@ -113,12 +113,14 @@ BOOL PSDRV_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
/* Windows does something truly hacky here. If we're in passthrough mode
and our rop is R2_NOP, then we output the string below. This is used in
Office 2k when inserting eps files */
- if(physDev->job.in_passthrough && !physDev->job.had_passthrough_rect && GetROP2(dev->hdc) == R2_NOP) {
- char buf[256];
- sprintf(buf, "N %d %d %d %d B\n", rect.right - rect.left, rect.bottom - rect.top, rect.left, rect.top);
- write_spool(dev, buf, strlen(buf));
- physDev->job.had_passthrough_rect = TRUE;
- return TRUE;
+ if (physDev->job.passthrough_state == passthrough_active && GetROP2(dev->hdc) == R2_NOP)
+ {
+ char buf[256];
+
+ sprintf(buf, "N %d %d %d %d B\n", rect.right - rect.left, rect.bottom - rect.top, rect.left, rect.top);
+ write_spool(dev, buf, strlen(buf));
+ physDev->job.passthrough_state = passthrough_had_rect;
+ return TRUE;
}
PSDRV_SetPen(dev);
diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c
index 972609d..663cc23 100644
--- a/dlls/wineps.drv/ps.c
+++ b/dlls/wineps.drv/ps.c
@@ -226,9 +226,9 @@ DWORD PSDRV_WriteSpool(PHYSDEV dev, LPCSTR lpData, DWORD cch)
return 0;
}
- if(physDev->job.in_passthrough) { /* Was in PASSTHROUGH mode */
+ if(physDev->job.passthrough_state != passthrough_none) { /* Was in PASSTHROUGH mode */
write_spool( dev, psenddocument, sizeof(psenddocument)-1 );
- physDev->job.in_passthrough = physDev->job.had_passthrough_rect = FALSE;
+ physDev->job.passthrough_state = passthrough_none;
}
if(physDev->job.OutOfPage) { /* Will get here after NEWFRAME Escape */
diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h
index 79f23ea..d92fbb3 100644
--- a/dlls/wineps.drv/psdrv.h
+++ b/dlls/wineps.drv/psdrv.h
@@ -343,6 +343,13 @@ typedef struct {
BOOL set;
} PSPEN;
+enum passthrough
+{
+ passthrough_none,
+ passthrough_active,
+ passthrough_had_rect, /* See the comment in PSDRV_Rectangle */
+};
+
typedef struct {
DWORD id; /* Job id */
HANDLE hprinter; /* Printer handle */
@@ -352,8 +359,7 @@ typedef struct {
BOOL OutOfPage; /* Page header not sent yet */
INT PageNo;
BOOL quiet; /* Don't actually output anything */
- BOOL in_passthrough; /* In PASSTHROUGH mode */
- BOOL had_passthrough_rect; /* See the comment in PSDRV_Rectangle */
+ enum passthrough passthrough_state;
} JOB;
typedef struct
More information about the wine-cvs
mailing list