Initial commit
[xorg_rtime.git] / xorg-server-1.4 / hw / xnest / GCOps.c
blobad9668ec1bb0a48d56d62a6ca4ef1b88fe07ed5f
1 /*
3 Copyright 1993 by Davor Matic
5 Permission to use, copy, modify, distribute, and sell this software
6 and its documentation for any purpose is hereby granted without fee,
7 provided that the above copyright notice appear in all copies and that
8 both that copyright notice and this permission notice appear in
9 supporting documentation. Davor Matic makes no representations about
10 the suitability of this software for any purpose. It is provided "as
11 is" without express or implied warranty.
15 #ifdef HAVE_XNEST_CONFIG_H
16 #include <xnest-config.h>
17 #endif
19 #include <X11/X.h>
20 #include <X11/Xproto.h>
21 #include "regionstr.h"
22 #include <X11/fonts/fontstruct.h>
23 #include "gcstruct.h"
24 #include "scrnintstr.h"
25 #include "windowstr.h"
26 #include "pixmapstr.h"
27 #include "region.h"
28 #include "servermd.h"
30 #include "Xnest.h"
32 #include "Display.h"
33 #include "Screen.h"
34 #include "XNGC.h"
35 #include "XNFont.h"
36 #include "GCOps.h"
37 #include "Drawable.h"
38 #include "Visual.h"
40 void
41 xnestFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans, xPoint *pPoints,
42 int *pWidths, int fSorted)
44 ErrorF("xnest warning: function xnestFillSpans not implemented\n");
47 void
48 xnestSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *pSrc,
49 xPoint *pPoints, int *pWidths, int nSpans, int fSorted)
51 ErrorF("xnest warning: function xnestSetSpans not implemented\n");
54 void
55 xnestGetSpans(DrawablePtr pDrawable, int maxWidth, DDXPointPtr pPoints,
56 int *pWidths, int nSpans, char *pBuffer)
58 ErrorF("xnest warning: function xnestGetSpans not implemented\n");
61 void
62 xnestQueryBestSize(int class, unsigned short *pWidth, unsigned short *pHeight,
63 ScreenPtr pScreen)
65 unsigned int width, height;
67 width = *pWidth;
68 height = *pHeight;
70 XQueryBestSize(xnestDisplay, class,
71 xnestDefaultWindows[pScreen->myNum],
72 width, height, &width, &height);
74 *pWidth = width;
75 *pHeight = height;
78 void
79 xnestPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
80 int w, int h, int leftPad, int format, char *pImage)
82 XImage *ximage;
84 ximage = XCreateImage(xnestDisplay, xnestDefaultVisual(pDrawable->pScreen),
85 depth, format, leftPad, (char *)pImage,
86 w, h, BitmapPad(xnestDisplay),
87 (format == ZPixmap) ?
88 PixmapBytePad(w, depth) : BitmapBytePad(w+leftPad));
90 if (ximage) {
91 XPutImage(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
92 ximage, 0, 0, x, y, w, h);
93 XFree(ximage);
97 void
98 xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
99 unsigned int format, unsigned long planeMask,
100 char *pImage)
102 XImage *ximage;
103 int length;
105 ximage = XGetImage(xnestDisplay, xnestDrawable(pDrawable),
106 x, y, w, h, planeMask, format);
108 if (ximage) {
109 length = ximage->bytes_per_line * ximage->height;
111 memmove(pImage, ximage->data, length);
113 XDestroyImage(ximage);
117 static Bool
118 xnestBitBlitPredicate(Display *display, XEvent *event, char *args)
120 return (event->type == GraphicsExpose || event->type == NoExpose);
123 static RegionPtr
124 xnestBitBlitHelper(GCPtr pGC)
126 if (!pGC->graphicsExposures)
127 return NullRegion;
128 else {
129 XEvent event;
130 RegionPtr pReg, pTmpReg;
131 BoxRec Box;
132 Bool pending, overlap;
134 pReg = REGION_CREATE(pGC->pScreen, NULL, 1);
135 pTmpReg = REGION_CREATE(pGC->pScreen, NULL, 1);
136 if(!pReg || !pTmpReg) return NullRegion;
138 pending = True;
139 while (pending) {
140 XIfEvent(xnestDisplay, &event, xnestBitBlitPredicate, NULL);
142 switch (event.type) {
143 case NoExpose:
144 pending = False;
145 break;
147 case GraphicsExpose:
148 Box.x1 = event.xgraphicsexpose.x;
149 Box.y1 = event.xgraphicsexpose.y;
150 Box.x2 = event.xgraphicsexpose.x + event.xgraphicsexpose.width;
151 Box.y2 = event.xgraphicsexpose.y + event.xgraphicsexpose.height;
152 REGION_RESET(pGC->pScreen, pTmpReg, &Box);
153 REGION_APPEND(pGC->pScreen, pReg, pTmpReg);
154 pending = event.xgraphicsexpose.count;
155 break;
159 REGION_DESTROY(pGC->pScreen, pTmpReg);
160 REGION_VALIDATE(pGC->pScreen, pReg, &overlap);
161 return(pReg);
165 RegionPtr
166 xnestCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
167 GCPtr pGC, int srcx, int srcy, int width, int height,
168 int dstx, int dsty)
170 XCopyArea(xnestDisplay,
171 xnestDrawable(pSrcDrawable), xnestDrawable(pDstDrawable),
172 xnestGC(pGC), srcx, srcy, width, height, dstx, dsty);
174 return xnestBitBlitHelper(pGC);
177 RegionPtr
178 xnestCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
179 GCPtr pGC, int srcx, int srcy, int width, int height,
180 int dstx, int dsty, unsigned long plane)
182 XCopyPlane(xnestDisplay,
183 xnestDrawable(pSrcDrawable), xnestDrawable(pDstDrawable),
184 xnestGC(pGC), srcx, srcy, width, height, dstx, dsty, plane);
186 return xnestBitBlitHelper(pGC);
189 void
190 xnestPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints,
191 DDXPointPtr pPoints)
193 XDrawPoints(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
194 (XPoint *)pPoints, nPoints, mode);
197 void
198 xnestPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints,
199 DDXPointPtr pPoints)
201 XDrawLines(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
202 (XPoint *)pPoints, nPoints, mode);
205 void
206 xnestPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nSegments,
207 xSegment *pSegments)
209 XDrawSegments(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
210 (XSegment *)pSegments, nSegments);
213 void
214 xnestPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nRectangles,
215 xRectangle *pRectangles)
217 XDrawRectangles(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
218 (XRectangle *)pRectangles, nRectangles);
221 void
222 xnestPolyArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs)
224 XDrawArcs(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
225 (XArc *)pArcs, nArcs);
228 void
229 xnestFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, int mode,
230 int nPoints, DDXPointPtr pPoints)
232 XFillPolygon(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
233 (XPoint *)pPoints, nPoints, shape, mode);
236 void
237 xnestPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nRectangles,
238 xRectangle *pRectangles)
240 XFillRectangles(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
241 (XRectangle *)pRectangles, nRectangles);
244 void
245 xnestPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs)
247 XFillArcs(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
248 (XArc *)pArcs, nArcs);
252 xnestPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
253 char *string)
255 int width;
257 XDrawString(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
258 x, y, string, count);
260 width = XTextWidth(xnestFontStruct(pGC->font), string, count);
262 return width + x;
266 xnestPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
267 unsigned short *string)
269 int width;
271 XDrawString16(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
272 x, y, (XChar2b *)string, count);
274 width = XTextWidth16(xnestFontStruct(pGC->font), (XChar2b *)string, count);
276 return width + x;
279 void
280 xnestImageText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
281 char *string)
283 XDrawImageString(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
284 x, y, string, count);
287 void
288 xnestImageText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count,
289 unsigned short *string)
291 XDrawImageString16(xnestDisplay, xnestDrawable(pDrawable), xnestGC(pGC),
292 x, y, (XChar2b *)string, count);
295 void
296 xnestImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
297 unsigned int nGlyphs, CharInfoPtr *pCharInfo,
298 pointer pGlyphBase)
300 ErrorF("xnest warning: function xnestImageGlyphBlt not implemented\n");
303 void
304 xnestPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
305 unsigned int nGlyphs, CharInfoPtr *pCharInfo,
306 pointer pGlyphBase)
308 ErrorF("xnest warning: function xnestPolyGlyphBlt not implemented\n");
311 void
312 xnestPushPixels(GCPtr pGC, PixmapPtr pBitmap, DrawablePtr pDst,
313 int width, int height, int x, int y)
315 /* only works for solid bitmaps */
316 if (pGC->fillStyle == FillSolid)
318 XSetStipple (xnestDisplay, xnestGC(pGC), xnestPixmap(pBitmap));
319 XSetTSOrigin (xnestDisplay, xnestGC(pGC), x, y);
320 XSetFillStyle (xnestDisplay, xnestGC(pGC), FillStippled);
321 XFillRectangle (xnestDisplay, xnestDrawable(pDst),
322 xnestGC(pGC), x, y, width, height);
323 XSetFillStyle (xnestDisplay, xnestGC(pGC), FillSolid);
325 else
326 ErrorF("xnest warning: function xnestPushPixels not implemented\n");