Release 980201
[wine/multimedia.git] / graphics / x11drv / clipping.c
bloba778c1ef5914611de9cfa9821d36b282049a863d
1 /*
2 * X11DRV clipping functions
4 * Copyright 1998 Huw Davies
5 */
7 #include <stdio.h>
8 #include "dc.h"
9 #include "x11drv.h"
10 #include "region.h"
11 #include "stddebug.h"
12 #include "debug.h"
13 #include "heap.h"
15 /***********************************************************************
16 * X11DRV_SetDeviceClipping
17 * Copy RECT32s to a temporary buffer of XRectangles and call
18 * TSXSetClipRectangles().
20 * Could write using GetRegionData but this would be slower.
22 void X11DRV_SetDeviceClipping( DC * dc )
24 XRectangle *pXrect;
25 RGNOBJ *obj = (RGNOBJ *) GDI_GetObjPtr(dc->w.hGCClipRgn, REGION_MAGIC);
26 if (!obj)
28 fprintf( stderr, "X11DRV_SetDeviceClipping: Rgn is 0. Please report this.\n");
29 exit(1);
32 if (obj->rgn->numRects > 0)
34 XRectangle *pXr;
35 RECT32 *pRect = obj->rgn->rects;
36 RECT32 *pEndRect = obj->rgn->rects + obj->rgn->numRects;
38 pXrect = HeapAlloc( GetProcessHeap(), 0,
39 sizeof(*pXrect) * obj->rgn->numRects );
40 if(!pXrect)
42 fprintf(stderr, "X11DRV_SetDeviceClipping() can't alloc buffer\n");
43 return;
46 for(pXr = pXrect; pRect < pEndRect; pRect++, pXr++)
48 pXr->x = pRect->left;
49 pXr->y = pRect->top;
50 pXr->width = pRect->right - pRect->left;
51 pXr->height = pRect->bottom - pRect->top;
54 else
55 pXrect = NULL;
57 TSXSetClipRectangles( display, dc->u.x.gc, dc->w.DCOrgX, dc->w.DCOrgY,
58 pXrect, obj->rgn->numRects, YXBanded );
60 if(pXrect)
61 HeapFree( GetProcessHeap(), 0, pXrect );
63 GDI_HEAP_UNLOCK( dc->w.hGCClipRgn );