- New implementation of SendMessage, ReceiveMessage, ReplyMessage functions
[wine] / graphics / x11drv / clipping.c
1 /*
2  * X11DRV clipping functions
3  *
4  * Copyright 1998 Huw Davies
5  */
6
7 #include "config.h"
8
9 #ifndef X_DISPLAY_MISSING
10
11 #include "ts_xlib.h"
12
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"
20
21 /***********************************************************************
22  *           X11DRV_SetDeviceClipping
23  *           Copy RECT32s to a temporary buffer of XRectangles and call
24  *           TSXSetClipRectangles().
25  *
26  *           Could write using GetRegionData but this would be slower.
27  */
28 void X11DRV_SetDeviceClipping( DC * dc )
29 {
30     XRectangle *pXrect;
31     X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
32     
33     RGNOBJ *obj = (RGNOBJ *) GDI_GetObjPtr(dc->w.hGCClipRgn, REGION_MAGIC);
34     if (!obj)
35     {
36         ERR(x11drv, "Rgn is 0. Please report this.\n");
37         return;
38     }
39     
40     if (obj->rgn->numRects > 0)
41     {
42         XRectangle *pXr;
43         RECT32 *pRect = obj->rgn->rects;
44         RECT32 *pEndRect = obj->rgn->rects + obj->rgn->numRects;
45
46         pXrect = HeapAlloc( GetProcessHeap(), 0, 
47                             sizeof(*pXrect) * obj->rgn->numRects );
48         if(!pXrect)
49         {
50             WARN(x11drv, "Can't alloc buffer\n");
51             return;
52         }
53
54         for(pXr = pXrect; pRect < pEndRect; pRect++, pXr++)
55         {
56             pXr->x = pRect->left;
57             pXr->y = pRect->top;
58             pXr->width = pRect->right - pRect->left;
59             pXr->height = pRect->bottom - pRect->top;
60         }
61     }
62     else
63         pXrect = NULL;
64
65     TSXSetClipRectangles( display, physDev->gc, 0, 0,
66                           pXrect, obj->rgn->numRects, YXBanded );
67
68     if(pXrect)
69         HeapFree( GetProcessHeap(), 0, pXrect );
70
71     GDI_HEAP_UNLOCK( dc->w.hGCClipRgn );
72 }
73
74 #endif /* !defined(X_DISPLAY_MISSING) */
75