2 * PostScript clipping functions
4 * Copyright 1999 Luc Tourangau
10 #include "debugtools.h"
13 DEFAULT_DEBUG_CHANNEL(psdrv)
15 /***********************************************************************
16 * PSDRV_SetDeviceClipping
18 VOID PSDRV_SetDeviceClipping( DC *dc )
20 CHAR szArrayName[] = "clippath";
24 TRACE("hdc=%04x\n", dc->hSelf);
26 if (dc->hGCClipRgn == 0) {
27 ERR("Rgn is 0. Please report this.\n");
31 size = GetRegionData(dc->hGCClipRgn, 0, NULL);
33 ERR("Invalid region\n");
37 rgndata = HeapAlloc( GetProcessHeap(), 0, size );
39 ERR("Can't allocate buffer\n");
43 GetRegionData(dc->hGCClipRgn, size, rgndata);
45 PSDRV_WriteInitClip(dc);
47 /* check for NULL region */
48 if (rgndata->rdh.nCount == 0)
50 /* set an empty clip path. */
51 PSDRV_WriteRectClip(dc, 0, 0, 0, 0);
53 /* optimize when it is a simple region */
54 else if (rgndata->rdh.nCount == 1)
56 RECT *pRect = (RECT *)rgndata->Buffer;
58 PSDRV_WriteRectClip(dc, pRect->left, pRect->top,
59 pRect->right - pRect->left,
60 pRect->bottom - pRect->top);
65 RECT *pRect = (RECT *)rgndata->Buffer;
67 PSDRV_WriteArrayDef(dc, szArrayName, rgndata->rdh.nCount * 4);
69 for (i = 0; i < rgndata->rdh.nCount; i++, pRect++)
71 PSDRV_WriteArrayPut(dc, szArrayName, i * 4,
73 PSDRV_WriteArrayPut(dc, szArrayName, i * 4 + 1,
75 PSDRV_WriteArrayPut(dc, szArrayName, i * 4 + 2,
76 pRect->right - pRect->left);
77 PSDRV_WriteArrayPut(dc, szArrayName, i * 4 + 3,
78 pRect->bottom - pRect->top);
81 PSDRV_WriteRectClip2(dc, szArrayName);
84 HeapFree( GetProcessHeap(), 0, rgndata );