Removed some more trailing whitespace.
[wine] / dlls / wineps / clipping.c
1 /*
2  *      PostScript clipping functions
3  *
4  *      Copyright 1999  Luc Tourangau
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "psdrv.h"
22 #include "wine/debug.h"
23 #include "winbase.h"
24
25 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
26
27 /***********************************************************************
28  *           PSDRV_SetDeviceClipping
29  */
30 VOID PSDRV_SetDeviceClipping( PSDRV_PDEVICE *physDev, HRGN hrgn )
31 {
32     CHAR szArrayName[] = "clippath";
33     DWORD size;
34     RGNDATA *rgndata;
35
36     TRACE("hdc=%04x\n", physDev->hdc);
37
38     size = GetRegionData(hrgn, 0, NULL);
39     if(!size) {
40         ERR("Invalid region\n");
41         return;
42     }
43
44     rgndata = HeapAlloc( GetProcessHeap(), 0, size );
45     if(!rgndata) {
46         ERR("Can't allocate buffer\n");
47         return;
48     }
49
50     GetRegionData(hrgn, size, rgndata);
51
52     PSDRV_WriteInitClip(physDev);
53
54     /* check for NULL region */
55     if (rgndata->rdh.nCount == 0)
56     {
57         /* set an empty clip path. */
58         PSDRV_WriteRectClip(physDev, 0, 0, 0, 0);
59     }
60     /* optimize when it is a simple region */
61     else if (rgndata->rdh.nCount == 1)
62     {
63         RECT *pRect = (RECT *)rgndata->Buffer;
64
65         PSDRV_WriteRectClip(physDev, pRect->left, pRect->top,
66                             pRect->right - pRect->left,
67                             pRect->bottom - pRect->top);
68     }
69     else
70     {
71         INT i;
72         RECT *pRect = (RECT *)rgndata->Buffer;
73
74         PSDRV_WriteArrayDef(physDev, szArrayName, rgndata->rdh.nCount * 4);
75
76         for (i = 0; i < rgndata->rdh.nCount; i++, pRect++)
77         {
78             PSDRV_WriteArrayPut(physDev, szArrayName, i * 4,
79                                 pRect->left);
80             PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 1,
81                                 pRect->top);
82             PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 2,
83                                 pRect->right - pRect->left);
84             PSDRV_WriteArrayPut(physDev, szArrayName, i * 4 + 3,
85                                 pRect->bottom - pRect->top);
86         }
87
88         PSDRV_WriteRectClip2(physDev, szArrayName);
89     }
90
91     HeapFree( GetProcessHeap(), 0, rgndata );
92     return;
93 }