New debug scheme with explicit debug channels declaration.
[wine/hacks.git] / graphics / x11drv / clipping.c
blob04a70280e78d2d0f115b3048c5c34c8d1d38c077
1 /*
2 * X11DRV clipping functions
4 * Copyright 1998 Huw Davies
5 */
7 #include "config.h"
9 #ifndef X_DISPLAY_MISSING
11 #include "ts_xlib.h"
13 #include <stdio.h>
14 #include "dc.h"
15 #include "x11drv.h"
16 #include "region.h"
17 #include "debug.h"
18 #include "heap.h"
19 #include "local.h"
21 DEFAULT_DEBUG_CHANNEL(x11drv)
23 /***********************************************************************
24 * X11DRV_SetDeviceClipping
25 * Copy RECT32s to a temporary buffer of XRectangles and call
26 * TSXSetClipRectangles().
28 * Could write using GetRegionData but this would be slower.
30 void X11DRV_SetDeviceClipping( DC * dc )
32 XRectangle *pXrect;
33 X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
35 RGNOBJ *obj = (RGNOBJ *) GDI_GetObjPtr(dc->w.hGCClipRgn, REGION_MAGIC);
36 if (!obj)
38 ERR(x11drv, "Rgn is 0. Please report this.\n");
39 return;
42 if (obj->rgn->numRects > 0)
44 XRectangle *pXr;
45 RECT *pRect = obj->rgn->rects;
46 RECT *pEndRect = obj->rgn->rects + obj->rgn->numRects;
48 pXrect = HeapAlloc( GetProcessHeap(), 0,
49 sizeof(*pXrect) * obj->rgn->numRects );
50 if(!pXrect)
52 WARN(x11drv, "Can't alloc buffer\n");
53 return;
56 for(pXr = pXrect; pRect < pEndRect; pRect++, pXr++)
58 pXr->x = pRect->left;
59 pXr->y = pRect->top;
60 pXr->width = pRect->right - pRect->left;
61 pXr->height = pRect->bottom - pRect->top;
64 else
65 pXrect = NULL;
67 TSXSetClipRectangles( display, physDev->gc, 0, 0,
68 pXrect, obj->rgn->numRects, YXBanded );
70 if(pXrect)
71 HeapFree( GetProcessHeap(), 0, pXrect );
73 GDI_HEAP_UNLOCK( dc->w.hGCClipRgn );
76 #endif /* !defined(X_DISPLAY_MISSING) */