2 * PostScript clipping functions
4 * Copyright 1999 Luc Tourangau
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
28 /***********************************************************************
29 * PSDRV_SetDeviceClipping
31 VOID PSDRV_SetDeviceClipping( PSDRV_PDEVICE *physDev )
33 CHAR szArrayName[] = "clippath";
38 TRACE("hdc=%04x\n", physDev->hdc);
40 if (dc->hGCClipRgn == 0) {
41 ERR("Rgn is 0. Please report this.\n");
45 size = GetRegionData(dc->hGCClipRgn, 0, NULL);
47 ERR("Invalid region\n");
51 rgndata = HeapAlloc( GetProcessHeap(), 0, size );
53 ERR("Can't allocate buffer\n");
57 GetRegionData(dc->hGCClipRgn, size, rgndata);
59 PSDRV_WriteInitClip(physDev);
61 /* check for NULL region */
62 if (rgndata->rdh.nCount == 0)
64 /* set an empty clip path. */
65 PSDRV_WriteRectClip(physDev, 0, 0, 0, 0);
67 /* optimize when it is a simple region */
68 else if (rgndata->rdh.nCount == 1)
70 RECT *pRect = (RECT *)rgndata->Buffer;
72 PSDRV_WriteRectClip(physDev, pRect->left, pRect->top,
73 pRect->right - pRect->left,
74 pRect->bottom - pRect->top);
79 RECT *pRect = (RECT *)rgndata->Buffer;
81 PSDRV_WriteArrayDef(physDev, szArrayName, rgndata->rdh.nCount * 4);
83 for (i = 0; i < rgndata->rdh.nCount; i++, pRect++)
85 PSDRV_WriteArrayPut(physDev, szArrayName, i * 4,
87 PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 1,
89 PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 2,
90 pRect->right - pRect->left);
91 PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 3,
92 pRect->bottom - pRect->top);
95 PSDRV_WriteRectClip2(physDev, szArrayName);
98 HeapFree( GetProcessHeap(), 0, rgndata );