diff --git a/graphics/psdrv/clipping.c b/graphics/psdrv/clipping.c index 265f8f30a3..5a9eff6434 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 4b8c138263..f7d104d7ef 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 f7e5aab22e..9c0b2c736d 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 a68a45240e..dda676c35a 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);