-
Notifications
You must be signed in to change notification settings - Fork 2
/
SetClip.c
75 lines (60 loc) · 1.7 KB
/
SetClip.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "nxlib.h"
#include <stdlib.h>
int
XSetClipOrigin(Display *display, GC gc, int clip_x_origin, int clip_y_origin)
{
//GR_GC_INFO gcip;
GrSetGCClipOrigin(gc->gid, clip_x_origin, clip_y_origin);
//NOTE: Don't offset region here, this is done in GsPrepareDrawing
//GrGetGCInfo(gc->gid, &gcip);
//GrOffsetRegion(gcip.region, clip_x_origin, clip_y_origin);
return 1;
}
int
XSetClipMask(Display *display, GC gc, Pixmap mask)
{
XGCValues *vp = (XGCValues *)gc->ext_data;
GR_WINDOW_INFO info;
/* avoid memory leak by deleting current gc region before new alloc*/
if (vp->clip_mask != None)
GrDestroyRegion(vp->clip_mask);
if (mask == None) {
GrSetGCRegion(gc->gid, 0);
vp->clip_mask = None;
return 1;
}
GrGetWindowInfo(mask, &info);
vp->clip_mask = GrNewRegionFromPixmap(mask, 0, 0, info.width, info.height);
GrSetGCRegion(gc->gid, vp->clip_mask);
return 1;
}
int
XSetClipRectangles(Display *display, GC gc, int clip_x_origin, int clip_y_origin,
XRectangle *rectangles, int n, int ordering)
{
GR_REGION_ID r;
XGCValues *vp = (XGCValues *)gc->ext_data;
GrSetGCClipOrigin(gc->gid, clip_x_origin, clip_y_origin);
/* avoid memory leak by deleting current gc region before new alloc*/
if (vp->clip_mask != None)
GrDestroyRegion(vp->clip_mask);
if (n == 0) {
/* FIXME need to disable all output here...*/
DPRINTF("XSetClipRectangles called with n=0\n");
vp->clip_mask = None; /* None for no output?*/
return 1;
}
r = GrNewRegion();
while (--n >= 0) {
GR_RECT rc;
rc.x = rectangles->x;
rc.y = rectangles->y;
rc.width = rectangles->width;
rc.height = rectangles->height;
GrUnionRectWithRegion(r, &rc);
++rectangles;
}
GrSetGCRegion(gc->gid, r);
vp->clip_mask = r;
return 1;
}