Home | History | Annotate | Line # | Download | only in xaa
      1 /*
      2    Copyright (c) 1999 - The XFree86 Project Inc.
      3 
      4    Written by Mark Vojkovich
      5 */
      6 
      7 
      8 #ifdef HAVE_XORG_CONFIG_H
      9 #include <xorg-config.h>
     10 #endif
     11 
     12 #include "misc.h"
     13 #include "xf86.h"
     14 #include "xf86_OSproc.h"
     15 
     16 #include <X11/X.h>
     17 #include "scrnintstr.h"
     18 #include "pixmapstr.h"
     19 #include "windowstr.h"
     20 #include "xf86str.h"
     21 #include "mi.h"
     22 #include "miline.h"
     23 #include "xaa.h"
     24 #include "xaalocal.h"
     25 #include "xaawrap.h"
     26 #include "servermd.h"
     27 
     28 /* Screen funcs */
     29 
     30 static void XAAOverCopyWindow(WindowPtr, DDXPointRec, RegionPtr);
     31 static void XAAOverWindowExposures(WindowPtr, RegionPtr, RegionPtr);
     32 
     33 static int XAAOverStippledFillChooser(GCPtr);
     34 static int XAAOverOpaqueStippledFillChooser(GCPtr);
     35 static int XAAOverTiledFillChooser(GCPtr);
     36 
     37 /* GC funcs */
     38 
     39 static RegionPtr XAAOverCopyArea(DrawablePtr, DrawablePtr, GC *,
     40 			int, int, int, int, int, int);
     41 static RegionPtr XAAOverCopyPlane(DrawablePtr, DrawablePtr, GCPtr,
     42 			int, int, int, int, int, int, unsigned long);
     43 static void XAAOverPushPixelsSolid(GCPtr, PixmapPtr, DrawablePtr, int,
     44 			int, int, int);
     45 static void XAAOverPolyFillRectSolid(DrawablePtr, GCPtr, int, xRectangle*);
     46 static void XAAOverPolyFillRectStippled(DrawablePtr, GCPtr, int, xRectangle*);
     47 static void XAAOverPolyFillRectOpaqueStippled(DrawablePtr, GCPtr,
     48 			int, xRectangle*);
     49 static void XAAOverPolyFillRectTiled(DrawablePtr, GCPtr, int, xRectangle*);
     50 static void XAAOverFillSpansSolid(DrawablePtr, GCPtr, int, DDXPointPtr,
     51 			int*, int);
     52 static void XAAOverFillSpansStippled(DrawablePtr, GCPtr, int, DDXPointPtr,
     53 			int*, int);
     54 static void XAAOverFillSpansOpaqueStippled(DrawablePtr, GCPtr, int,
     55 			DDXPointPtr, int*, int);
     56 static void XAAOverFillSpansTiled(DrawablePtr, GCPtr, int, DDXPointPtr,
     57 			int*, int);
     58 static int XAAOverPolyText8TE(DrawablePtr, GCPtr, int, int, int, char *);
     59 static int XAAOverPolyText16TE(DrawablePtr, GCPtr, int, int, int,
     60 			unsigned short*);
     61 static void XAAOverImageText8TE(DrawablePtr, GCPtr, int, int, int, char*);
     62 static void XAAOverImageText16TE(DrawablePtr, GCPtr, int, int, int,
     63 			unsigned short*);
     64 static void XAAOverImageGlyphBltTE(DrawablePtr, GCPtr, int, int,
     65 			unsigned int, CharInfoPtr*, pointer);
     66 static void XAAOverPolyGlyphBltTE(DrawablePtr, GCPtr, int, int,
     67 			unsigned int, CharInfoPtr*, pointer);
     68 static int XAAOverPolyText8NonTE(DrawablePtr, GCPtr, int, int, int, char*);
     69 static int XAAOverPolyText16NonTE(DrawablePtr, GCPtr, int, int, int,
     70 			unsigned short*);
     71 static void XAAOverImageText8NonTE(DrawablePtr, GCPtr, int, int, int, char*);
     72 static void XAAOverImageText16NonTE(DrawablePtr, GCPtr, int, int, int,
     73 			unsigned short*);
     74 static void XAAOverImageGlyphBltNonTE(DrawablePtr, GCPtr, int, int,
     75 			unsigned int, CharInfoPtr *, pointer);
     76 static void XAAOverPolyGlyphBltNonTE(DrawablePtr, GCPtr, int, int,
     77 			unsigned int, CharInfoPtr *, pointer);
     78 static void XAAOverPolyRectangleThinSolid(DrawablePtr, GCPtr, int, xRectangle*);
     79 static void XAAOverPolylinesWideSolid(DrawablePtr, GCPtr, int, int,
     80 			DDXPointPtr);
     81 static void XAAOverPolylinesThinSolid(DrawablePtr, GCPtr, int, int,
     82 			DDXPointPtr);
     83 static void XAAOverPolySegmentThinSolid(DrawablePtr, GCPtr, int, xSegment*);
     84 static void XAAOverPolylinesThinDashed(DrawablePtr, GCPtr, int, int,
     85 			DDXPointPtr);
     86 static void XAAOverPolySegmentThinDashed(DrawablePtr, GCPtr, int, xSegment*);
     87 static void XAAOverFillPolygonSolid(DrawablePtr, GCPtr, int, int, int,
     88 			DDXPointPtr);
     89 static void XAAOverFillPolygonStippled(DrawablePtr, GCPtr, int, int, int,
     90 			DDXPointPtr);
     91 static void XAAOverFillPolygonOpaqueStippled(DrawablePtr, GCPtr, int, int, int,
     92 			DDXPointPtr);
     93 static void XAAOverFillPolygonTiled(DrawablePtr, GCPtr, int, int, int,
     94 			DDXPointPtr);
     95 static void XAAOverPolyFillArcSolid(DrawablePtr, GCPtr, int, xArc*);
     96 static void XAAOverPutImage(DrawablePtr, GCPtr, int, int, int, int, int,
     97 			int, int, char*);
     98 
     99 
    100 typedef struct {
    101    ScrnInfoPtr		pScrn;
    102    DepthChangeFuncPtr	callback;
    103    int			currentDepth;
    104 /* GC funcs */
    105    RegionPtr (*CopyArea)(DrawablePtr, DrawablePtr, GC *,
    106 			int, int, int, int, int, int);
    107    RegionPtr (*CopyPlane)(DrawablePtr, DrawablePtr, GCPtr,
    108 			int, int, int, int, int, int, unsigned long);
    109    void (*PushPixelsSolid)(GCPtr, PixmapPtr, DrawablePtr, int, int, int, int);
    110    void (*PolyFillRectSolid)(DrawablePtr, GCPtr, int, xRectangle*);
    111    void (*PolyFillRectStippled)(DrawablePtr, GCPtr, int, xRectangle*);
    112    void (*PolyFillRectOpaqueStippled)(DrawablePtr, GCPtr, int, xRectangle*);
    113    void (*PolyFillRectTiled)(DrawablePtr, GCPtr, int, xRectangle*);
    114    void (*FillSpansSolid)(DrawablePtr, GCPtr, int, DDXPointPtr, int*, int);
    115    void (*FillSpansStippled)(DrawablePtr, GCPtr, int, DDXPointPtr, int*, int);
    116    void (*FillSpansOpaqueStippled)(DrawablePtr,GCPtr,int,DDXPointPtr,int*,int);
    117    void (*FillSpansTiled)(DrawablePtr, GCPtr, int, DDXPointPtr, int*, int);
    118    int (*PolyText8TE)(DrawablePtr, GCPtr, int, int, int, char *);
    119    int (*PolyText16TE)(DrawablePtr, GCPtr, int, int, int, unsigned short*);
    120    void (*ImageText8TE)(DrawablePtr, GCPtr, int, int, int, char*);
    121    void (*ImageText16TE)(DrawablePtr, GCPtr, int, int, int, unsigned short*);
    122    void (*ImageGlyphBltTE)(DrawablePtr, GCPtr, int, int, unsigned int,
    123 			CharInfoPtr*, pointer);
    124    void (*PolyGlyphBltTE)(DrawablePtr, GCPtr, int, int, unsigned int,
    125 			CharInfoPtr*, pointer);
    126    int (*PolyText8NonTE)(DrawablePtr, GCPtr, int, int, int, char*);
    127    int (*PolyText16NonTE)(DrawablePtr, GCPtr, int, int, int, unsigned short*);
    128    void (*ImageText8NonTE)(DrawablePtr, GCPtr, int, int, int, char*);
    129    void (*ImageText16NonTE)(DrawablePtr, GCPtr, int, int, int, unsigned short*);
    130    void (*ImageGlyphBltNonTE)(DrawablePtr, GCPtr, int, int, unsigned int,
    131 			CharInfoPtr *, pointer);
    132    void (*PolyGlyphBltNonTE)(DrawablePtr, GCPtr, int, int, unsigned int,
    133 			CharInfoPtr *, pointer);
    134    void (*PolyRectangleThinSolid)(DrawablePtr, GCPtr, int, xRectangle*);
    135    void (*PolylinesWideSolid)(DrawablePtr, GCPtr, int, int, DDXPointPtr);
    136 
    137    void (*PolylinesThinSolid)(DrawablePtr, GCPtr, int, int, DDXPointPtr);
    138    void (*PolySegmentThinSolid)(DrawablePtr, GCPtr, int, xSegment*);
    139    void (*PolylinesThinDashed)(DrawablePtr, GCPtr, int, int, DDXPointPtr);
    140    void (*PolySegmentThinDashed)(DrawablePtr, GCPtr, int, xSegment*);
    141    void (*FillPolygonSolid)(DrawablePtr, GCPtr, int, int, int, DDXPointPtr);
    142    void (*FillPolygonStippled)(DrawablePtr, GCPtr, int, int, int, DDXPointPtr);
    143    void (*FillPolygonOpaqueStippled)(DrawablePtr, GCPtr, int, int, int,
    144 			DDXPointPtr);
    145    void (*FillPolygonTiled)(DrawablePtr, GCPtr, int, int, int, DDXPointPtr);
    146    void (*PolyFillArcSolid)(DrawablePtr, GCPtr, int, xArc*);
    147    void (*PutImage)(DrawablePtr, GCPtr, int, int, int, int, int, int,
    148 			int, char*);
    149    int (*StippledFillChooser)(GCPtr);
    150    int (*OpaqueStippledFillChooser)(GCPtr);
    151    int (*TiledFillChooser)(GCPtr);
    152 } XAAOverlayRec, *XAAOverlayPtr;
    153 
    154 static DevPrivateKeyRec XAAOverlayKeyRec;
    155 #define XAAOverlayKey (&XAAOverlayKeyRec)
    156 
    157 #define GET_OVERLAY_PRIV(pScreen) \
    158     (XAAOverlayPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAOverlayKey)
    159 
    160 #define SWITCH_DEPTH(d) \
    161    if(pOverPriv->currentDepth != d) { \
    162 	(*pOverPriv->callback)(pOverPriv->pScrn, d); \
    163 	pOverPriv->currentDepth = d; \
    164    }
    165 
    166 
    167 Bool
    168 XAAInitDualFramebufferOverlay(
    169     ScreenPtr pScreen,
    170     DepthChangeFuncPtr callback
    171 ){
    172     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
    173     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
    174     XAAOverlayPtr pOverPriv;
    175 
    176     if (!dixRegisterPrivateKey(&XAAOverlayKeyRec, PRIVATE_SCREEN, 0))
    177 	return FALSE;
    178 
    179     if(!(pOverPriv = malloc(sizeof(XAAOverlayRec))))
    180 	return FALSE;
    181 
    182     dixSetPrivate(&pScreen->devPrivates, XAAOverlayKey, pOverPriv);
    183 
    184     pOverPriv->pScrn = pScrn;
    185     pOverPriv->callback = callback;
    186     pOverPriv->currentDepth = -1;
    187 
    188     /* Overwrite key screen functions.  The XAA core will clean up */
    189 
    190     pScreen->CopyWindow = XAAOverCopyWindow;
    191     pScreen->WindowExposures = XAAOverWindowExposures;
    192 
    193     pOverPriv->StippledFillChooser = infoRec->StippledFillChooser;
    194     pOverPriv->OpaqueStippledFillChooser = infoRec->OpaqueStippledFillChooser;
    195     pOverPriv->TiledFillChooser = infoRec->TiledFillChooser;
    196 
    197     infoRec->StippledFillChooser = XAAOverStippledFillChooser;
    198     infoRec->OpaqueStippledFillChooser = XAAOverOpaqueStippledFillChooser;
    199     infoRec->TiledFillChooser = XAAOverTiledFillChooser;
    200 
    201     /* wrap all XAA GC rendering */
    202 
    203     pOverPriv->CopyArea = infoRec->CopyArea;
    204     pOverPriv->CopyPlane = infoRec->CopyPlane;
    205     pOverPriv->PushPixelsSolid = infoRec->PushPixelsSolid;
    206     pOverPriv->PolyFillRectSolid = infoRec->PolyFillRectSolid;
    207     pOverPriv->PolyFillRectStippled = infoRec->PolyFillRectStippled;
    208     pOverPriv->PolyFillRectOpaqueStippled = infoRec->PolyFillRectOpaqueStippled;
    209     pOverPriv->PolyFillRectTiled = infoRec->PolyFillRectTiled;
    210     pOverPriv->FillSpansSolid = infoRec->FillSpansSolid;
    211     pOverPriv->FillSpansStippled = infoRec->FillSpansStippled;
    212     pOverPriv->FillSpansOpaqueStippled = infoRec->FillSpansOpaqueStippled;
    213     pOverPriv->FillSpansTiled = infoRec->FillSpansTiled;
    214     pOverPriv->PolyText8TE = infoRec->PolyText8TE;
    215     pOverPriv->PolyText16TE = infoRec->PolyText16TE;
    216     pOverPriv->ImageText8TE = infoRec->ImageText8TE;
    217     pOverPriv->ImageText16TE = infoRec->ImageText16TE;
    218     pOverPriv->ImageGlyphBltTE = infoRec->ImageGlyphBltTE;
    219     pOverPriv->PolyGlyphBltTE = infoRec->PolyGlyphBltTE;
    220     pOverPriv->PolyText8NonTE = infoRec->PolyText8NonTE;
    221     pOverPriv->PolyText16NonTE = infoRec->PolyText16NonTE;
    222     pOverPriv->ImageText8NonTE = infoRec->ImageText8NonTE;
    223     pOverPriv->ImageText16NonTE = infoRec->ImageText16NonTE;
    224     pOverPriv->ImageGlyphBltNonTE = infoRec->ImageGlyphBltNonTE;
    225     pOverPriv->PolyGlyphBltNonTE = infoRec->PolyGlyphBltNonTE;
    226     pOverPriv->PolyRectangleThinSolid = infoRec->PolyRectangleThinSolid;
    227     pOverPriv->PolylinesWideSolid = infoRec->PolylinesWideSolid;
    228     pOverPriv->PolylinesThinSolid = infoRec->PolylinesThinSolid;
    229     pOverPriv->PolySegmentThinSolid = infoRec->PolySegmentThinSolid;
    230     pOverPriv->PolylinesThinDashed = infoRec->PolylinesThinDashed;
    231     pOverPriv->PolySegmentThinDashed = infoRec->PolySegmentThinDashed;
    232     pOverPriv->FillPolygonSolid = infoRec->FillPolygonSolid;
    233     pOverPriv->FillPolygonStippled = infoRec->FillPolygonStippled;
    234     pOverPriv->FillPolygonOpaqueStippled = infoRec->FillPolygonOpaqueStippled;
    235     pOverPriv->FillPolygonTiled = infoRec->FillPolygonTiled;
    236     pOverPriv->PolyFillArcSolid = infoRec->PolyFillArcSolid;
    237     pOverPriv->PutImage = infoRec->PutImage;
    238 
    239 
    240     if(infoRec->CopyArea)
    241 	infoRec->CopyArea = XAAOverCopyArea;
    242     if(infoRec->CopyPlane)
    243 	infoRec->CopyPlane = XAAOverCopyPlane;
    244     if(infoRec->PushPixelsSolid)
    245 	infoRec->PushPixelsSolid = XAAOverPushPixelsSolid;
    246     if(infoRec->PolyFillRectSolid)
    247 	infoRec->PolyFillRectSolid = XAAOverPolyFillRectSolid;
    248     if(infoRec->PolyFillRectStippled)
    249 	infoRec->PolyFillRectStippled = XAAOverPolyFillRectStippled;
    250     if(infoRec->PolyFillRectOpaqueStippled)
    251 	infoRec->PolyFillRectOpaqueStippled = XAAOverPolyFillRectOpaqueStippled;
    252     if(infoRec->PolyFillRectTiled)
    253 	infoRec->PolyFillRectTiled = XAAOverPolyFillRectTiled;
    254     if(infoRec->FillSpansSolid)
    255 	infoRec->FillSpansSolid = XAAOverFillSpansSolid;
    256     if(infoRec->FillSpansStippled)
    257 	infoRec->FillSpansStippled = XAAOverFillSpansStippled;
    258     if(infoRec->FillSpansOpaqueStippled)
    259 	infoRec->FillSpansOpaqueStippled = XAAOverFillSpansOpaqueStippled;
    260     if(infoRec->FillSpansTiled)
    261 	infoRec->FillSpansTiled = XAAOverFillSpansTiled;
    262     if(infoRec->PolyText8TE)
    263 	infoRec->PolyText8TE = XAAOverPolyText8TE;
    264     if(infoRec->PolyText16TE)
    265 	infoRec->PolyText16TE = XAAOverPolyText16TE;
    266     if(infoRec->ImageText8TE)
    267 	infoRec->ImageText8TE = XAAOverImageText8TE;
    268     if(infoRec->ImageText16TE)
    269 	infoRec->ImageText16TE = XAAOverImageText16TE;
    270     if(infoRec->ImageGlyphBltTE)
    271 	infoRec->ImageGlyphBltTE = XAAOverImageGlyphBltTE;
    272     if(infoRec->PolyGlyphBltTE)
    273 	infoRec->PolyGlyphBltTE = XAAOverPolyGlyphBltTE;
    274     if(infoRec->PolyText8NonTE)
    275 	infoRec->PolyText8NonTE = XAAOverPolyText8NonTE;
    276     if(infoRec->PolyText16NonTE)
    277 	infoRec->PolyText16NonTE = XAAOverPolyText16NonTE;
    278     if(infoRec->ImageText8NonTE)
    279 	infoRec->ImageText8NonTE = XAAOverImageText8NonTE;
    280     if(infoRec->ImageText16NonTE)
    281 	infoRec->ImageText16NonTE = XAAOverImageText16NonTE;
    282     if(infoRec->ImageGlyphBltNonTE)
    283 	infoRec->ImageGlyphBltNonTE = XAAOverImageGlyphBltNonTE;
    284     if(infoRec->PolyGlyphBltNonTE)
    285 	infoRec->PolyGlyphBltNonTE = XAAOverPolyGlyphBltNonTE;
    286     if(infoRec->PolyRectangleThinSolid)
    287 	infoRec->PolyRectangleThinSolid = XAAOverPolyRectangleThinSolid;
    288     if(infoRec->PolylinesWideSolid)
    289 	infoRec->PolylinesWideSolid = XAAOverPolylinesWideSolid;
    290     if(infoRec->PolylinesThinSolid)
    291 	infoRec->PolylinesThinSolid = XAAOverPolylinesThinSolid;
    292     if(infoRec->PolySegmentThinSolid)
    293 	infoRec->PolySegmentThinSolid = XAAOverPolySegmentThinSolid;
    294     if(infoRec->PolylinesThinDashed)
    295 	infoRec->PolylinesThinDashed = XAAOverPolylinesThinDashed;
    296     if(infoRec->PolySegmentThinDashed)
    297 	infoRec->PolySegmentThinDashed = XAAOverPolySegmentThinDashed;
    298     if(infoRec->FillPolygonSolid)
    299 	infoRec->FillPolygonSolid = XAAOverFillPolygonSolid;
    300     if(infoRec->FillPolygonStippled)
    301 	infoRec->FillPolygonStippled = XAAOverFillPolygonStippled;
    302     if(infoRec->FillPolygonOpaqueStippled)
    303 	infoRec->FillPolygonOpaqueStippled = XAAOverFillPolygonOpaqueStippled;
    304     if(infoRec->FillPolygonTiled)
    305 	infoRec->FillPolygonTiled = XAAOverFillPolygonTiled;
    306     if(infoRec->PolyFillArcSolid)
    307 	infoRec->PolyFillArcSolid = XAAOverPolyFillArcSolid;
    308     if(infoRec->PutImage)
    309 	infoRec->PutImage = XAAOverPutImage;
    310 
    311     return TRUE;
    312 }
    313 
    314 /***********************  Screen functions ************************/
    315 
    316 void
    317 XAAOverCopyWindow(
    318     WindowPtr pWin,
    319     DDXPointRec ptOldOrg,
    320     RegionPtr prgnSrc
    321 ){
    322     ScreenPtr pScreen = pWin->drawable.pScreen;
    323     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
    324     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen);
    325     ScrnInfoPtr pScrn = infoRec->pScrn;
    326     DDXPointPtr ppt, pptSrc;
    327     RegionRec rgnDst;
    328     BoxPtr pbox;
    329     int i, nbox, dx, dy;
    330     WindowPtr pRoot = pScreen->root;
    331 
    332 
    333     if (!pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) {
    334 	XAA_SCREEN_PROLOGUE (pScreen, CopyWindow);
    335 	if(pScrn->vtSema && infoRec->NeedToSync) {
    336 	    (*infoRec->Sync)(pScrn);
    337 	    infoRec->NeedToSync = FALSE;
    338 	}
    339         (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
    340 	XAA_SCREEN_EPILOGUE (pScreen, CopyWindow, XAAOverCopyWindow);
    341     	return;
    342     }
    343 
    344     infoRec->ScratchGC.alu = GXcopy;
    345     infoRec->ScratchGC.planemask = ~0;
    346 
    347     RegionNull(&rgnDst);
    348 
    349     dx = ptOldOrg.x - pWin->drawable.x;
    350     dy = ptOldOrg.y - pWin->drawable.y;
    351     RegionTranslate(prgnSrc, -dx, -dy);
    352     RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
    353 
    354     nbox = RegionNumRects(&rgnDst);
    355     if(nbox &&
    356 	(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) {
    357 
    358 	pbox = RegionRects(&rgnDst);
    359 	for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
    360 	    ppt->x = pbox->x1 + dx;
    361 	    ppt->y = pbox->y1 + dy;
    362 	}
    363 
    364 	SWITCH_DEPTH(8);
    365 	XAADoBitBlt((DrawablePtr)pRoot, (DrawablePtr)pRoot,
    366         		&(infoRec->ScratchGC), &rgnDst, pptSrc);
    367 
    368 	if(pWin->drawable.bitsPerPixel != 8) {
    369 	    SWITCH_DEPTH(pScrn->depth);
    370 	    XAADoBitBlt((DrawablePtr)pRoot, (DrawablePtr)pRoot,
    371         		&(infoRec->ScratchGC), &rgnDst, pptSrc);
    372 	}
    373 
    374 	free(pptSrc);
    375     }
    376 
    377     RegionUninit(&rgnDst);
    378 
    379     if(pWin->drawable.depth == 8) {
    380       RegionNull(&rgnDst);
    381       miSegregateChildren(pWin, &rgnDst, pScrn->depth);
    382       if(RegionNotEmpty(&rgnDst)) {
    383 	RegionIntersect(&rgnDst, &rgnDst, prgnSrc);
    384 	nbox = RegionNumRects(&rgnDst);
    385 	if(nbox &&
    386 	  (pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))){
    387 
    388 	    pbox = RegionRects(&rgnDst);
    389 	    for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
    390 		ppt->x = pbox->x1 + dx;
    391 		ppt->y = pbox->y1 + dy;
    392 	    }
    393 
    394 	    SWITCH_DEPTH(pScrn->depth);
    395 	    XAADoBitBlt((DrawablePtr)pRoot, (DrawablePtr)pRoot,
    396         		&(infoRec->ScratchGC), &rgnDst, pptSrc);
    397 	    free(pptSrc);
    398 	}
    399       }
    400       RegionUninit(&rgnDst);
    401     }
    402 }
    403 
    404 
    405 void
    406 XAAOverWindowExposures(
    407    WindowPtr pWin,
    408    RegionPtr pReg,
    409    RegionPtr pOtherReg
    410 ){
    411     ScreenPtr pScreen = pWin->drawable.pScreen;
    412     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
    413 
    414     if((pWin->drawable.bitsPerPixel != 8) && infoRec->pScrn->vtSema) {
    415 	if(RegionNumRects(pReg) && infoRec->FillSolidRects) {
    416 	    XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen);
    417 
    418 	    SWITCH_DEPTH(8);
    419 	    (*infoRec->FillSolidRects)(infoRec->pScrn,
    420 		infoRec->pScrn->colorKey, GXcopy, ~0,
    421 			RegionNumRects(pReg), RegionRects(pReg));
    422 	    miWindowExposures(pWin, pReg, pOtherReg);
    423 	    return;
    424 	} else if(infoRec->NeedToSync) {
    425             (*infoRec->Sync)(infoRec->pScrn);
    426             infoRec->NeedToSync = FALSE;
    427 	}
    428     }
    429 
    430     XAA_SCREEN_PROLOGUE (pScreen, WindowExposures);
    431     (*pScreen->WindowExposures) (pWin, pReg, pOtherReg);
    432     XAA_SCREEN_EPILOGUE(pScreen, WindowExposures, XAAOverWindowExposures);
    433 }
    434 
    435 /*********************  Choosers *************************/
    436 
    437 static int
    438 XAAOverStippledFillChooser(GCPtr pGC)
    439 {
    440     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    441     int ret;
    442 
    443     ret = (*pOverPriv->StippledFillChooser)(pGC);
    444 
    445     if((pGC->depth == 8) &&
    446 	((ret == DO_COLOR_8x8) || (ret == DO_CACHE_BLT))) {
    447 	ret = 0;
    448     }
    449 
    450     return ret;
    451 }
    452 
    453 static int
    454 XAAOverOpaqueStippledFillChooser(GCPtr pGC)
    455 {
    456     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    457     int ret;
    458 
    459     ret = (*pOverPriv->OpaqueStippledFillChooser)(pGC);
    460 
    461     if((pGC->depth == 8) &&
    462 	((ret == DO_COLOR_8x8) || (ret == DO_CACHE_BLT))) {
    463 	ret = 0;
    464     }
    465 
    466     return ret;
    467 }
    468 
    469 static int
    470 XAAOverTiledFillChooser(GCPtr pGC)
    471 {
    472     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    473     int ret;
    474 
    475     ret = (*pOverPriv->TiledFillChooser)(pGC);
    476 
    477     if((pGC->depth == 8) &&
    478 	((ret == DO_COLOR_8x8) || (ret == DO_CACHE_BLT))) {
    479 	ret = 0;
    480     }
    481 
    482     return ret;
    483 }
    484 
    485 
    486 /**************************** GC Functions **************************/
    487 
    488 static RegionPtr
    489 XAAOverCopyArea(
    490    DrawablePtr pSrc,
    491    DrawablePtr pDst,
    492    GC *pGC,
    493    int srcx, int srcy,
    494    int width, int height,
    495    int dstx, int dsty
    496 ){
    497     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    498 
    499     SWITCH_DEPTH(pGC->depth);
    500 
    501     return (*pOverPriv->CopyArea)(pSrc, pDst,
    502 		pGC, srcx, srcy, width, height, dstx, dsty);
    503 }
    504 
    505 static RegionPtr
    506 XAAOverCopyPlane(
    507    DrawablePtr pSrc,
    508    DrawablePtr pDst,
    509    GCPtr pGC,
    510    int srcx, int srcy,
    511    int width, int height,
    512    int dstx, int dsty,
    513    unsigned long bitPlane
    514 ){
    515     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    516 
    517     SWITCH_DEPTH(pGC->depth);
    518 
    519     return (*pOverPriv->CopyPlane)(pSrc, pDst,
    520 	       pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
    521 
    522 }
    523 
    524 static void
    525 XAAOverPushPixelsSolid(
    526    GCPtr pGC,
    527    PixmapPtr pBitMap,
    528    DrawablePtr pDraw,
    529    int dx, int dy,
    530    int xOrg, int yOrg
    531 ){
    532     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    533 
    534     SWITCH_DEPTH(pGC->depth);
    535 
    536     (*pOverPriv->PushPixelsSolid)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
    537 }
    538 
    539 
    540 
    541 static void
    542 XAAOverPolyFillRectSolid(
    543    DrawablePtr pDraw,
    544    GCPtr pGC,
    545    int nrectFill,
    546    xRectangle *prectInit
    547 ){
    548     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    549 
    550     SWITCH_DEPTH(pGC->depth);
    551 
    552     (*pOverPriv->PolyFillRectSolid)(pDraw, pGC, nrectFill, prectInit);
    553 }
    554 
    555 static void
    556 XAAOverPolyFillRectStippled(
    557    DrawablePtr pDraw,
    558    GCPtr pGC,
    559    int nrectFill,
    560    xRectangle *prectInit
    561 ){
    562     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    563 
    564     SWITCH_DEPTH(pGC->depth);
    565 
    566     (*pOverPriv->PolyFillRectStippled)(pDraw, pGC, nrectFill, prectInit);
    567 }
    568 
    569 
    570 static void
    571 XAAOverPolyFillRectOpaqueStippled(
    572    DrawablePtr pDraw,
    573    GCPtr pGC,
    574    int nrectFill,
    575    xRectangle *prectInit
    576 ){
    577     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    578 
    579     SWITCH_DEPTH(pGC->depth);
    580 
    581     (*pOverPriv->PolyFillRectOpaqueStippled)(pDraw, pGC, nrectFill, prectInit);
    582 }
    583 
    584 static void
    585 XAAOverPolyFillRectTiled(
    586    DrawablePtr pDraw,
    587    GCPtr pGC,
    588    int nrectFill,
    589    xRectangle *prectInit
    590 ){
    591     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    592 
    593     SWITCH_DEPTH(pGC->depth);
    594 
    595     (*pOverPriv->PolyFillRectTiled)(pDraw, pGC, nrectFill, prectInit);
    596 }
    597 
    598 
    599 static void
    600 XAAOverFillSpansSolid(
    601    DrawablePtr	pDraw,
    602    GCPtr	pGC,
    603    int		nInit,
    604    DDXPointPtr 	ppt,
    605    int		*pwidth,
    606    int		fSorted
    607 ){
    608     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    609 
    610     SWITCH_DEPTH(pGC->depth);
    611 
    612     (*pOverPriv->FillSpansSolid)(
    613 		pDraw, pGC, nInit, ppt, pwidth, fSorted);
    614 }
    615 
    616 
    617 static void
    618 XAAOverFillSpansStippled(
    619    DrawablePtr	pDraw,
    620    GCPtr	pGC,
    621    int		nInit,
    622    DDXPointPtr 	ppt,
    623    int		*pwidth,
    624    int		fSorted
    625 ){
    626     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    627 
    628     SWITCH_DEPTH(pGC->depth);
    629 
    630     (*pOverPriv->FillSpansStippled)(pDraw, pGC, nInit, ppt, pwidth, fSorted);
    631 }
    632 
    633 static void
    634 XAAOverFillSpansOpaqueStippled(
    635    DrawablePtr	pDraw,
    636    GCPtr	pGC,
    637    int		nInit,
    638    DDXPointPtr 	ppt,
    639    int		*pwidth,
    640    int		fSorted
    641 ){
    642     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    643 
    644     SWITCH_DEPTH(pGC->depth);
    645 
    646     (*pOverPriv->FillSpansOpaqueStippled)(
    647 		pDraw, pGC, nInit, ppt, pwidth, fSorted);
    648 }
    649 
    650 
    651 static void
    652 XAAOverFillSpansTiled(
    653    DrawablePtr	pDraw,
    654    GCPtr	pGC,
    655    int		nInit,
    656    DDXPointPtr 	ppt,
    657    int		*pwidth,
    658    int		fSorted
    659 ){
    660     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    661 
    662     SWITCH_DEPTH(pGC->depth);
    663 
    664     (*pOverPriv->FillSpansTiled)(pDraw, pGC, nInit, ppt, pwidth, fSorted);
    665 }
    666 
    667 static int
    668 XAAOverPolyText8TE(
    669    DrawablePtr pDraw,
    670    GCPtr pGC,
    671    int x, int y,
    672    int count,
    673    char *chars
    674 ){
    675     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    676 
    677     SWITCH_DEPTH(pGC->depth);
    678 
    679     return (*pOverPriv->PolyText8TE)(pDraw, pGC, x, y, count, chars);
    680 }
    681 
    682 
    683 static int
    684 XAAOverPolyText16TE(
    685    DrawablePtr pDraw,
    686    GCPtr pGC,
    687    int x, int y,
    688    int count,
    689    unsigned short *chars
    690 ){
    691     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    692 
    693     SWITCH_DEPTH(pGC->depth);
    694 
    695     return (*pOverPriv->PolyText16TE)(pDraw, pGC, x, y, count, chars);
    696 }
    697 
    698 
    699 static void
    700 XAAOverImageText8TE(
    701    DrawablePtr pDraw,
    702    GCPtr pGC,
    703    int x, int y,
    704    int count,
    705    char *chars
    706 ){
    707     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    708 
    709     SWITCH_DEPTH(pGC->depth);
    710 
    711     (*pOverPriv->ImageText8TE)(pDraw, pGC, x, y, count, chars);
    712 }
    713 
    714 
    715 static void
    716 XAAOverImageText16TE(
    717    DrawablePtr pDraw,
    718    GCPtr pGC,
    719    int x, int y,
    720    int count,
    721    unsigned short *chars
    722 ){
    723     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    724 
    725     SWITCH_DEPTH(pGC->depth);
    726 
    727     (*pOverPriv->ImageText16TE)(pDraw, pGC, x, y, count, chars);
    728 }
    729 
    730 static void
    731 XAAOverImageGlyphBltTE(
    732    DrawablePtr pDraw,
    733    GCPtr pGC,
    734    int xInit, int yInit,
    735    unsigned int nglyph,
    736    CharInfoPtr *ppci,
    737    pointer pglyphBase
    738 ){
    739     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    740 
    741     SWITCH_DEPTH(pGC->depth);
    742 
    743     (*pOverPriv->ImageGlyphBltTE)(
    744 	pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
    745 }
    746 
    747 static void
    748 XAAOverPolyGlyphBltTE(
    749    DrawablePtr pDraw,
    750    GCPtr pGC,
    751    int xInit, int yInit,
    752    unsigned int nglyph,
    753    CharInfoPtr *ppci,
    754    pointer pglyphBase
    755 ){
    756     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    757 
    758     SWITCH_DEPTH(pGC->depth);
    759 
    760     (*pOverPriv->PolyGlyphBltTE)(
    761 	pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
    762 }
    763 
    764 static int
    765 XAAOverPolyText8NonTE(
    766    DrawablePtr pDraw,
    767    GCPtr pGC,
    768    int x, int y,
    769    int count,
    770    char *chars
    771 ){
    772     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    773 
    774     SWITCH_DEPTH(pGC->depth);
    775 
    776     return (*pOverPriv->PolyText8NonTE)(pDraw, pGC, x, y, count, chars);
    777 }
    778 
    779 
    780 static int
    781 XAAOverPolyText16NonTE(
    782    DrawablePtr pDraw,
    783    GCPtr pGC,
    784    int x, int y,
    785    int count,
    786    unsigned short *chars
    787 ){
    788     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    789 
    790     SWITCH_DEPTH(pGC->depth);
    791 
    792     return (*pOverPriv->PolyText16NonTE)(pDraw, pGC, x, y, count, chars);
    793 }
    794 
    795 static void
    796 XAAOverImageText8NonTE(
    797    DrawablePtr pDraw,
    798    GCPtr pGC,
    799    int x, int y,
    800    int count,
    801    char *chars
    802 ){
    803     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    804 
    805     SWITCH_DEPTH(pGC->depth);
    806 
    807     (*pOverPriv->ImageText8NonTE)(pDraw, pGC, x, y, count, chars);
    808 }
    809 
    810 static void
    811 XAAOverImageText16NonTE(
    812    DrawablePtr pDraw,
    813    GCPtr pGC,
    814    int x, int y,
    815    int count,
    816    unsigned short *chars
    817 ){
    818     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    819 
    820     SWITCH_DEPTH(pGC->depth);
    821 
    822     (*pOverPriv->ImageText16NonTE)(pDraw, pGC, x, y, count, chars);
    823 }
    824 
    825 
    826 static void
    827 XAAOverImageGlyphBltNonTE(
    828    DrawablePtr pDraw,
    829    GCPtr pGC,
    830    int xInit, int yInit,
    831    unsigned int nglyph,
    832    CharInfoPtr *ppci,
    833    pointer pglyphBase
    834 ){
    835     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    836 
    837     SWITCH_DEPTH(pGC->depth);
    838 
    839     (*pOverPriv->ImageGlyphBltNonTE)(
    840 		pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
    841 }
    842 
    843 static void
    844 XAAOverPolyGlyphBltNonTE(
    845    DrawablePtr pDraw,
    846    GCPtr pGC,
    847    int xInit, int yInit,
    848    unsigned int nglyph,
    849    CharInfoPtr *ppci,
    850    pointer pglyphBase
    851 ){
    852     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    853 
    854     SWITCH_DEPTH(pGC->depth);
    855 
    856     (*pOverPriv->PolyGlyphBltNonTE)(
    857 		pDraw, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
    858 }
    859 
    860 static void
    861 XAAOverPolyRectangleThinSolid(
    862    DrawablePtr  pDraw,
    863    GCPtr        pGC,
    864    int	    	nRectsInit,
    865    xRectangle  *pRectsInit
    866 ){
    867     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    868 
    869     SWITCH_DEPTH(pGC->depth);
    870 
    871     (*pOverPriv->PolyRectangleThinSolid)(pDraw, pGC, nRectsInit, pRectsInit);
    872 }
    873 
    874 
    875 
    876 static void
    877 XAAOverPolylinesWideSolid(
    878    DrawablePtr	pDraw,
    879    GCPtr	pGC,
    880    int		mode,
    881    int 		npt,
    882    DDXPointPtr pPts
    883 ){
    884     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    885 
    886     SWITCH_DEPTH(pGC->depth);
    887 
    888     (*pOverPriv->PolylinesWideSolid)(pDraw, pGC, mode, npt, pPts);
    889 }
    890 
    891 
    892 static void
    893 XAAOverPolylinesThinSolid(
    894    DrawablePtr	pDraw,
    895    GCPtr	pGC,
    896    int		mode,
    897    int 		npt,
    898    DDXPointPtr pPts
    899 ){
    900     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    901 
    902     SWITCH_DEPTH(pGC->depth);
    903 
    904     (*pOverPriv->PolylinesThinSolid)(pDraw, pGC, mode, npt, pPts);
    905 }
    906 
    907 static void
    908 XAAOverPolySegmentThinSolid(
    909    DrawablePtr	pDraw,
    910    GCPtr	pGC,
    911    int		nseg,
    912    xSegment	*pSeg
    913 ){
    914     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    915 
    916     SWITCH_DEPTH(pGC->depth);
    917 
    918     (*pOverPriv->PolySegmentThinSolid)(pDraw, pGC, nseg, pSeg);
    919 }
    920 
    921 static void
    922 XAAOverPolylinesThinDashed(
    923    DrawablePtr	pDraw,
    924    GCPtr	pGC,
    925    int		mode,
    926    int 		npt,
    927    DDXPointPtr pPts
    928 ){
    929     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    930 
    931     SWITCH_DEPTH(pGC->depth);
    932 
    933     (*pOverPriv->PolylinesThinDashed)(pDraw, pGC, mode, npt, pPts);
    934 }
    935 
    936 static void
    937 XAAOverPolySegmentThinDashed(
    938    DrawablePtr	pDraw,
    939    GCPtr	pGC,
    940    int		nseg,
    941    xSegment	*pSeg
    942 ){
    943     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    944 
    945     SWITCH_DEPTH(pGC->depth);
    946 
    947     (*pOverPriv->PolySegmentThinDashed)(pDraw, pGC, nseg, pSeg);
    948 }
    949 
    950 
    951 static void
    952 XAAOverFillPolygonSolid(
    953    DrawablePtr	pDraw,
    954    GCPtr	pGC,
    955    int		shape,
    956    int		mode,
    957    int		count,
    958    DDXPointPtr	ptsIn
    959 ){
    960     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    961 
    962     SWITCH_DEPTH(pGC->depth);
    963 
    964     (*pOverPriv->FillPolygonSolid)(pDraw, pGC, shape, mode, count, ptsIn);
    965 }
    966 
    967 static void
    968 XAAOverFillPolygonStippled(
    969    DrawablePtr	pDraw,
    970    GCPtr	pGC,
    971    int		shape,
    972    int		mode,
    973    int		count,
    974    DDXPointPtr	ptsIn
    975 ){
    976     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    977 
    978     SWITCH_DEPTH(pGC->depth);
    979 
    980     (*pOverPriv->FillPolygonStippled)(pDraw, pGC, shape, mode, count, ptsIn);
    981 }
    982 
    983 
    984 static void
    985 XAAOverFillPolygonOpaqueStippled(
    986    DrawablePtr	pDraw,
    987    GCPtr	pGC,
    988    int		shape,
    989    int		mode,
    990    int		count,
    991    DDXPointPtr	ptsIn
    992 ){
    993     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
    994 
    995     SWITCH_DEPTH(pGC->depth);
    996 
    997     (*pOverPriv->FillPolygonOpaqueStippled)(
    998 			pDraw, pGC, shape, mode, count, ptsIn);
    999 }
   1000 
   1001 static void
   1002 XAAOverFillPolygonTiled(
   1003    DrawablePtr	pDraw,
   1004    GCPtr	pGC,
   1005    int		shape,
   1006    int		mode,
   1007    int		count,
   1008    DDXPointPtr	ptsIn
   1009 ){
   1010     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
   1011 
   1012     SWITCH_DEPTH(pGC->depth);
   1013 
   1014     (*pOverPriv->FillPolygonTiled)(pDraw, pGC, shape, mode, count, ptsIn);
   1015 }
   1016 
   1017 
   1018 static void
   1019 XAAOverPolyFillArcSolid(
   1020    DrawablePtr	pDraw,
   1021    GCPtr	pGC,
   1022    int		narcs,
   1023    xArc		*parcs
   1024 ){
   1025     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
   1026 
   1027     SWITCH_DEPTH(pGC->depth);
   1028 
   1029     (*pOverPriv->PolyFillArcSolid)(pDraw, pGC, narcs, parcs);
   1030 }
   1031 
   1032 
   1033 static void
   1034 XAAOverPutImage(
   1035    DrawablePtr	pDraw,
   1036    GCPtr	pGC,
   1037    int		depth,
   1038    int		x,
   1039    int		y,
   1040    int		w,
   1041    int		h,
   1042    int		leftPad,
   1043    int		format,
   1044    char		*pImage
   1045 ){
   1046     XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pGC->pScreen);
   1047 
   1048     SWITCH_DEPTH(pGC->depth);
   1049 
   1050     (*pOverPriv->PutImage)(pDraw, pGC, depth, x, y, w, h,
   1051 				leftPad, format, pImage);
   1052 }
   1053 
   1054