From 62efee2345f38832451ce857ef72beee40686eee Mon Sep 17 00:00:00 2001 From: Stephane Lussier Date: Wed, 13 Oct 1999 13:58:45 +0000 Subject: [PATCH] Fixed the clipping for the postscript driver and turned it on (by setting PSDRV_SetDeviceClipping in the function table). --- graphics/psdrv/clipping.c | 22 ++++++++++++++++++++-- graphics/psdrv/init.c | 2 +- graphics/psdrv/ps.c | 22 ++++++++++++++++++++-- include/psdrv.h | 4 +++- 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/graphics/psdrv/clipping.c b/graphics/psdrv/clipping.c index 265f8f30a3b..5a9eff6434b 100644 --- a/graphics/psdrv/clipping.c +++ b/graphics/psdrv/clipping.c @@ -42,7 +42,24 @@ VOID PSDRV_SetDeviceClipping( DC *dc ) GetRegionData(dc->w.hGCClipRgn, size, rgndata); - if (rgndata->rdh.nCount > 0) + PSDRV_WriteInitClip(dc); + + /* check for NULL region */ + if (rgndata->rdh.nCount == 0) + { + /* set an empty clip path. */ + PSDRV_WriteRectClip(dc, 0, 0, 0, 0); + } + /* optimize when it is a simple region */ + else if (rgndata->rdh.nCount == 1) + { + RECT *pRect = (RECT *)rgndata->Buffer; + + PSDRV_WriteRectClip(dc, pRect->left, pRect->top, + pRect->right - pRect->left, + pRect->bottom - pRect->top); + } + else { INT i; RECT *pRect = (RECT *)rgndata->Buffer; @@ -60,9 +77,10 @@ VOID PSDRV_SetDeviceClipping( DC *dc ) PSDRV_WriteArrayPut(dc, szArrayName, i * 4 + 3, pRect->bottom - pRect->top); } + + PSDRV_WriteRectClip2(dc, szArrayName); } - PSDRV_WriteRectClip(dc, szArrayName); HeapFree( GetProcessHeap(), 0, rgndata ); return; } diff --git a/graphics/psdrv/init.c b/graphics/psdrv/init.c index 4b8c1382632..f7d104d7ef0 100644 --- a/graphics/psdrv/init.c +++ b/graphics/psdrv/init.c @@ -78,7 +78,7 @@ static const DC_FUNCTIONS PSDRV_Funcs = NULL, /* pSelectPalette */ PSDRV_SetBkColor, /* pSetBkColor */ NULL, /* pSetBkMode */ - NULL, /* pSetDeviceClipping */ + PSDRV_SetDeviceClipping, /* pSetDeviceClipping */ NULL, /* pSetDIBitsToDevice */ NULL, /* pSetMapMode (optional) */ NULL, /* pSetMapperFlags */ diff --git a/graphics/psdrv/ps.c b/graphics/psdrv/ps.c index f7e5aab22ec..9c0b2c736d9 100644 --- a/graphics/psdrv/ps.c +++ b/graphics/psdrv/ps.c @@ -161,10 +161,16 @@ static char psclosepath[] = static char psclip[] = "clip\n"; +static char psinitclip[] = +"initclip\n"; + static char pseoclip[] = "eoclip\n"; static char psrectclip[] = +"%d %d %d %d rectclip\n"; + +static char psrectclip2[] = "%s rectclip\n"; static char pshatch[] = @@ -702,6 +708,11 @@ BOOL PSDRV_WriteEOClip(DC *dc) return PSDRV_WriteSpool(dc, pseoclip, sizeof(pseoclip)-1); } +BOOL PSDRV_WriteInitClip(DC *dc) +{ + return PSDRV_WriteSpool(dc, psinitclip, sizeof(psinitclip)-1); +} + BOOL PSDRV_WriteHatch(DC *dc) { return PSDRV_WriteSpool(dc, pshatch, sizeof(pshatch)-1); @@ -911,14 +922,21 @@ BOOL PSDRV_WriteArrayDef(DC *dc, CHAR *pszArrayName, INT nSize) return PSDRV_WriteSpool(dc, buf, strlen(buf)); } -BOOL PSDRV_WriteRectClip(DC *dc, CHAR *pszArrayName) +BOOL PSDRV_WriteRectClip(DC *dc, INT x, INT y, INT w, INT h) { char buf[100]; - sprintf(buf, psrectclip, pszArrayName); + sprintf(buf, psrectclip, x, y, w, h); return PSDRV_WriteSpool(dc, buf, strlen(buf)); } +BOOL PSDRV_WriteRectClip2(DC *dc, CHAR *pszArrayName) +{ + char buf[100]; + + sprintf(buf, psrectclip2, pszArrayName); + return PSDRV_WriteSpool(dc, buf, strlen(buf)); +} BOOL PSDRV_WritePatternDict(DC *dc, BITMAP *bm, BYTE *bits) { diff --git a/include/psdrv.h b/include/psdrv.h index a68a45240e6..dda676c35ae 100644 --- a/include/psdrv.h +++ b/include/psdrv.h @@ -289,8 +289,10 @@ extern BOOL PSDRV_WriteGSave(DC *dc); extern BOOL PSDRV_WriteGRestore(DC *dc); extern BOOL PSDRV_WriteNewPath(DC *dc); extern BOOL PSDRV_WriteClosePath(DC *dc); +extern BOOL PSDRV_WriteInitClip(DC *dc); extern BOOL PSDRV_WriteClip(DC *dc); -extern BOOL PSDRV_WriteRectClip(DC *dc, CHAR *pszArrayName); +extern BOOL PSDRV_WriteRectClip(DC *dc, INT x, INT y, INT w, INT h); +extern BOOL PSDRV_WriteRectClip2(DC *dc, CHAR *pszArrayName); extern BOOL PSDRV_WriteEOClip(DC *dc); extern BOOL PSDRV_WriteHatch(DC *dc); extern BOOL PSDRV_WriteRotate(DC *dc, float ang);