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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
|
#ifdef HAVE_XS_CONFIG_H
#include <xs-config.h>
#endif
#include <X11/Xmd.h>
#include <X11/XCB/xcb.h>
#include <X11/XCB/xcb_aux.h>
#include <X11/XCB/xproto.h>
#include <X11/XCB/xcb_image.h>
#include "regionstr.h"
#include <X11/fonts/fontstruct.h>
#include "gcstruct.h"
#include "scrnintstr.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "region.h"
#include "servermd.h"
#include "xs-globals.h"
#include "xs-pixmap.h"
#include "xs-window.h"
#include "xs-gcops.h"
#include "xs-gc.h"
void xsFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans, xPoint *pPoints,
int *pWidths, int fSorted)
{
ErrorF("xs warning: function xsFillSpans not implemented\n");
}
void xsSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *pSrc,
xPoint *pPoints, int *pWidths, int nSpans, int fSorted)
{
ErrorF("xs warning: function xsSetSpans not implemented\n");
}
void xsGetSpans(DrawablePtr pDrawable, int maxWidth, DDXPointPtr pPoints,
int *pWidths, int nSpans, char *pBuffer)
{
ErrorF("xs warning: function xsGetSpans not implemented\n");
}
void xsQueryBestSize(int class, unsigned short *pWidth, unsigned short *pHeight,
ScreenPtr pScreen)
{
XCBQueryBestSizeCookie c;
XCBQueryBestSizeRep *r;
c = XCBQueryBestSize(xsConnection, class, (XCBDRAWABLE)xsBackingRoot, *pWidth,*pHeight);
r = XCBQueryBestSizeReply(xsConnection, c, NULL);
*pWidth = r->width;
*pHeight = r->height;
}
void xsPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
int w, int h, int leftPad, int format, char *pImage)
{
int size;
int i;
size = xsPixmapCalcSize(depth, w, h);
XCBPutImage(xsConnection,
format,
XS_DRAWABLE_ID(pDrawable),
XS_GC_PRIV(pGC)->gc,
w, h,
x, y,
leftPad,
depth,
size,
(CARD8*) (pImage+leftPad));
}
void xsGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
unsigned int format, unsigned long planeMask,
char *pImage)
{
XCBImage *img;
int length;
img = XCBImageGet(xsConnection,
XS_DRAWABLE_ID(pDrawable),
x, y,
w, h,
planeMask,
format);
if (img) {
length = img->bytes_per_line * img->height;
memmove(pImage, img->data, length);
XCBImageDestroy(img);
}
}
static Bool xsBitBlitPredicate(XCBGenericEvent *event)
{
return (event->response_type == XCBGraphicsExposure || event->response_type == XCBNoExposure);
}
static RegionPtr xsBitBlitHelper(GCPtr pGC)
{
int err;
if (!pGC->graphicsExposures)
return NullRegion;
else {
XCBGenericEvent *event;
XCBGraphicsExposureEvent *exp;
RegionPtr pReg, pTmpReg;
BoxRec Box;
Bool pending, overlap;
pReg = REGION_CREATE(pGC->pScreen, NULL, 1);
pTmpReg = REGION_CREATE(pGC->pScreen, NULL, 1);
if(!pReg || !pTmpReg)
return NullRegion;
pending = TRUE;
while (pending) {
event = XCBPollForEvent(xsConnection, &err);
if (!event)
break;
switch (event->response_type) {
case XCBNoExposure:
pending = FALSE;
break;
case XCBGraphicsExposure:
exp = (XCBGraphicsExposureEvent *) event;
Box.x1 = exp->x;
Box.y1 = exp->y;
Box.x2 = exp->x + exp->width;
Box.y2 = exp->y + exp->height;
REGION_RESET(pGC->pScreen, pTmpReg, &Box);
REGION_APPEND(pGC->pScreen, pReg, pTmpReg);
pending = exp->count;
break;
default:
ErrorF("File: %s Error: %d\n", __FILE__, err);
xsHandleEvent(event);
}
}
REGION_DESTROY(pGC->pScreen, pTmpReg);
REGION_VALIDATE(pGC->pScreen, pReg, &overlap);
return(pReg);
}
}
RegionPtr xsCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
GCPtr pGC, int srcx, int srcy, int width, int height,
int dstx, int dsty)
{
XCBCopyArea(xsConnection,
XS_DRAWABLE_ID(pSrcDrawable),
XS_DRAWABLE_ID(pDstDrawable),
XS_GC_PRIV(pGC)->gc,
srcx, srcy,
dstx, dsty,
width, height);
return xsBitBlitHelper(pGC);
}
RegionPtr xsCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
GCPtr pGC, int srcx, int srcy, int width, int height,
int dstx, int dsty, unsigned long plane)
{
XCBCopyPlane(xsConnection,
XS_DRAWABLE_ID(pSrcDrawable),
XS_DRAWABLE_ID(pDstDrawable),
XS_GC_PRIV(pGC)->gc,
srcx, srcy,
dstx, dsty,
width, height,
plane);
return xsBitBlitHelper(pGC);
}
void xsPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints,
DDXPointPtr pPoints)
{
XCBPolyPoint(xsConnection,
mode,
XS_DRAWABLE_ID(pDrawable),
XS_GC_PRIV(pGC)->gc,
nPoints,
(XCBPOINT *)pPoints);
}
void xsPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints,
DDXPointPtr pPoints)
{
XCBPolyLine(xsConnection,
mode,
XS_DRAWABLE_ID(pDrawable),
XS_GC_PRIV(pGC)->gc,
nPoints,
(XCBPOINT *)pPoints);
}
void xsPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nSegments,
xSegment *pSegments)
{
XCBPolySegment(xsConnection,
XS_DRAWABLE_ID(pDrawable),
XS_GC_PRIV(pGC)->gc,
nSegments,
(XCBSEGMENT *)pSegments);
}
void xsPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nRectangles,
xRectangle *pRectangles)
{
XCBPolyRectangle(xsConnection,
XS_DRAWABLE_ID(pDrawable),
XS_GC_PRIV(pGC)->gc,
nRectangles,
(XCBRECTANGLE *)pRectangles);
}
void xsPolyArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs)
{
XCBPolyArc(xsConnection,
XS_DRAWABLE_ID(pDrawable),
XS_GC_PRIV(pGC)->gc,
nArcs,
(XCBARC *)pArcs);
}
void xsFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, int mode,
int nPoints, DDXPointPtr pPoints)
{
XCBFillPoly(xsConnection,
XS_DRAWABLE_ID(pDrawable),
XS_GC_PRIV(pGC)->gc,
shape,
mode,
nPoints,
(XCBPOINT *)pPoints);
}
void xsPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nRectangles,
xRectangle *pRectangles)
{
XCBPolyFillRectangle(xsConnection,
XS_DRAWABLE_ID(pDrawable),
XS_GC_PRIV(pGC)->gc,
nRectangles,
(XCBRECTANGLE*)pRectangles);
}
void xsPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs)
{
XCBPolyFillArc(xsConnection,
XS_DRAWABLE_ID(pDrawable),
XS_GC_PRIV(pGC)->gc,
nArcs,
(XCBARC *)pArcs);
}
int xsPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, char *string)
{
#if 0
int width, i;
XCBCHAR2B *str;
XCBFONTABLE f;
XCBQueryTextExtentsCookie c;
XCBQueryTextExtentsRep *r;
XCBGenericError *e;
XCBPolyText8(xsConnection,
XS_DRAWABLE_ID(pDrawable),
XS_GC_PRIV(pGC)->gc,
x, y,
count,
(BYTE *)string);
f.font = xsFont(pGC->font);
f.gcontext = XS_GC_PRIV(pGC)->gc;
str = xalloc(count * sizeof(XCBCHAR2B));
for (i=0; i<count; i++) {
str[i].byte1 = string[i];
str[i].byte2 = '\0';
}
c = XCBQueryTextExtents(xsConnection, f, count, str);
xfree(str);
r = XCBQueryTextExtentsReply(xsConnection, c, NULL);
if (r)
if (!e)
width = r->overall_width;
/*handle error.. what's appropriate?*/
return width + x;
#endif
ErrorF("Would have printed %s\n", string);
}
int xsPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, unsigned short *string)
{
#if 0
int width = 0;
XCBFONTABLE f;
XCBQueryTextExtentsCookie c;
XCBQueryTextExtentsRep *r;
XCBGenericError *e;
XCBPolyText16(xsConnection,
XS_DRAWABLE_ID(pDrawable),
XS_GC_PRIV(pGC)->gc,
x, y,
count*2,
(BYTE *)string);
f.font = xsFont(pGC->font);
f.gcontext = XS_GC_PRIV(pGC)->gc;
c = XCBQueryTextExtents(xsConnection, f, count, (XCBCHAR2B*)string);
r = XCBQueryTextExtentsReply(xsConnection, c, &e);
if (r)
if (!e)
width = r->overall_width;
/*handle error.. what's appropriate?*/
return width + x;
#endif
ErrorF("Would have printed %s\n", string);
}
void xsImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
char *string)
{
XCBImageText8(xsConnection,
count,
XS_DRAWABLE_ID(pDrawable),
XS_GC_PRIV(pGC)->gc,
x, y,
string);
}
void xsImageText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, unsigned short *string)
{
XCBImageText16(xsConnection,
count,
XS_DRAWABLE_ID(pDrawable),
XS_GC_PRIV(pGC)->gc,
x, y,
(XCBCHAR2B *)string);
}
void xsImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
unsigned int nGlyphs, CharInfoPtr *pCharInfo,
pointer pGlyphBase)
{
ErrorF("xs warning: function xsImageGlyphBlt not implemented\n");
}
void xsPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
unsigned int nGlyphs, CharInfoPtr *pCharInfo,
pointer pGlyphBase)
{
ErrorF("xs warning: function xsPolyGlyphBlt not implemented\n");
}
void xsPushPixels(GCPtr pGC, PixmapPtr pBitmap, DrawablePtr pDst,
int width, int height, int x, int y)
{
XCBParamsGC param;
XCBRECTANGLE rect;
/* only works for solid bitmaps */
if (pGC->fillStyle == FillSolid)
{
param.stipple = XS_PIXMAP_PRIV(pBitmap)->pixmap.xid;
param.tile_stipple_originX = x;
param.tile_stipple_originY = y;
param.fill_style = XCBFillStyleStippled;
XCBAuxChangeGC(xsConnection, XS_GC_PRIV(pGC)->gc,
XCBGCStipple | XCBGCTileStippleOriginX | XCBGCTileStippleOriginY | XCBGCFillStyle,
¶m);
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
XCBPolyFillRectangle (xsConnection,
XS_DRAWABLE_ID(pDst),
XS_GC_PRIV(pGC)->gc,
1,
&rect);
param.fill_style = XCBFillStyleSolid;
XCBAuxChangeGC(xsConnection, XS_GC_PRIV(pGC)->gc,
XCBGCFillStyle,
¶m);
}
else
ErrorF("xs warning: function xsPushPixels not implemented\n");
}
|