1 #ifdef HAVE_XORG_CONFIG_H
2 #include <xorg-config.h>
6 #include <X11/Xproto.h>
7 #include "scrnintstr.h"
11 #include "windowstr.h"
13 #include "picturestr.h"
14 #include "colormapst.h"
17 #include "xaaWrapper.h"
19 void XAASync(ScreenPtr pScreen
);
21 /* #include "render.h" */
26 != (xaaWrapperGetScrPriv(((DrawablePtr)(pDraw))->pScreen))->depth)
31 static Bool
xaaWrapperCreateGC(GCPtr pGC
);
32 static void xaaWrapperValidateGC(GCPtr pGC
, unsigned long changes
, DrawablePtr pDraw
);
33 static void xaaWrapperDestroyGC(GCPtr pGC
);
34 static void xaaWrapperChangeGC (GCPtr pGC
, unsigned long mask
);
35 static void xaaWrapperCopyGC (GCPtr pGCSrc
, unsigned long mask
, GCPtr pGCDst
);
36 static void xaaWrapperChangeClip (GCPtr pGC
, int type
, pointer pvalue
, int nrects
);
38 static void xaaWrapperCopyClip(GCPtr pgcDst
, GCPtr pgcSrc
);
39 static void xaaWrapperDestroyClip(GCPtr pGC
);
43 xaaWrapperComposite (CARD8 op
, PicturePtr pSrc
, PicturePtr pMask
, PicturePtr pDst
,
44 INT16 xSrc
, INT16 ySrc
, INT16 xMask
, INT16 yMask
,
45 INT16 xDst
, INT16 yDst
, CARD16 width
, CARD16 height
);
47 xaaWrapperGlyphs (CARD8 op
, PicturePtr pSrc
, PicturePtr pDst
,
48 PictFormatPtr maskFormat
, INT16 xSrc
, INT16 ySrc
, int nlist
,
49 GlyphListPtr list
, GlyphPtr
*glyphs
);
53 CloseScreenProcPtr CloseScreen
;
54 CreateScreenResourcesProcPtr CreateScreenResources
;
55 CreateWindowProcPtr CreateWindow
;
56 CopyWindowProcPtr CopyWindow
;
57 PaintWindowProcPtr PaintWindowBackground
;
58 PaintWindowProcPtr PaintWindowBorder
;
59 WindowExposuresProcPtr WindowExposures
;
60 CreateGCProcPtr CreateGC
;
61 CreateColormapProcPtr CreateColormap
;
62 DestroyColormapProcPtr DestroyColormap
;
63 InstallColormapProcPtr InstallColormap
;
64 UninstallColormapProcPtr UninstallColormap
;
65 ListInstalledColormapsProcPtr ListInstalledColormaps
;
66 StoreColorsProcPtr StoreColors
;
68 CompositeProcPtr Composite
;
72 CloseScreenProcPtr wrapCloseScreen
;
73 CreateScreenResourcesProcPtr wrapCreateScreenResources
;
74 CreateWindowProcPtr wrapCreateWindow
;
75 CopyWindowProcPtr wrapCopyWindow
;
76 PaintWindowProcPtr wrapPaintWindowBackground
;
77 PaintWindowProcPtr wrapPaintWindowBorder
;
78 WindowExposuresProcPtr wrapWindowExposures
;
79 CreateGCProcPtr wrapCreateGC
;
80 CreateColormapProcPtr wrapCreateColormap
;
81 DestroyColormapProcPtr wrapDestroyColormap
;
82 InstallColormapProcPtr wrapInstallColormap
;
83 UninstallColormapProcPtr wrapUninstallColormap
;
84 ListInstalledColormapsProcPtr wrapListInstalledColormaps
;
85 StoreColorsProcPtr wrapStoreColors
;
87 CompositeProcPtr wrapComposite
;
88 GlyphsProcPtr wrapGlyphs
;
91 } xaaWrapperScrPrivRec
, *xaaWrapperScrPrivPtr
;
93 #define xaaWrapperGetScrPriv(s) ((xaaWrapperScrPrivPtr)( \
94 (xaaWrapperScrPrivateIndex != -1) \
95 ? (s)->devPrivates[xaaWrapperScrPrivateIndex].ptr\
97 #define xaaWrapperScrPriv(s) xaaWrapperScrPrivPtr pScrPriv = xaaWrapperGetScrPriv(s)
99 #define wrap(priv,real,mem,func) {\
100 priv->mem = real->mem; \
104 #define unwrap(priv,real,mem) {\
105 real->mem = priv->mem; \
108 #define cond_wrap(priv,cond,real,mem,wrapmem,func) {\
110 priv->wrapmem = real->mem; \
112 priv->mem = real->mem; \
116 #define cond_unwrap(priv,cond,real,mem,wrapmem) {\
118 real->mem = priv->wrapmem; \
120 real->mem = priv->mem; \
123 #define get(priv,real,func,wrap) \
124 priv->wrap = real->func;
126 typedef struct _xaaWrapperGCPriv
{
131 } xaaWrapperGCPrivRec
, *xaaWrapperGCPrivPtr
;
133 #define xaaWrapperGetGCPriv(pGC) ((xaaWrapperGCPrivPtr) \
134 (pGC)->devPrivates[xaaWrapperGCPrivateIndex].ptr)
135 #define xaaWrapperGCPriv(pGC) xaaWrapperGCPrivPtr pGCPriv = xaaWrapperGetGCPriv(pGC)
138 static int xaaWrapperScrPrivateIndex
= -1;
139 static int xaaWrapperGCPrivateIndex
= -1;
140 static int xaaWrapperGeneration
= -1;
143 xaaWrapperCreateScreenResources(ScreenPtr pScreen
)
145 xaaWrapperScrPriv(pScreen
);
148 unwrap (pScrPriv
,pScreen
, CreateScreenResources
);
149 ret
= pScreen
->CreateScreenResources(pScreen
);
150 wrap(pScrPriv
,pScreen
,CreateScreenResources
,xaaWrapperCreateScreenResources
);
155 xaaWrapperCloseScreen (int iScreen
, ScreenPtr pScreen
)
157 xaaWrapperScrPriv(pScreen
);
160 unwrap (pScrPriv
,pScreen
, CloseScreen
);
161 ret
= pScreen
->CloseScreen(iScreen
,pScreen
);
166 xaaWrapperCreateWindow(WindowPtr pWin
)
168 xaaWrapperScrPriv(pWin
->drawable
.pScreen
);
171 cond_unwrap(pScrPriv
, &pWin
->drawable
, pWin
->drawable
.pScreen
,
172 CreateWindow
, wrapCreateWindow
);
173 ret
= pWin
->drawable
.pScreen
->CreateWindow(pWin
);
174 cond_wrap(pScrPriv
, &pWin
->drawable
, pWin
->drawable
.pScreen
, CreateWindow
,
175 wrapCreateWindow
, xaaWrapperCreateWindow
);
181 xaaWrapperCopyWindow(WindowPtr pWin
,
182 DDXPointRec ptOldOrg
,
185 ScreenPtr pScreen
= pWin
->drawable
.pScreen
;
186 xaaWrapperScrPriv(pScreen
);
188 unwrap (pScrPriv
, pScreen
, CopyWindow
);
190 if (COND(&pWin
->drawable
))
191 pWin
->drawable
.pScreen
->CopyWindow
= pScrPriv
->wrapCopyWindow
;
193 pScreen
->CopyWindow(pWin
, ptOldOrg
, prgnSrc
);
194 wrap(pScrPriv
, pScreen
, CopyWindow
, xaaWrapperCopyWindow
);
198 xaaWrapperWindowExposures (WindowPtr pWin
,
200 RegionPtr other_exposed
)
202 xaaWrapperScrPriv(pWin
->drawable
.pScreen
);
204 cond_unwrap(pScrPriv
, &pWin
->drawable
, pWin
->drawable
.pScreen
,
205 WindowExposures
, wrapWindowExposures
);
206 pWin
->drawable
.pScreen
->WindowExposures(pWin
, prgn
, other_exposed
);
207 cond_wrap(pScrPriv
, &pWin
->drawable
, pWin
->drawable
.pScreen
,
208 WindowExposures
, wrapWindowExposures
, xaaWrapperWindowExposures
);
212 xaaWrapperPaintWindow(WindowPtr pWin
, RegionPtr pRegion
, int what
)
214 xaaWrapperScrPriv(pWin
->drawable
.pScreen
);
218 cond_unwrap(pScrPriv
, &pWin
->drawable
, pWin
->drawable
.pScreen
,
219 PaintWindowBorder
, wrapPaintWindowBorder
);
221 pWin
->drawable
.pScreen
->PaintWindowBorder (pWin
, pRegion
, what
);
222 cond_wrap(pScrPriv
, &pWin
->drawable
, pWin
->drawable
.pScreen
,
223 PaintWindowBorder
, wrapPaintWindowBorder
,
224 xaaWrapperPaintWindow
);
227 cond_unwrap(pScrPriv
, &pWin
->drawable
, pWin
->drawable
.pScreen
,
228 PaintWindowBackground
, wrapPaintWindowBackground
);
230 pWin
->drawable
.pScreen
->PaintWindowBackground (pWin
, pRegion
, what
);
231 cond_wrap(pScrPriv
, &pWin
->drawable
, pWin
->drawable
.pScreen
,
232 PaintWindowBackground
, wrapPaintWindowBackground
,
233 xaaWrapperPaintWindow
);
239 xaaWrapperCreateColormap(ColormapPtr pmap
)
241 xaaWrapperScrPriv(pmap
->pScreen
);
243 unwrap(pScrPriv
,pmap
->pScreen
, CreateColormap
);
244 ret
= pmap
->pScreen
->CreateColormap(pmap
);
245 wrap(pScrPriv
,pmap
->pScreen
,CreateColormap
,xaaWrapperCreateColormap
);
251 xaaWrapperDestroyColormap(ColormapPtr pmap
)
253 xaaWrapperScrPriv(pmap
->pScreen
);
254 unwrap(pScrPriv
,pmap
->pScreen
, DestroyColormap
);
255 pmap
->pScreen
->DestroyColormap(pmap
);
256 wrap(pScrPriv
,pmap
->pScreen
,DestroyColormap
,xaaWrapperDestroyColormap
);
260 xaaWrapperStoreColors(ColormapPtr pmap
, int nColors
, xColorItem
*pColors
)
262 xaaWrapperScrPriv(pmap
->pScreen
);
263 unwrap(pScrPriv
,pmap
->pScreen
, StoreColors
);
264 pmap
->pScreen
->StoreColors(pmap
,nColors
,pColors
);
265 wrap(pScrPriv
,pmap
->pScreen
,StoreColors
,xaaWrapperStoreColors
);
269 xaaWrapperInstallColormap(ColormapPtr pmap
)
271 xaaWrapperScrPriv(pmap
->pScreen
);
273 unwrap(pScrPriv
,pmap
->pScreen
, InstallColormap
);
274 pmap
->pScreen
->InstallColormap(pmap
);
275 wrap(pScrPriv
,pmap
->pScreen
,InstallColormap
,xaaWrapperInstallColormap
);
279 xaaWrapperUninstallColormap(ColormapPtr pmap
)
281 xaaWrapperScrPriv(pmap
->pScreen
);
283 unwrap(pScrPriv
,pmap
->pScreen
, UninstallColormap
);
284 pmap
->pScreen
->UninstallColormap(pmap
);
285 wrap(pScrPriv
,pmap
->pScreen
,UninstallColormap
,xaaWrapperUninstallColormap
);
289 xaaWrapperListInstalledColormaps(ScreenPtr pScreen
, Colormap
*pCmapIds
)
292 xaaWrapperScrPriv(pScreen
);
294 unwrap(pScrPriv
,pScreen
, ListInstalledColormaps
);
295 n
= pScreen
->ListInstalledColormaps(pScreen
, pCmapIds
);
296 wrap (pScrPriv
,pScreen
,ListInstalledColormaps
,xaaWrapperListInstalledColormaps
);
301 xaaSetupWrapper(ScreenPtr pScreen
, XAAInfoRecPtr infoPtr
, int depth
, SyncFunc
*func
)
304 xaaWrapperScrPrivPtr pScrPriv
;
306 PictureScreenPtr ps
= GetPictureScreenIfSet(pScreen
);
308 if (xaaWrapperGeneration
!= serverGeneration
) {
309 xaaWrapperScrPrivateIndex
= AllocateScreenPrivateIndex ();
310 if (xaaWrapperScrPrivateIndex
== -1)
312 xaaWrapperGCPrivateIndex
= AllocateGCPrivateIndex ();
313 if (xaaWrapperGCPrivateIndex
== -1)
315 xaaWrapperGeneration
= serverGeneration
;
318 if (!AllocateGCPrivate (pScreen
, xaaWrapperGCPrivateIndex
,
319 sizeof (xaaWrapperGCPrivRec
)))
322 pScrPriv
= (xaaWrapperScrPrivPtr
) xalloc (sizeof (xaaWrapperScrPrivRec
));
326 get (pScrPriv
, pScreen
, CloseScreen
, wrapCloseScreen
);
327 get (pScrPriv
, pScreen
, CreateScreenResources
, wrapCreateScreenResources
);
328 get (pScrPriv
, pScreen
, CreateWindow
, wrapCreateWindow
);
329 get (pScrPriv
, pScreen
, CopyWindow
, wrapCopyWindow
);
330 get (pScrPriv
, pScreen
, PaintWindowBorder
, wrapPaintWindowBorder
);
331 get (pScrPriv
, pScreen
, PaintWindowBackground
, wrapPaintWindowBackground
);
332 get (pScrPriv
, pScreen
, WindowExposures
, wrapWindowExposures
);
333 get (pScrPriv
, pScreen
, CreateGC
, wrapCreateGC
);
334 get (pScrPriv
, pScreen
, CreateColormap
, wrapCreateColormap
);
335 get (pScrPriv
, pScreen
, DestroyColormap
, wrapDestroyColormap
);
336 get (pScrPriv
, pScreen
, InstallColormap
, wrapInstallColormap
);
337 get (pScrPriv
, pScreen
, UninstallColormap
, wrapUninstallColormap
);
338 get (pScrPriv
, pScreen
, ListInstalledColormaps
, wrapListInstalledColormaps
);
339 get (pScrPriv
, pScreen
, StoreColors
, wrapStoreColors
);
342 get (pScrPriv
, ps
, Glyphs
, wrapGlyphs
);
343 get (pScrPriv
, ps
, Composite
, wrapComposite
);
346 if (!(ret
= XAAInit(pScreen
,infoPtr
)))
349 wrap (pScrPriv
, pScreen
, CloseScreen
, xaaWrapperCloseScreen
);
350 wrap (pScrPriv
, pScreen
, CreateScreenResources
,
351 xaaWrapperCreateScreenResources
);
352 wrap (pScrPriv
, pScreen
, CreateWindow
, xaaWrapperCreateWindow
);
353 wrap (pScrPriv
, pScreen
, CopyWindow
, xaaWrapperCopyWindow
);
354 wrap (pScrPriv
, pScreen
, PaintWindowBorder
, xaaWrapperPaintWindow
);
355 wrap (pScrPriv
, pScreen
, PaintWindowBackground
, xaaWrapperPaintWindow
);
356 wrap (pScrPriv
, pScreen
, WindowExposures
, xaaWrapperWindowExposures
);
357 wrap (pScrPriv
, pScreen
, CreateGC
, xaaWrapperCreateGC
);
358 wrap (pScrPriv
, pScreen
, CreateColormap
, xaaWrapperCreateColormap
);
359 wrap (pScrPriv
, pScreen
, DestroyColormap
, xaaWrapperDestroyColormap
);
360 wrap (pScrPriv
, pScreen
, InstallColormap
, xaaWrapperInstallColormap
);
361 wrap (pScrPriv
, pScreen
, UninstallColormap
, xaaWrapperUninstallColormap
);
362 wrap (pScrPriv
, pScreen
, ListInstalledColormaps
,
363 xaaWrapperListInstalledColormaps
);
364 wrap (pScrPriv
, pScreen
, StoreColors
, xaaWrapperStoreColors
);
368 wrap (pScrPriv
, ps
, Glyphs
, xaaWrapperGlyphs
);
369 wrap (pScrPriv
, ps
, Composite
, xaaWrapperComposite
);
372 pScrPriv
->depth
= depth
;
373 pScreen
->devPrivates
[xaaWrapperScrPrivateIndex
].ptr
= (pointer
) pScrPriv
;
380 GCFuncs xaaWrapperGCFuncs
= {
381 xaaWrapperValidateGC
, xaaWrapperChangeGC
, xaaWrapperCopyGC
,
382 xaaWrapperDestroyGC
, xaaWrapperChangeClip
, xaaWrapperDestroyClip
,
386 #define XAAWRAPPER_GC_FUNC_PROLOGUE(pGC) \
387 xaaWrapperGCPriv(pGC); \
388 unwrap(pGCPriv, pGC, funcs); \
389 if (pGCPriv->wrap) unwrap(pGCPriv, pGC, ops)
391 #define XAAWRAPPER_GC_FUNC_EPILOGUE(pGC) \
392 wrap(pGCPriv, pGC, funcs, &xaaWrapperGCFuncs); \
393 if (pGCPriv->wrap) wrap(pGCPriv, pGC, ops, pGCPriv->wrapops)
396 xaaWrapperCreateGC(GCPtr pGC
)
398 ScreenPtr pScreen
= pGC
->pScreen
;
399 xaaWrapperScrPriv(pScreen
);
400 xaaWrapperGCPriv(pGC
);
403 unwrap (pScrPriv
, pScreen
, CreateGC
);
404 if((ret
= (*pScreen
->CreateGC
) (pGC
))) {
405 pGCPriv
->wrap
= FALSE
;
406 pGCPriv
->funcs
= pGC
->funcs
;
407 pGCPriv
->wrapops
= pGC
->ops
;
408 pGC
->funcs
= &xaaWrapperGCFuncs
;
410 wrap (pScrPriv
, pScreen
, CreateGC
, xaaWrapperCreateGC
);
416 xaaWrapperValidateGC(
418 unsigned long changes
,
421 XAAWRAPPER_GC_FUNC_PROLOGUE (pGC
);
422 (*pGC
->funcs
->ValidateGC
)(pGC
, changes
, pDraw
);
425 pGCPriv
->wrap
= TRUE
;
427 XAAWRAPPER_GC_FUNC_EPILOGUE (pGC
);
431 xaaWrapperDestroyGC(GCPtr pGC
)
433 XAAWRAPPER_GC_FUNC_PROLOGUE (pGC
);
434 (*pGC
->funcs
->DestroyGC
)(pGC
);
435 XAAWRAPPER_GC_FUNC_EPILOGUE (pGC
);
443 XAAWRAPPER_GC_FUNC_PROLOGUE (pGC
);
444 (*pGC
->funcs
->ChangeGC
) (pGC
, mask
);
445 XAAWRAPPER_GC_FUNC_EPILOGUE (pGC
);
454 XAAWRAPPER_GC_FUNC_PROLOGUE (pGCDst
);
455 (*pGCDst
->funcs
->CopyGC
) (pGCSrc
, mask
, pGCDst
);
456 XAAWRAPPER_GC_FUNC_EPILOGUE (pGCDst
);
460 xaaWrapperChangeClip (
466 XAAWRAPPER_GC_FUNC_PROLOGUE (pGC
);
467 (*pGC
->funcs
->ChangeClip
) (pGC
, type
, pvalue
, nrects
);
468 XAAWRAPPER_GC_FUNC_EPILOGUE (pGC
);
472 xaaWrapperCopyClip(GCPtr pgcDst
, GCPtr pgcSrc
)
474 XAAWRAPPER_GC_FUNC_PROLOGUE (pgcDst
);
475 (* pgcDst
->funcs
->CopyClip
)(pgcDst
, pgcSrc
);
476 XAAWRAPPER_GC_FUNC_EPILOGUE (pgcDst
);
480 xaaWrapperDestroyClip(GCPtr pGC
)
482 XAAWRAPPER_GC_FUNC_PROLOGUE (pGC
);
483 (* pGC
->funcs
->DestroyClip
)(pGC
);
484 XAAWRAPPER_GC_FUNC_EPILOGUE (pGC
);
489 xaaWrapperComposite (CARD8 op
, PicturePtr pSrc
, PicturePtr pMask
, PicturePtr pDst
,
490 INT16 xSrc
, INT16 ySrc
, INT16 xMask
, INT16 yMask
,
491 INT16 xDst
, INT16 yDst
, CARD16 width
, CARD16 height
)
493 ScreenPtr pScreen
= pDst
->pDrawable
->pScreen
;
494 PictureScreenPtr ps
= GetPictureScreen(pScreen
);
495 xaaWrapperScrPriv(pScreen
);
497 unwrap (pScrPriv
, ps
, Composite
);
498 (*ps
->Composite
) (op
, pSrc
, pMask
, pDst
, xSrc
, ySrc
, xMask
, yMask
,
499 xDst
, yDst
, width
, height
);
500 wrap (pScrPriv
, ps
, Composite
, xaaWrapperComposite
);
505 xaaWrapperGlyphs (CARD8 op
, PicturePtr pSrc
, PicturePtr pDst
,
506 PictFormatPtr maskFormat
, INT16 xSrc
, INT16 ySrc
, int nlist
,
507 GlyphListPtr list
, GlyphPtr
*glyphs
)
509 ScreenPtr pScreen
= pDst
->pDrawable
->pScreen
;
510 PictureScreenPtr ps
= GetPictureScreen(pScreen
);
511 xaaWrapperScrPriv(pScreen
);
513 unwrap (pScrPriv
, ps
, Glyphs
);
514 (*ps
->Glyphs
) (op
, pSrc
, pDst
, maskFormat
, xSrc
, ySrc
,
515 nlist
, list
, glyphs
);
516 wrap (pScrPriv
, ps
, Glyphs
, xaaWrapperGlyphs
);
522 XAASync(ScreenPtr pScreen
)
524 XAAScreenPtr pScreenPriv
=
525 (XAAScreenPtr
) pScreen
->devPrivates
[XAAGetScreenIndex()].ptr
;
526 XAAInfoRecPtr infoRec
= pScreenPriv
->AccelInfoRec
;
528 if(infoRec
->NeedToSync
) {
529 (*infoRec
->Sync
)(infoRec
->pScrn
);
530 infoRec
->NeedToSync
= FALSE
;