1
/* $Xorg: GC.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
4
Copyright 1993 by Davor Matic
6
Permission to use, copy, modify, distribute, and sell this software
7
and its documentation for any purpose is hereby granted without fee,
8
provided that the above copyright notice appear in all copies and that
9
both that copyright notice and this permission notice appear in
10
supporting documentation. Davor Matic makes no representations about
11
the suitability of this software for any purpose. It is provided "as
12
is" without express or implied warranty.
15
/* $XFree86: xc/programs/Xserver/hw/xnest/GC.c,v 3.6 2001/10/28 03:34:11 tsi Exp $ */
17
#ifdef HAVE_XNEST_CONFIG_H
18
#include <xnest-config.h>
22
#include <X11/Xproto.h>
24
#include "windowstr.h"
25
#include "pixmapstr.h"
26
#include "scrnintstr.h"
27
#include <X11/fonts/fontstruct.h>
40
int xnestGCPrivateIndex;
42
static GCFuncs xnestFuncs = {
52
static GCOps xnestOps = {
76
xnestCreateGC(GCPtr pGC)
78
pGC->clientClipType = CT_NONE;
79
pGC->clientClip = NULL;
81
pGC->funcs = &xnestFuncs;
86
xnestGCPriv(pGC)->gc = XCreateGC(xnestDisplay,
87
xnestDefaultDrawables[pGC->depth],
89
xnestGCPriv(pGC)->nClipRects = 0;
95
xnestValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
97
pGC->lastWinOrg.x = pDrawable->x;
98
pGC->lastWinOrg.y = pDrawable->y;
102
xnestChangeGC(GCPtr pGC, unsigned long mask)
106
if (mask & GCFunction)
107
values.function = pGC->alu;
109
if (mask & GCPlaneMask)
110
values.plane_mask = pGC->planemask;
112
if (mask & GCForeground)
113
values.foreground = xnestPixel(pGC->fgPixel);
115
if (mask & GCBackground)
116
values.background = xnestPixel(pGC->bgPixel);
118
if (mask & GCLineWidth)
119
values.line_width = pGC->lineWidth;
121
if (mask & GCLineStyle)
122
values.line_style = pGC->lineStyle;
124
if (mask & GCCapStyle)
125
values.cap_style = pGC->capStyle;
127
if (mask & GCJoinStyle)
128
values.join_style = pGC->joinStyle;
130
if (mask & GCFillStyle)
131
values.fill_style = pGC->fillStyle;
133
if (mask & GCFillRule)
134
values.fill_rule = pGC->fillRule;
137
if (pGC->tileIsPixel)
140
values.tile = xnestPixmap(pGC->tile.pixmap);
143
if (mask & GCStipple)
144
values.stipple = xnestPixmap(pGC->stipple);
146
if (mask & GCTileStipXOrigin)
147
values.ts_x_origin = pGC->patOrg.x;
149
if (mask & GCTileStipYOrigin)
150
values.ts_y_origin = pGC->patOrg.y;
153
values.font = xnestFont(pGC->font);
155
if (mask & GCSubwindowMode)
156
values.subwindow_mode = pGC->subWindowMode;
158
if (mask & GCGraphicsExposures)
159
values.graphics_exposures = pGC->graphicsExposures;
161
if (mask & GCClipXOrigin)
162
values.clip_x_origin = pGC->clipOrg.x;
164
if (mask & GCClipYOrigin)
165
values.clip_y_origin = pGC->clipOrg.y;
167
if (mask & GCClipMask) /* this is handled in change clip */
170
if (mask & GCDashOffset)
171
values.dash_offset = pGC->dashOffset;
173
if (mask & GCDashList) {
175
XSetDashes(xnestDisplay, xnestGC(pGC),
176
pGC->dashOffset, (char *)pGC->dash, pGC->numInDashList);
179
if (mask & GCArcMode)
180
values.arc_mode = pGC->arcMode;
183
XChangeGC(xnestDisplay, xnestGC(pGC), mask, &values);
187
xnestCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
189
XCopyGC(xnestDisplay, xnestGC(pGCSrc), mask, xnestGC(pGCDst));
193
xnestDestroyGC(GCPtr pGC)
195
XFreeGC(xnestDisplay, xnestGC(pGC));
199
xnestChangeClip(GCPtr pGC, int type, pointer pValue, int nRects)
205
xnestDestroyClipHelper(pGC);
210
XSetClipMask(xnestDisplay, xnestGC(pGC), None);
214
nRects = REGION_NUM_RECTS((RegionPtr)pValue);
215
size = nRects * sizeof(*pRects);
216
pRects = (XRectangle *) xalloc(size);
217
pBox = REGION_RECTS((RegionPtr)pValue);
218
for (i = nRects; i-- > 0; ) {
219
pRects[i].x = pBox[i].x1;
220
pRects[i].y = pBox[i].y1;
221
pRects[i].width = pBox[i].x2 - pBox[i].x1;
222
pRects[i].height = pBox[i].y2 - pBox[i].y1;
224
XSetClipRectangles(xnestDisplay, xnestGC(pGC), 0, 0,
225
pRects, nRects, Unsorted);
226
xfree((char *) pRects);
230
XSetClipMask(xnestDisplay, xnestGC(pGC),
231
xnestPixmap((PixmapPtr)pValue));
233
* Need to change into region, so subsequent uses are with
234
* current pixmap contents.
236
pGC->clientClip = (pointer) (*pGC->pScreen->BitmapToRegion)((PixmapPtr)pValue);
237
(*pGC->pScreen->DestroyPixmap)((PixmapPtr)pValue);
238
pValue = pGC->clientClip;
243
XSetClipRectangles(xnestDisplay, xnestGC(pGC),
244
pGC->clipOrg.x, pGC->clipOrg.y,
245
(XRectangle *)pValue, nRects, Unsorted);
249
XSetClipRectangles(xnestDisplay, xnestGC(pGC),
250
pGC->clipOrg.x, pGC->clipOrg.y,
251
(XRectangle *)pValue, nRects, YSorted);
255
XSetClipRectangles(xnestDisplay, xnestGC(pGC),
256
pGC->clipOrg.x, pGC->clipOrg.y,
257
(XRectangle *)pValue, nRects, YXSorted);
261
XSetClipRectangles(xnestDisplay, xnestGC(pGC),
262
pGC->clipOrg.x, pGC->clipOrg.y,
263
(XRectangle *)pValue, nRects, YXBanded);
278
* other parts of server can only deal with CT_NONE,
279
* CT_PIXMAP and CT_REGION client clips.
281
pGC->clientClip = (pointer) RECTS_TO_REGION(pGC->pScreen, nRects,
282
(xRectangle *)pValue, type);
284
pValue = pGC->clientClip;
290
pGC->clientClipType = type;
291
pGC->clientClip = pValue;
292
xnestGCPriv(pGC)->nClipRects = nRects;
296
xnestDestroyClip(GCPtr pGC)
298
xnestDestroyClipHelper(pGC);
300
XSetClipMask(xnestDisplay, xnestGC(pGC), None);
302
pGC->clientClipType = CT_NONE;
303
pGC->clientClip = NULL;
304
xnestGCPriv(pGC)->nClipRects = 0;
308
xnestDestroyClipHelper(GCPtr pGC)
310
switch (pGC->clientClipType)
317
REGION_DESTROY(pGC->pScreen, pGC->clientClip);
323
xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
327
switch (pGCSrc->clientClipType)
331
xnestDestroyClip(pGCDst);
335
pRgn = REGION_CREATE(pGCDst->pScreen, NULL, 1);
336
REGION_COPY(pGCDst->pScreen, pRgn, pGCSrc->clientClip);
337
xnestChangeClip(pGCDst, CT_REGION, pRgn, 0);