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