Do not erase local files on uninstall if install dir does not exist.
[wine.git] / graphics / psdrv / clipping.c
blob5a9eff6434b895e16f7a0b9310a1d8f6c1a6868a
1 /*
2 * PostScript clipping functions
4 * Copyright 1999 Luc Tourangau
6 */
8 #include "gdi.h"
9 #include "psdrv.h"
10 #include "debugtools.h"
11 #include "winbase.h"
13 DEFAULT_DEBUG_CHANNEL(psdrv)
15 /***********************************************************************
16 * PSDRV_SetDeviceClipping
18 VOID PSDRV_SetDeviceClipping( DC *dc )
20 CHAR szArrayName[] = "clippath";
21 DWORD size;
22 RGNDATA *rgndata;
24 TRACE("hdc=%04x\n", dc->hSelf);
26 if (dc->w.hGCClipRgn == 0) {
27 ERR("Rgn is 0. Please report this.\n");
28 return;
31 size = GetRegionData(dc->w.hGCClipRgn, 0, NULL);
32 if(!size) {
33 ERR("Invalid region\n");
34 return;
37 rgndata = HeapAlloc( GetProcessHeap(), 0, size );
38 if(!rgndata) {
39 ERR("Can't allocate buffer\n");
40 return;
43 GetRegionData(dc->w.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);
62 else
64 INT i;
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,
72 pRect->left);
73 PSDRV_WriteArrayPut(dc, szArrayName, i * 4 + 1,
74 pRect->top);
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 );
85 return;