wineps.drv: Get rid of the empty SetDeviceClipping entry point.
[wine/wine-gecko.git] / dlls / wineps.drv / clipping.c
blobe7bc710fe8206dfbd18fc73efafb9be351d47209
1 /*
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "psdrv.h"
22 #include "wine/debug.h"
23 #include "winbase.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
27 /***********************************************************************
28 * PSDRV_SetClip
30 * The idea here is that every graphics operation should bracket
31 * output in PSDRV_SetClip/ResetClip calls. The clip path outside
32 * these calls will be empty; the reason for this is that it is
33 * impossible in PostScript to cleanly make the clip path larger than
34 * the current one. Also Photoshop assumes that despite having set a
35 * small clip area in the printer dc that it can still write raw
36 * PostScript to the driver and expect this code not to be clipped.
38 void PSDRV_SetClip( PSDRV_PDEVICE *physDev )
40 CHAR szArrayName[] = "clippath";
41 DWORD size;
42 RGNDATA *rgndata = NULL;
43 HRGN hrgn = CreateRectRgn(0,0,0,0);
44 BOOL empty;
46 TRACE("hdc=%p\n", physDev->hdc);
48 if(physDev->pathdepth) {
49 TRACE("inside a path, so not clipping\n");
50 goto end;
53 empty = !GetClipRgn(physDev->hdc, hrgn);
55 if(!empty) {
56 size = GetRegionData(hrgn, 0, NULL);
57 if(!size) {
58 ERR("Invalid region\n");
59 goto end;
62 rgndata = HeapAlloc( GetProcessHeap(), 0, size );
63 if(!rgndata) {
64 ERR("Can't allocate buffer\n");
65 goto end;
68 GetRegionData(hrgn, size, rgndata);
70 PSDRV_WriteGSave(physDev);
72 /* check for NULL region */
73 if (rgndata->rdh.nCount == 0)
75 /* set an empty clip path. */
76 PSDRV_WriteRectClip(physDev, 0, 0, 0, 0);
78 /* optimize when it is a simple region */
79 else if (rgndata->rdh.nCount == 1)
81 RECT *pRect = (RECT *)rgndata->Buffer;
83 PSDRV_WriteRectClip(physDev, pRect->left, pRect->top,
84 pRect->right - pRect->left,
85 pRect->bottom - pRect->top);
87 else
89 UINT i;
90 RECT *pRect = (RECT *)rgndata->Buffer;
92 PSDRV_WriteArrayDef(physDev, szArrayName, rgndata->rdh.nCount * 4);
94 for (i = 0; i < rgndata->rdh.nCount; i++, pRect++)
96 PSDRV_WriteArrayPut(physDev, szArrayName, i * 4,
97 pRect->left);
98 PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 1,
99 pRect->top);
100 PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 2,
101 pRect->right - pRect->left);
102 PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 3,
103 pRect->bottom - pRect->top);
105 PSDRV_WriteRectClip2(physDev, szArrayName);
108 end:
109 HeapFree( GetProcessHeap(), 0, rgndata );
110 DeleteObject(hrgn);
114 /***********************************************************************
115 * PSDRV_ResetClip
117 void PSDRV_ResetClip( PSDRV_PDEVICE *physDev )
119 HRGN hrgn = CreateRectRgn(0,0,0,0);
120 BOOL empty;
122 empty = !GetClipRgn(physDev->hdc, hrgn);
123 if(!empty && !physDev->pathdepth)
124 PSDRV_WriteGRestore(physDev);
125 DeleteObject(hrgn);