First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / rac / xf86RAC.c
blobaba86226e51cb79462eb54cca753c969c959dae3
1 #ifdef HAVE_XORG_CONFIG_H
2 #include <xorg-config.h>
3 #endif
5 #include "misc.h"
6 #include "xf86.h"
7 #include "xf86_OSproc.h"
9 #include <X11/X.h>
10 #include "colormapst.h"
11 #include "scrnintstr.h"
12 #include "screenint.h"
13 #include "gcstruct.h"
14 #include "pixmapstr.h"
15 #include "pixmap.h"
16 #include "windowstr.h"
17 #include "window.h"
18 #include "xf86str.h"
19 #include "xf86RAC.h"
20 #include "mipointer.h"
21 #include "mipointrst.h"
22 #ifdef RENDER
23 # include "picturestr.h"
24 #endif
26 #ifdef DEBUG
27 #define DPRINT_S(x,y) ErrorF(x ": %i\n",y);
28 #define DPRINT(x) ErrorF(x "\n");
29 #else
30 #define DPRINT_S(x,y)
31 #define DPRINT(x)
32 #endif
34 #define WRAP_SCREEN(x,y) {pScreenPriv->x = pScreen->x;\
35 pScreen->x = y;}
36 #define WRAP_SCREEN_COND(x,y,cond) \
37 {pScreenPriv->x = pScreen->x;\
38 if (flag & (cond))\
39 pScreen->x = y;}
40 #define UNWRAP_SCREEN(x) pScreen->x = pScreenPriv->x
42 #define SCREEN_PROLOG(x) \
43 pScreen->x = \
44 ((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr)->x
45 #define SCREEN_EPILOG(x,y) pScreen->x = y;
47 #define WRAP_PICT_COND(x,y,cond) if (ps)\
48 {pScreenPriv->x = ps->x;\
49 if (flag & (cond))\
50 ps->x = y;}
51 #define UNWRAP_PICT(x) if (ps) {ps->x = pScreenPriv->x;}
53 #define PICTURE_PROLOGUE(field) \
54 ps->field = \
55 ((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr)->field
56 #define PICTURE_EPILOGUE(field, wrap) \
57 ps->field = wrap
59 #define WRAP_SCREEN_INFO(x,y) {pScreenPriv->x = pScrn->x;\
60 pScrn->x = y;}
61 #define WRAP_SCREEN_INFO_COND(x,y,cond) \
62 {pScreenPriv->x = pScrn->x;\
63 if (flag & (cond))\
64 pScrn->x = y;}
65 #define UNWRAP_SCREEN_INFO(x) pScrn->x = pScreenPriv->x
67 #define SPRITE_PROLOG miPointerScreenPtr PointPriv = \
68 (miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr;\
69 RACScreenPtr pScreenPriv = \
70 ((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr);\
71 PointPriv->spriteFuncs = pScreenPriv->miSprite;
72 #define SPRITE_EPILOG pScreenPriv->miSprite = PointPriv->spriteFuncs;\
73 PointPriv->spriteFuncs = &RACSpriteFuncs;
74 #define WRAP_SPRITE_COND(cond){pScreenPriv->miSprite = PointPriv->spriteFuncs;\
75 if(flag & (cond))\
76 PointPriv->spriteFuncs = &RACSpriteFuncs;}
77 #define UNWRAP_SPRITE PointPriv->spriteFuncs = pScreenPriv->miSprite
80 #define GC_WRAP(x) pGCPriv->wrapOps = (x)->ops;\
81 pGCPriv->wrapFuncs = (x)->funcs;\
82 (x)->ops = &RACGCOps;\
83 (x)->funcs = &RACGCFuncs;
84 #define GC_UNWRAP(x)\
85 RACGCPtr pGCPriv = (RACGCPtr) (x)->devPrivates[RACGCIndex].ptr;\
86 (x)->ops = pGCPriv->wrapOps;\
87 (x)->funcs = pGCPriv->wrapFuncs;
89 #define GC_SCREEN register ScrnInfoPtr pScrn \
90 = xf86Screens[pGC->pScreen->myNum]
92 #define ENABLE xf86EnableAccess(xf86Screens[pScreen->myNum])
93 #define ENABLE_GC xf86EnableAccess(xf86Screens[pGC->pScreen->myNum])
95 typedef struct _RACScreen {
96 CreateGCProcPtr CreateGC;
97 CloseScreenProcPtr CloseScreen;
98 GetImageProcPtr GetImage;
99 GetSpansProcPtr GetSpans;
100 SourceValidateProcPtr SourceValidate;
101 PaintWindowBackgroundProcPtr PaintWindowBackground;
102 PaintWindowBorderProcPtr PaintWindowBorder;
103 CopyWindowProcPtr CopyWindow;
104 ClearToBackgroundProcPtr ClearToBackground;
105 BSFuncRec BackingStoreFuncs;
106 CreatePixmapProcPtr CreatePixmap;
107 SaveScreenProcPtr SaveScreen;
108 /* Colormap */
109 StoreColorsProcPtr StoreColors;
110 /* Cursor */
111 DisplayCursorProcPtr DisplayCursor;
112 RealizeCursorProcPtr RealizeCursor;
113 UnrealizeCursorProcPtr UnrealizeCursor;
114 RecolorCursorProcPtr RecolorCursor;
115 SetCursorPositionProcPtr SetCursorPosition;
116 void (*AdjustFrame)(int,int,int,int);
117 Bool (*SwitchMode)(int, DisplayModePtr,int);
118 Bool (*EnterVT)(int, int);
119 void (*LeaveVT)(int, int);
120 void (*FreeScreen)(int, int);
121 miPointerSpriteFuncPtr miSprite;
122 #ifdef RENDER
123 CompositeProcPtr Composite;
124 GlyphsProcPtr Glyphs;
125 CompositeRectsProcPtr CompositeRects;
126 #endif
127 } RACScreenRec, *RACScreenPtr;
129 typedef struct _RACGC {
130 GCOps *wrapOps;
131 GCFuncs *wrapFuncs;
132 } RACGCRec, *RACGCPtr;
134 /* Screen funcs */
135 static Bool RACCloseScreen (int i, ScreenPtr pScreen);
136 static void RACGetImage (DrawablePtr pDrawable, int sx, int sy,
137 int w, int h, unsigned int format,
138 unsigned long planemask, char *pdstLine);
139 static void RACGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
140 int *pwidth, int nspans, char *pdstStart);
141 static void RACSourceValidate (DrawablePtr pDrawable,
142 int x, int y, int width, int height );
143 static void RACPaintWindowBackground(WindowPtr pWin, RegionPtr prgn, int what);
144 static void RACPaintWindowBorder(WindowPtr pWin, RegionPtr prgn, int what);
145 static void RACCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
146 RegionPtr prgnSrc );
147 static void RACClearToBackground (WindowPtr pWin, int x, int y,
148 int w, int h, Bool generateExposures );
149 static void RACSaveAreas (PixmapPtr pPixmap, RegionPtr prgnSave,
150 int xorg, int yorg, WindowPtr pWin);
151 static void RACRestoreAreas (PixmapPtr pPixmap, RegionPtr prgnRestore,
152 int xorg, int yorg, WindowPtr pWin);
153 static PixmapPtr RACCreatePixmap(ScreenPtr pScreen, int w, int h, int depth);
154 static Bool RACCreateGC(GCPtr pGC);
155 static Bool RACSaveScreen(ScreenPtr pScreen, Bool unblank);
156 static void RACStoreColors (ColormapPtr pmap, int ndef, xColorItem *pdefs);
157 static void RACRecolorCursor (ScreenPtr pScreen, CursorPtr pCurs,
158 Bool displayed);
159 static Bool RACRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor);
160 static Bool RACUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor);
161 static Bool RACDisplayCursor (ScreenPtr pScreen, CursorPtr pCursor);
162 static Bool RACSetCursorPosition (ScreenPtr pScreen, int x, int y,
163 Bool generateEvent);
164 static void RACAdjustFrame(int index, int x, int y, int flags);
165 static Bool RACSwitchMode(int index, DisplayModePtr mode, int flags);
166 static Bool RACEnterVT(int index, int flags);
167 static void RACLeaveVT(int index, int flags);
168 static void RACFreeScreen(int index, int flags);
169 /* GC funcs */
170 static void RACValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw);
171 static void RACChangeGC(GCPtr pGC, unsigned long mask);
172 static void RACCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
173 static void RACDestroyGC(GCPtr pGC);
174 static void RACChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects);
175 static void RACDestroyClip(GCPtr pGC);
176 static void RACCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
177 /* GC ops */
178 static void RACFillSpans( DrawablePtr pDraw, GC *pGC, int nInit,
179 DDXPointPtr pptInit, int *pwidthInit, int fSorted );
180 static void RACSetSpans(DrawablePtr pDraw, GCPtr pGC, char *pcharsrc,
181 register DDXPointPtr ppt, int *pwidth, int nspans,
182 int fSorted );
183 static void RACPutImage(DrawablePtr pDraw, GCPtr pGC, int depth,
184 int x, int y, int w, int h, int leftPad,
185 int format, char *pImage );
186 static RegionPtr RACCopyArea(DrawablePtr pSrc, DrawablePtr pDst,
187 GC *pGC, int srcx, int srcy,
188 int width, int height,
189 int dstx, int dsty );
190 static RegionPtr RACCopyPlane(DrawablePtr pSrc, DrawablePtr pDst,
191 GCPtr pGC, int srcx, int srcy,
192 int width, int height, int dstx, int dsty,
193 unsigned long bitPlane );
194 static void RACPolyPoint(DrawablePtr pDraw, GCPtr pGC, int mode,
195 int npt, xPoint *pptInit );
196 static void RACPolylines(DrawablePtr pDraw, GCPtr pGC, int mode,
197 int npt, DDXPointPtr pptInit );
198 static void RACPolySegment(DrawablePtr pDraw, GCPtr pGC, int nseg,
199 xSegment *pSeg );
200 static void RACPolyRectangle(DrawablePtr pDraw, GCPtr pGC, int nRectsInit,
201 xRectangle *pRectsInit );
202 static void RACPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
203 xArc *parcs );
204 static void RACFillPolygon(DrawablePtr pDraw, GCPtr pGC, int shape, int mode,
205 int count, DDXPointPtr ptsIn );
206 static void RACPolyFillRect( DrawablePtr pDraw, GCPtr pGC, int nrectFill,
207 xRectangle *prectInit );
208 static void RACPolyFillArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
209 xArc *parcs );
210 static int RACPolyText8(DrawablePtr pDraw, GCPtr pGC, int x, int y,
211 int count, char *chars );
212 static int RACPolyText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
213 int count, unsigned short *chars );
214 static void RACImageText8(DrawablePtr pDraw, GCPtr pGC, int x, int y,
215 int count, char *chars );
216 static void RACImageText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
217 int count, unsigned short *chars );
218 static void RACImageGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int xInit,
219 int yInit, unsigned int nglyph,
220 CharInfoPtr *ppci, pointer pglyphBase );
221 static void RACPolyGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int xInit,
222 int yInit, unsigned int nglyph,
223 CharInfoPtr *ppci, pointer pglyphBase );
224 static void RACPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDraw,
225 int dx, int dy, int xOrg, int yOrg );
226 /* miSpriteFuncs */
227 static Bool RACSpriteRealizeCursor(ScreenPtr pScreen, CursorPtr pCur);
228 static Bool RACSpriteUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCur);
229 static void RACSpriteSetCursor(ScreenPtr pScreen, CursorPtr pCur,
230 int x, int y);
231 static void RACSpriteMoveCursor(ScreenPtr pScreen, int x, int y);
232 #ifdef RENDER
233 static void RACComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
234 PicturePtr pDst, INT16 xSrc, INT16 ySrc,
235 INT16 xMask, INT16 yMask, INT16 xDst,
236 INT16 yDst, CARD16 width, CARD16 height);
237 static void RACGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
238 PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
239 int nlist, GlyphListPtr list, GlyphPtr *glyphs);
240 static void RACCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color,
241 int nRect, xRectangle *rects);
242 #endif
244 static GCFuncs RACGCFuncs = {
245 RACValidateGC, RACChangeGC, RACCopyGC, RACDestroyGC,
246 RACChangeClip, RACDestroyClip, RACCopyClip
249 static GCOps RACGCOps = {
250 RACFillSpans, RACSetSpans, RACPutImage, RACCopyArea,
251 RACCopyPlane, RACPolyPoint, RACPolylines, RACPolySegment,
252 RACPolyRectangle, RACPolyArc, RACFillPolygon, RACPolyFillRect,
253 RACPolyFillArc, RACPolyText8, RACPolyText16, RACImageText8,
254 RACImageText16, RACImageGlyphBlt, RACPolyGlyphBlt, RACPushPixels,
255 {NULL} /* devPrivate */
258 static miPointerSpriteFuncRec RACSpriteFuncs = {
259 RACSpriteRealizeCursor, RACSpriteUnrealizeCursor, RACSpriteSetCursor,
260 RACSpriteMoveCursor
263 static int RACScreenIndex = -1;
264 static int RACGCIndex = -1;
265 static unsigned long RACGeneration = 0;
268 Bool
269 xf86RACInit(ScreenPtr pScreen, unsigned int flag)
271 ScrnInfoPtr pScrn;
272 RACScreenPtr pScreenPriv;
273 miPointerScreenPtr PointPriv;
274 #ifdef RENDER
275 PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
276 #endif
278 pScrn = xf86Screens[pScreen->myNum];
279 PointPriv = (miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr;
281 DPRINT_S("RACInit",pScreen->myNum);
282 if (RACGeneration != serverGeneration) {
283 if ( ((RACScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
284 ((RACGCIndex = AllocateGCPrivateIndex()) < 0))
285 return FALSE;
287 RACGeneration = serverGeneration;
290 if (!AllocateGCPrivate(pScreen, RACGCIndex, sizeof(RACGCRec)))
291 return FALSE;
293 if (!(pScreenPriv = xalloc(sizeof(RACScreenRec))))
294 return FALSE;
296 pScreen->devPrivates[RACScreenIndex].ptr = (pointer)pScreenPriv;
298 WRAP_SCREEN(CloseScreen, RACCloseScreen);
299 WRAP_SCREEN(SaveScreen, RACSaveScreen);
300 WRAP_SCREEN_COND(CreateGC, RACCreateGC, RAC_FB);
301 WRAP_SCREEN_COND(GetImage, RACGetImage, RAC_FB);
302 WRAP_SCREEN_COND(GetSpans, RACGetSpans, RAC_FB);
303 WRAP_SCREEN_COND(SourceValidate, RACSourceValidate, RAC_FB);
304 WRAP_SCREEN_COND(PaintWindowBackground, RACPaintWindowBackground, RAC_FB);
305 WRAP_SCREEN_COND(PaintWindowBorder, RACPaintWindowBorder, RAC_FB);
306 WRAP_SCREEN_COND(CopyWindow, RACCopyWindow, RAC_FB);
307 WRAP_SCREEN_COND(ClearToBackground, RACClearToBackground, RAC_FB);
308 WRAP_SCREEN_COND(CreatePixmap, RACCreatePixmap, RAC_FB);
309 WRAP_SCREEN_COND(BackingStoreFuncs.RestoreAreas, RACRestoreAreas, RAC_FB);
310 WRAP_SCREEN_COND(BackingStoreFuncs.SaveAreas, RACSaveAreas, RAC_FB);
311 WRAP_SCREEN_COND(StoreColors, RACStoreColors, RAC_COLORMAP);
312 WRAP_SCREEN_COND(DisplayCursor, RACDisplayCursor, RAC_CURSOR);
313 WRAP_SCREEN_COND(RealizeCursor, RACRealizeCursor, RAC_CURSOR);
314 WRAP_SCREEN_COND(UnrealizeCursor, RACUnrealizeCursor, RAC_CURSOR);
315 WRAP_SCREEN_COND(RecolorCursor, RACRecolorCursor, RAC_CURSOR);
316 WRAP_SCREEN_COND(SetCursorPosition, RACSetCursorPosition, RAC_CURSOR);
317 #ifdef RENDER
318 WRAP_PICT_COND(Composite,RACComposite,RAC_FB);
319 WRAP_PICT_COND(Glyphs,RACGlyphs,RAC_FB);
320 WRAP_PICT_COND(CompositeRects,RACCompositeRects,RAC_FB);
321 #endif
322 WRAP_SCREEN_INFO_COND(AdjustFrame, RACAdjustFrame, RAC_VIEWPORT);
323 WRAP_SCREEN_INFO(SwitchMode, RACSwitchMode);
324 WRAP_SCREEN_INFO(EnterVT, RACEnterVT);
325 WRAP_SCREEN_INFO(LeaveVT, RACLeaveVT);
326 WRAP_SCREEN_INFO(FreeScreen, RACFreeScreen);
327 WRAP_SPRITE_COND(RAC_CURSOR);
329 return TRUE;
332 /* Screen funcs */
333 static Bool
334 RACCloseScreen (int i, ScreenPtr pScreen)
336 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
337 RACScreenPtr pScreenPriv =
338 (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
339 miPointerScreenPtr PointPriv
340 = (miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr;
341 #ifdef RENDER
342 PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
343 #endif
345 DPRINT_S("RACCloseScreen",pScreen->myNum);
346 UNWRAP_SCREEN(CreateGC);
347 UNWRAP_SCREEN(CloseScreen);
348 UNWRAP_SCREEN(GetImage);
349 UNWRAP_SCREEN(GetSpans);
350 UNWRAP_SCREEN(SourceValidate);
351 UNWRAP_SCREEN(PaintWindowBackground);
352 UNWRAP_SCREEN(PaintWindowBorder);
353 UNWRAP_SCREEN(CopyWindow);
354 UNWRAP_SCREEN(ClearToBackground);
355 UNWRAP_SCREEN(BackingStoreFuncs.RestoreAreas);
356 UNWRAP_SCREEN(BackingStoreFuncs.SaveAreas);
357 UNWRAP_SCREEN(SaveScreen);
358 UNWRAP_SCREEN(StoreColors);
359 UNWRAP_SCREEN(DisplayCursor);
360 UNWRAP_SCREEN(RealizeCursor);
361 UNWRAP_SCREEN(UnrealizeCursor);
362 UNWRAP_SCREEN(RecolorCursor);
363 UNWRAP_SCREEN(SetCursorPosition);
364 #ifdef RENDER
365 UNWRAP_PICT(Composite);
366 UNWRAP_PICT(Glyphs);
367 UNWRAP_PICT(CompositeRects);
368 #endif
369 UNWRAP_SCREEN_INFO(AdjustFrame);
370 UNWRAP_SCREEN_INFO(SwitchMode);
371 UNWRAP_SCREEN_INFO(EnterVT);
372 UNWRAP_SCREEN_INFO(LeaveVT);
373 UNWRAP_SCREEN_INFO(FreeScreen);
374 UNWRAP_SPRITE;
376 xfree ((pointer) pScreenPriv);
378 if (xf86Screens[pScreen->myNum]->vtSema) {
379 xf86EnterServerState(SETUP);
380 ENABLE;
382 return (*pScreen->CloseScreen) (i, pScreen);
385 static void
386 RACGetImage (
387 DrawablePtr pDrawable,
388 int sx, int sy, int w, int h,
389 unsigned int format,
390 unsigned long planemask,
391 char *pdstLine
394 ScreenPtr pScreen = pDrawable->pScreen;
395 DPRINT_S("RACGetImage",pScreen->myNum);
396 SCREEN_PROLOG(GetImage);
397 if (xf86Screens[pScreen->myNum]->vtSema) {
398 ENABLE;
400 (*pScreen->GetImage) (pDrawable, sx, sy, w, h,
401 format, planemask, pdstLine);
402 SCREEN_EPILOG (GetImage, RACGetImage);
405 static void
406 RACGetSpans (
407 DrawablePtr pDrawable,
408 int wMax,
409 DDXPointPtr ppt,
410 int *pwidth,
411 int nspans,
412 char *pdstStart
415 ScreenPtr pScreen = pDrawable->pScreen;
417 DPRINT_S("RACGetSpans",pScreen->myNum);
418 SCREEN_PROLOG (GetSpans);
419 ENABLE;
420 (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
421 SCREEN_EPILOG (GetSpans, RACGetSpans);
424 static void
425 RACSourceValidate (
426 DrawablePtr pDrawable,
427 int x, int y, int width, int height )
429 ScreenPtr pScreen = pDrawable->pScreen;
430 DPRINT_S("RACSourceValidate",pScreen->myNum);
431 SCREEN_PROLOG (SourceValidate);
432 ENABLE;
433 if (pScreen->SourceValidate)
434 (*pScreen->SourceValidate) (pDrawable, x, y, width, height);
435 SCREEN_EPILOG (SourceValidate, RACSourceValidate);
438 static void
439 RACPaintWindowBackground(
440 WindowPtr pWin,
441 RegionPtr prgn,
442 int what
445 ScreenPtr pScreen = pWin->drawable.pScreen;
447 DPRINT_S("RACPaintWindowBackground",pScreen->myNum);
448 SCREEN_PROLOG (PaintWindowBackground);
449 ENABLE;
450 (*pScreen->PaintWindowBackground) (pWin, prgn, what);
451 SCREEN_EPILOG (PaintWindowBackground, RACPaintWindowBackground);
454 static void
455 RACPaintWindowBorder(
456 WindowPtr pWin,
457 RegionPtr prgn,
458 int what
461 ScreenPtr pScreen = pWin->drawable.pScreen;
463 DPRINT_S("RACPaintWindowBorder",pScreen->myNum);
464 SCREEN_PROLOG (PaintWindowBorder);
465 ENABLE;
466 (*pScreen->PaintWindowBorder) (pWin, prgn, what);
467 SCREEN_EPILOG (PaintWindowBorder, RACPaintWindowBorder);
470 static void
471 RACCopyWindow(
472 WindowPtr pWin,
473 DDXPointRec ptOldOrg,
474 RegionPtr prgnSrc )
476 ScreenPtr pScreen = pWin->drawable.pScreen;
478 DPRINT_S("RACCopyWindow",pScreen->myNum);
479 SCREEN_PROLOG (CopyWindow);
480 ENABLE;
481 (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
482 SCREEN_EPILOG (CopyWindow, RACCopyWindow);
485 static void
486 RACClearToBackground (
487 WindowPtr pWin,
488 int x, int y,
489 int w, int h,
490 Bool generateExposures )
492 ScreenPtr pScreen = pWin->drawable.pScreen;
494 DPRINT_S("RACClearToBackground",pScreen->myNum);
495 SCREEN_PROLOG ( ClearToBackground);
496 ENABLE;
497 (*pScreen->ClearToBackground) (pWin, x, y, w, h, generateExposures);
498 SCREEN_EPILOG (ClearToBackground, RACClearToBackground);
501 static void
502 RACSaveAreas (
503 PixmapPtr pPixmap,
504 RegionPtr prgnSave,
505 int xorg,
506 int yorg,
507 WindowPtr pWin
510 ScreenPtr pScreen = pPixmap->drawable.pScreen;
511 DPRINT_S("RACSaveAreas",pScreen->myNum);
512 SCREEN_PROLOG (BackingStoreFuncs.SaveAreas);
513 ENABLE;
514 (*pScreen->BackingStoreFuncs.SaveAreas) (
515 pPixmap, prgnSave, xorg, yorg, pWin);
517 SCREEN_EPILOG (BackingStoreFuncs.SaveAreas, RACSaveAreas);
520 static void
521 RACRestoreAreas (
522 PixmapPtr pPixmap,
523 RegionPtr prgnRestore,
524 int xorg,
525 int yorg,
526 WindowPtr pWin
529 ScreenPtr pScreen = pPixmap->drawable.pScreen;
531 DPRINT_S("RACRestoreAreas",pScreen->myNum);
532 SCREEN_PROLOG (BackingStoreFuncs.RestoreAreas);
533 ENABLE;
534 (*pScreen->BackingStoreFuncs.RestoreAreas) (
535 pPixmap, prgnRestore, xorg, yorg, pWin);
537 SCREEN_EPILOG ( BackingStoreFuncs.RestoreAreas, RACRestoreAreas);
540 static PixmapPtr
541 RACCreatePixmap(ScreenPtr pScreen, int w, int h, int depth)
543 PixmapPtr pPix;
545 DPRINT_S("RACCreatePixmap",pScreen->myNum);
546 SCREEN_PROLOG ( CreatePixmap);
547 ENABLE;
548 pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth);
549 SCREEN_EPILOG (CreatePixmap, RACCreatePixmap);
551 return pPix;
554 static Bool
555 RACSaveScreen(ScreenPtr pScreen, Bool unblank)
557 Bool val;
559 DPRINT_S("RACSaveScreen",pScreen->myNum);
560 SCREEN_PROLOG (SaveScreen);
561 ENABLE;
562 val = (*pScreen->SaveScreen) (pScreen, unblank);
563 SCREEN_EPILOG (SaveScreen, RACSaveScreen);
565 return val;
568 static void
569 RACStoreColors (
570 ColormapPtr pmap,
571 int ndef,
572 xColorItem *pdefs)
574 ScreenPtr pScreen = pmap->pScreen;
576 DPRINT_S("RACStoreColors",pScreen->myNum);
577 SCREEN_PROLOG (StoreColors);
578 ENABLE;
579 (*pScreen->StoreColors) (pmap,ndef,pdefs);
581 SCREEN_EPILOG ( StoreColors, RACStoreColors);
584 static void
585 RACRecolorCursor (
586 ScreenPtr pScreen,
587 CursorPtr pCurs,
588 Bool displayed
591 DPRINT_S("RACRecolorCursor",pScreen->myNum);
592 SCREEN_PROLOG (RecolorCursor);
593 ENABLE;
594 (*pScreen->RecolorCursor) (pScreen,pCurs,displayed);
596 SCREEN_EPILOG ( RecolorCursor, RACRecolorCursor);
599 static Bool
600 RACRealizeCursor (
601 ScreenPtr pScreen,
602 CursorPtr pCursor
605 Bool val;
607 DPRINT_S("RACRealizeCursor",pScreen->myNum);
608 SCREEN_PROLOG (RealizeCursor);
609 ENABLE;
610 val = (*pScreen->RealizeCursor) (pScreen,pCursor);
612 SCREEN_EPILOG ( RealizeCursor, RACRealizeCursor);
613 return val;
616 static Bool
617 RACUnrealizeCursor (
618 ScreenPtr pScreen,
619 CursorPtr pCursor
622 Bool val;
624 DPRINT_S("RACUnrealizeCursor",pScreen->myNum);
625 SCREEN_PROLOG (UnrealizeCursor);
626 ENABLE;
627 val = (*pScreen->UnrealizeCursor) (pScreen,pCursor);
629 SCREEN_EPILOG ( UnrealizeCursor, RACUnrealizeCursor);
630 return val;
633 static Bool
634 RACDisplayCursor (
635 ScreenPtr pScreen,
636 CursorPtr pCursor
639 Bool val;
641 DPRINT_S("RACDisplayCursor",pScreen->myNum);
642 SCREEN_PROLOG (DisplayCursor);
643 ENABLE;
644 val = (*pScreen->DisplayCursor) (pScreen,pCursor);
646 SCREEN_EPILOG ( DisplayCursor, RACDisplayCursor);
647 return val;
650 static Bool
651 RACSetCursorPosition (
652 ScreenPtr pScreen,
653 int x, int y,
654 Bool generateEvent)
656 Bool val;
658 DPRINT_S("RACSetCursorPosition",pScreen->myNum);
659 SCREEN_PROLOG (SetCursorPosition);
660 ENABLE;
661 val = (*pScreen->SetCursorPosition) (pScreen,x,y,generateEvent);
663 SCREEN_EPILOG ( SetCursorPosition, RACSetCursorPosition);
664 return val;
667 static void
668 RACAdjustFrame(int index, int x, int y, int flags)
670 ScreenPtr pScreen = screenInfo.screens[index];
671 RACScreenPtr pScreenPriv =
672 (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
674 DPRINT_S("RACAdjustFrame",index);
675 xf86EnableAccess(xf86Screens[index]);
677 (*pScreenPriv->AdjustFrame)(index, x, y, flags);
680 static Bool
681 RACSwitchMode(int index, DisplayModePtr mode, int flags)
683 ScreenPtr pScreen = screenInfo.screens[index];
684 RACScreenPtr pScreenPriv =
685 (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
687 DPRINT_S("RACSwitchMode",index);
688 xf86EnableAccess(xf86Screens[index]);
690 return (*pScreenPriv->SwitchMode)(index, mode, flags);
693 static Bool
694 RACEnterVT(int index, int flags)
696 ScreenPtr pScreen = screenInfo.screens[index];
697 RACScreenPtr pScreenPriv =
698 (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
700 DPRINT_S("RACEnterVT",index);
701 xf86EnableAccess(xf86Screens[index]);
703 return (*pScreenPriv->EnterVT)(index, flags);
706 static void
707 RACLeaveVT(int index, int flags)
709 ScreenPtr pScreen = screenInfo.screens[index];
710 RACScreenPtr pScreenPriv =
711 (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
713 DPRINT_S("RACLeaveVT",index);
714 xf86EnableAccess(xf86Screens[index]);
716 (*pScreenPriv->LeaveVT)(index, flags);
719 static void
720 RACFreeScreen(int index, int flags)
722 ScreenPtr pScreen = screenInfo.screens[index];
723 RACScreenPtr pScreenPriv =
724 (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
726 DPRINT_S("RACFreeScreen",index);
727 xf86EnableAccess(xf86Screens[index]);
729 (*pScreenPriv->FreeScreen)(index, flags);
732 static Bool
733 RACCreateGC(GCPtr pGC)
735 ScreenPtr pScreen = pGC->pScreen;
736 RACGCPtr pGCPriv = (RACGCPtr) (pGC)->devPrivates[RACGCIndex].ptr;
737 Bool ret;
739 DPRINT_S("RACCreateGC",pScreen->myNum);
740 SCREEN_PROLOG(CreateGC);
742 ret = (*pScreen->CreateGC)(pGC);
744 GC_WRAP(pGC);
745 SCREEN_EPILOG(CreateGC,RACCreateGC);
747 return ret;
750 /* GC funcs */
751 static void
752 RACValidateGC(
753 GCPtr pGC,
754 unsigned long changes,
755 DrawablePtr pDraw )
757 GC_UNWRAP(pGC);
758 DPRINT("RACValidateGC");
759 (*pGC->funcs->ValidateGC)(pGC, changes, pDraw);
760 GC_WRAP(pGC);
764 static void
765 RACDestroyGC(GCPtr pGC)
767 GC_UNWRAP (pGC);
768 DPRINT("RACDestroyGC");
769 (*pGC->funcs->DestroyGC)(pGC);
770 GC_WRAP (pGC);
773 static void
774 RACChangeGC (
775 GCPtr pGC,
776 unsigned long mask)
778 GC_UNWRAP (pGC);
779 DPRINT("RACChangeGC");
780 (*pGC->funcs->ChangeGC) (pGC, mask);
781 GC_WRAP (pGC);
784 static void
785 RACCopyGC (
786 GCPtr pGCSrc,
787 unsigned long mask,
788 GCPtr pGCDst)
790 GC_UNWRAP (pGCDst);
791 DPRINT("RACCopyGC");
792 (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
793 GC_WRAP (pGCDst);
796 static void
797 RACChangeClip (
798 GCPtr pGC,
799 int type,
800 pointer pvalue,
801 int nrects )
803 GC_UNWRAP (pGC);
804 DPRINT("RACChangeClip");
805 (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
806 GC_WRAP (pGC);
809 static void
810 RACCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
812 GC_UNWRAP (pgcDst);
813 DPRINT("RACCopyClip");
814 (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
815 GC_WRAP (pgcDst);
818 static void
819 RACDestroyClip(GCPtr pGC)
821 GC_UNWRAP (pGC);
822 DPRINT("RACDestroyClip");
823 (* pGC->funcs->DestroyClip)(pGC);
824 GC_WRAP (pGC);
827 /* GC Ops */
828 static void
829 RACFillSpans(
830 DrawablePtr pDraw,
831 GC *pGC,
832 int nInit,
833 DDXPointPtr pptInit,
834 int *pwidthInit,
835 int fSorted )
837 GC_UNWRAP(pGC);
838 DPRINT("RACFillSpans");
839 ENABLE_GC;
840 (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
841 GC_WRAP(pGC);
844 static void
845 RACSetSpans(
846 DrawablePtr pDraw,
847 GCPtr pGC,
848 char *pcharsrc,
849 register DDXPointPtr ppt,
850 int *pwidth,
851 int nspans,
852 int fSorted )
854 GC_UNWRAP(pGC);
855 DPRINT("RACSetSpans");
856 ENABLE_GC;
857 (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
858 GC_WRAP(pGC);
861 static void
862 RACPutImage(
863 DrawablePtr pDraw,
864 GCPtr pGC,
865 int depth,
866 int x, int y, int w, int h,
867 int leftPad,
868 int format,
869 char *pImage )
871 GC_UNWRAP(pGC);
872 DPRINT("RACPutImage");
873 ENABLE_GC;
874 (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
875 leftPad, format, pImage);
876 GC_WRAP(pGC);
879 static RegionPtr
880 RACCopyArea(
881 DrawablePtr pSrc,
882 DrawablePtr pDst,
883 GC *pGC,
884 int srcx, int srcy,
885 int width, int height,
886 int dstx, int dsty )
888 RegionPtr ret;
890 GC_UNWRAP(pGC);
891 DPRINT("RACCopyArea");
892 ENABLE_GC;
893 ret = (*pGC->ops->CopyArea)(pSrc, pDst,
894 pGC, srcx, srcy, width, height, dstx, dsty);
895 GC_WRAP(pGC);
896 return ret;
899 static RegionPtr
900 RACCopyPlane(
901 DrawablePtr pSrc,
902 DrawablePtr pDst,
903 GCPtr pGC,
904 int srcx, int srcy,
905 int width, int height,
906 int dstx, int dsty,
907 unsigned long bitPlane )
909 RegionPtr ret;
911 GC_UNWRAP(pGC);
912 DPRINT("RACCopyPlane");
913 ENABLE_GC;
914 ret = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC, srcx, srcy,
915 width, height, dstx, dsty, bitPlane);
916 GC_WRAP(pGC);
917 return ret;
920 static void
921 RACPolyPoint(
922 DrawablePtr pDraw,
923 GCPtr pGC,
924 int mode,
925 int npt,
926 xPoint *pptInit )
928 GC_UNWRAP(pGC);
929 DPRINT("RACPolyPoint");
930 ENABLE_GC;
931 (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
932 GC_WRAP(pGC);
936 static void
937 RACPolylines(
938 DrawablePtr pDraw,
939 GCPtr pGC,
940 int mode,
941 int npt,
942 DDXPointPtr pptInit )
944 GC_UNWRAP(pGC);
945 DPRINT("RACPolylines");
946 ENABLE_GC;
947 (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
948 GC_WRAP(pGC);
951 static void
952 RACPolySegment(
953 DrawablePtr pDraw,
954 GCPtr pGC,
955 int nseg,
956 xSegment *pSeg )
958 GC_UNWRAP(pGC);
959 DPRINT("RACPolySegment");
960 ENABLE_GC;
961 (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
962 GC_WRAP(pGC);
965 static void
966 RACPolyRectangle(
967 DrawablePtr pDraw,
968 GCPtr pGC,
969 int nRectsInit,
970 xRectangle *pRectsInit )
972 GC_UNWRAP(pGC);
973 DPRINT("RACPolyRectangle");
974 ENABLE_GC;
975 (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit);
976 GC_WRAP(pGC);
979 static void
980 RACPolyArc(
981 DrawablePtr pDraw,
982 GCPtr pGC,
983 int narcs,
984 xArc *parcs )
986 GC_UNWRAP(pGC);
987 DPRINT("RACPolyArc");
988 ENABLE_GC;
989 (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
990 GC_WRAP(pGC);
993 static void
994 RACFillPolygon(
995 DrawablePtr pDraw,
996 GCPtr pGC,
997 int shape,
998 int mode,
999 int count,
1000 DDXPointPtr ptsIn )
1002 GC_UNWRAP(pGC);
1003 DPRINT("RACFillPolygon");
1004 ENABLE_GC;
1005 (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
1006 GC_WRAP(pGC);
1010 static void
1011 RACPolyFillRect(
1012 DrawablePtr pDraw,
1013 GCPtr pGC,
1014 int nrectFill,
1015 xRectangle *prectInit )
1017 GC_UNWRAP(pGC);
1018 DPRINT("RACPolyFillRect");
1019 ENABLE_GC;
1020 (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
1021 GC_WRAP(pGC);
1025 static void
1026 RACPolyFillArc(
1027 DrawablePtr pDraw,
1028 GCPtr pGC,
1029 int narcs,
1030 xArc *parcs )
1032 GC_UNWRAP(pGC);
1033 DPRINT("RACPolyFillArc");
1034 ENABLE_GC;
1035 (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
1036 GC_WRAP(pGC);
1039 static int
1040 RACPolyText8(
1041 DrawablePtr pDraw,
1042 GCPtr pGC,
1043 int x,
1044 int y,
1045 int count,
1046 char *chars )
1048 int ret;
1050 GC_UNWRAP(pGC);
1051 DPRINT("RACPolyText8");
1052 ENABLE_GC;
1053 ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
1054 GC_WRAP(pGC);
1055 return ret;
1058 static int
1059 RACPolyText16(
1060 DrawablePtr pDraw,
1061 GCPtr pGC,
1062 int x,
1063 int y,
1064 int count,
1065 unsigned short *chars )
1067 int ret;
1069 GC_UNWRAP(pGC);
1070 DPRINT("RACPolyText16");
1071 ENABLE_GC;
1072 ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
1073 GC_WRAP(pGC);
1074 return ret;
1077 static void
1078 RACImageText8(
1079 DrawablePtr pDraw,
1080 GCPtr pGC,
1081 int x,
1082 int y,
1083 int count,
1084 char *chars )
1086 GC_UNWRAP(pGC);
1087 DPRINT("RACImageText8");
1088 ENABLE_GC;
1089 (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
1090 GC_WRAP(pGC);
1093 static void
1094 RACImageText16(
1095 DrawablePtr pDraw,
1096 GCPtr pGC,
1097 int x,
1098 int y,
1099 int count,
1100 unsigned short *chars )
1102 GC_UNWRAP(pGC);
1103 DPRINT("RACImageText16");
1104 ENABLE_GC;
1105 (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
1106 GC_WRAP(pGC);
1110 static void
1111 RACImageGlyphBlt(
1112 DrawablePtr pDraw,
1113 GCPtr pGC,
1114 int xInit, int yInit,
1115 unsigned int nglyph,
1116 CharInfoPtr *ppci,
1117 pointer pglyphBase )
1119 GC_UNWRAP(pGC);
1120 DPRINT("RACImageGlyphBlt");
1121 ENABLE_GC;
1122 (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit,
1123 nglyph, ppci, pglyphBase);
1124 GC_WRAP(pGC);
1127 static void
1128 RACPolyGlyphBlt(
1129 DrawablePtr pDraw,
1130 GCPtr pGC,
1131 int xInit, int yInit,
1132 unsigned int nglyph,
1133 CharInfoPtr *ppci,
1134 pointer pglyphBase )
1136 GC_UNWRAP(pGC);
1137 DPRINT("RACPolyGlyphBlt");
1138 ENABLE_GC;
1139 (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit,
1140 nglyph, ppci, pglyphBase);
1141 GC_WRAP(pGC);
1144 static void
1145 RACPushPixels(
1146 GCPtr pGC,
1147 PixmapPtr pBitMap,
1148 DrawablePtr pDraw,
1149 int dx, int dy, int xOrg, int yOrg )
1151 GC_UNWRAP(pGC);
1152 DPRINT("RACPushPixels");
1153 ENABLE_GC;
1154 (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
1155 GC_WRAP(pGC);
1159 /* miSpriteFuncs */
1160 static Bool
1161 RACSpriteRealizeCursor(ScreenPtr pScreen, CursorPtr pCur)
1163 Bool val;
1164 SPRITE_PROLOG;
1165 DPRINT_S("RACSpriteRealizeCursor",pScreen->myNum);
1166 ENABLE;
1167 val = PointPriv->spriteFuncs->RealizeCursor(pScreen, pCur);
1168 SPRITE_EPILOG;
1169 return val;
1172 static Bool
1173 RACSpriteUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCur)
1175 Bool val;
1176 SPRITE_PROLOG;
1177 DPRINT_S("RACSpriteUnrealizeCursor",pScreen->myNum);
1178 ENABLE;
1179 val = PointPriv->spriteFuncs->UnrealizeCursor(pScreen, pCur);
1180 SPRITE_EPILOG;
1181 return val;
1184 static void
1185 RACSpriteSetCursor(ScreenPtr pScreen, CursorPtr pCur, int x, int y)
1187 SPRITE_PROLOG;
1188 DPRINT_S("RACSpriteSetCursor",pScreen->myNum);
1189 ENABLE;
1190 PointPriv->spriteFuncs->SetCursor(pScreen, pCur, x, y);
1191 SPRITE_EPILOG;
1194 static void
1195 RACSpriteMoveCursor(ScreenPtr pScreen, int x, int y)
1197 SPRITE_PROLOG;
1198 DPRINT_S("RACSpriteMoveCursor",pScreen->myNum);
1199 ENABLE;
1200 PointPriv->spriteFuncs->MoveCursor(pScreen, x, y);
1201 SPRITE_EPILOG;
1204 #ifdef RENDER
1205 static void
1206 RACComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
1207 PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask,
1208 INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width,
1209 CARD16 height)
1211 ScreenPtr pScreen = pDst->pDrawable->pScreen;
1212 PictureScreenPtr ps = GetPictureScreen(pScreen);
1214 PICTURE_PROLOGUE(Composite);
1216 ENABLE;
1217 (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst,
1218 yDst, width, height);
1220 PICTURE_EPILOGUE(Composite, RACComposite);
1223 static void
1224 RACGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
1225 PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist,
1226 GlyphListPtr list, GlyphPtr *glyphs)
1228 ScreenPtr pScreen = pDst->pDrawable->pScreen;
1229 PictureScreenPtr ps = GetPictureScreen(pScreen);
1231 PICTURE_PROLOGUE(Glyphs);
1233 ENABLE;
1234 (*ps->Glyphs)(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
1236 PICTURE_EPILOGUE (Glyphs, RACGlyphs);
1239 static void
1240 RACCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRect,
1241 xRectangle *rects)
1243 ScreenPtr pScreen = pDst->pDrawable->pScreen;
1244 PictureScreenPtr ps = GetPictureScreen(pScreen);
1246 PICTURE_PROLOGUE(CompositeRects);
1248 ENABLE;
1249 (*ps->CompositeRects)(op, pDst, color, nRect, rects);
1251 PICTURE_EPILOGUE (CompositeRects, RACCompositeRects);
1253 #endif