diff options
Diffstat (limited to 'mi/misprite.c')
-rw-r--r-- | mi/misprite.c | 415 |
1 files changed, 336 insertions, 79 deletions
diff --git a/mi/misprite.c b/mi/misprite.c index 2fc6da8dd..d323f1168 100644 --- a/mi/misprite.c +++ b/mi/misprite.c @@ -30,6 +30,7 @@ Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/programs/Xserver/mi/misprite.c,v 3.11 2002/12/09 04:10:58 tsi Exp $ */ # include "X.h" # include "Xproto.h" @@ -47,6 +48,9 @@ in this Software without prior written authorization from The Open Group. # include "mispritest.h" # include "dixfontstr.h" # include "fontstruct.h" +#ifdef RENDER +# include "mipict.h" +#endif /* * screen wrappers @@ -55,23 +59,63 @@ in this Software without prior written authorization from The Open Group. static int miSpriteScreenIndex; static unsigned long miSpriteGeneration = 0; -static Bool miSpriteCloseScreen(); -static void miSpriteGetImage(); -static void miSpriteGetSpans(); -static void miSpriteSourceValidate(); -static Bool miSpriteCreateGC(); -static void miSpriteBlockHandler(); -static void miSpriteInstallColormap(); -static void miSpriteStoreColors(); - -static void miSpritePaintWindowBackground(); -static void miSpritePaintWindowBorder(); -static void miSpriteCopyWindow(); -static void miSpriteClearToBackground(); +static Bool miSpriteCloseScreen(int i, ScreenPtr pScreen); +static void miSpriteGetImage(DrawablePtr pDrawable, int sx, int sy, + int w, int h, unsigned int format, + unsigned long planemask, char *pdstLine); +static void miSpriteGetSpans(DrawablePtr pDrawable, int wMax, + DDXPointPtr ppt, int *pwidth, int nspans, + char *pdstStart); +static void miSpriteSourceValidate(DrawablePtr pDrawable, int x, int y, + int width, int height); +static Bool miSpriteCreateGC(GCPtr pGC); +static void miSpriteBlockHandler(int i, pointer blockData, + pointer pTimeout, + pointer pReadMask); +static void miSpriteInstallColormap(ColormapPtr pMap); +static void miSpriteStoreColors(ColormapPtr pMap, int ndef, + xColorItem *pdef); + +static void miSpritePaintWindowBackground(WindowPtr pWin, + RegionPtr pRegion, int what); +static void miSpritePaintWindowBorder(WindowPtr pWin, + RegionPtr pRegion, int what); +static void miSpriteCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, + RegionPtr pRegion); +static void miSpriteClearToBackground(WindowPtr pWin, int x, int y, + int w, int h, + Bool generateExposures); + +#ifdef RENDER +static void miSpriteComposite(CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height); + +static void miSpriteGlyphs(CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlist, + GlyphListPtr list, + GlyphPtr *glyphs); +#endif -static void miSpriteSaveDoomedAreas(); -static RegionPtr miSpriteRestoreAreas(); -static void miSpriteComputeSaved(); +static void miSpriteSaveDoomedAreas(WindowPtr pWin, + RegionPtr pObscured, int dx, + int dy); +static RegionPtr miSpriteRestoreAreas(WindowPtr pWin, RegionPtr pRgnExposed); +static void miSpriteComputeSaved(ScreenPtr pScreen); #define SCREEN_PROLOGUE(pScreen, field)\ ((pScreen)->field = \ @@ -86,10 +130,14 @@ static void miSpriteComputeSaved(); static int miSpriteGCIndex; -static void miSpriteValidateGC (), miSpriteCopyGC (); -static void miSpriteDestroyGC(), miSpriteChangeGC(); -static void miSpriteChangeClip(), miSpriteDestroyClip(); -static void miSpriteCopyClip(); +static void miSpriteValidateGC(GCPtr pGC, unsigned long stateChanges, + DrawablePtr pDrawable); +static void miSpriteCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst); +static void miSpriteDestroyGC(GCPtr pGC); +static void miSpriteChangeGC(GCPtr pGC, unsigned long mask); +static void miSpriteChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects); +static void miSpriteDestroyClip(GCPtr pGC); +static void miSpriteCopyClip(GCPtr pgcDst, GCPtr pgcSrc); static GCFuncs miSpriteGCFuncs = { miSpriteValidateGC, @@ -121,19 +169,62 @@ static GCFuncs miSpriteGCFuncs = { * GC op wrappers */ -static void miSpriteFillSpans(), miSpriteSetSpans(); -static void miSpritePutImage(); -static RegionPtr miSpriteCopyArea(), miSpriteCopyPlane(); -static void miSpritePolyPoint(), miSpritePolylines(); -static void miSpritePolySegment(), miSpritePolyRectangle(); -static void miSpritePolyArc(), miSpriteFillPolygon(); -static void miSpritePolyFillRect(), miSpritePolyFillArc(); -static int miSpritePolyText8(), miSpritePolyText16(); -static void miSpriteImageText8(), miSpriteImageText16(); -static void miSpriteImageGlyphBlt(), miSpritePolyGlyphBlt(); -static void miSpritePushPixels(); +static void miSpriteFillSpans(DrawablePtr pDrawable, GCPtr pGC, + int nInit, DDXPointPtr pptInit, + int *pwidthInit, int fSorted); +static void miSpriteSetSpans(DrawablePtr pDrawable, GCPtr pGC, + char *psrc, DDXPointPtr ppt, int *pwidth, + int nspans, int fSorted); +static void miSpritePutImage(DrawablePtr pDrawable, GCPtr pGC, + int depth, int x, int y, int w, int h, + int leftPad, int format, char *pBits); +static RegionPtr miSpriteCopyArea(DrawablePtr pSrc, DrawablePtr pDst, + GCPtr pGC, int srcx, int srcy, int w, + int h, int dstx, int dsty); +static RegionPtr miSpriteCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, + GCPtr pGC, int srcx, int srcy, int w, + int h, int dstx, int dsty, + unsigned long plane); +static void miSpritePolyPoint(DrawablePtr pDrawable, GCPtr pGC, + int mode, int npt, xPoint *pptInit); +static void miSpritePolylines(DrawablePtr pDrawable, GCPtr pGC, + int mode, int npt, DDXPointPtr pptInit); +static void miSpritePolySegment(DrawablePtr pDrawable, GCPtr pGC, + int nseg, xSegment *pSegs); +static void miSpritePolyRectangle(DrawablePtr pDrawable, GCPtr pGC, + int nrects, xRectangle *pRects); +static void miSpritePolyArc(DrawablePtr pDrawable, GCPtr pGC, + int narcs, xArc *parcs); +static void miSpriteFillPolygon(DrawablePtr pDrawable, GCPtr pGC, + int shape, int mode, int count, + DDXPointPtr pPts); +static void miSpritePolyFillRect(DrawablePtr pDrawable, GCPtr pGC, + int nrectFill, xRectangle *prectInit); +static void miSpritePolyFillArc(DrawablePtr pDrawable, GCPtr pGC, + int narcs, xArc *parcs); +static int miSpritePolyText8(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, char *chars); +static int miSpritePolyText16(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, + unsigned short *chars); +static void miSpriteImageText8(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, char *chars); +static void miSpriteImageText16(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, + unsigned short *chars); +static void miSpriteImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase); +static void miSpritePolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase); +static void miSpritePushPixels(GCPtr pGC, PixmapPtr pBitMap, + DrawablePtr pDst, int w, int h, + int x, int y); #ifdef NEED_LINEHELPER -static void miSpriteLineHelper(); +static void miSpriteLineHelper(void); #endif static GCOps miSpriteGCOps = { @@ -174,7 +265,7 @@ static GCOps miSpriteGCOps = { (pScreenPriv->isUp && \ (pScreenPriv->pCacheWin == pWin ? \ pScreenPriv->isInCacheWin : ( \ - ((int) (pScreenPriv->pCacheWin = (pWin))) , \ + (pScreenPriv->pCacheWin = (pWin)), \ (pScreenPriv->isInCacheWin = \ (pWin)->drawable.x < pScreenPriv->saved.x2 && \ pScreenPriv->saved.x1 < (pWin)->drawable.x + \ @@ -200,8 +291,11 @@ static GCOps miSpriteGCOps = { * pointer-sprite method table */ -static Bool miSpriteRealizeCursor (), miSpriteUnrealizeCursor (); -static void miSpriteSetCursor (), miSpriteMoveCursor (); +static Bool miSpriteRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); +static Bool miSpriteUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); +static void miSpriteSetCursor(ScreenPtr pScreen, CursorPtr pCursor, + int x, int y); +static void miSpriteMoveCursor(ScreenPtr pScreen, int x, int y); miPointerSpriteFuncRec miSpritePointerFuncs = { miSpriteRealizeCursor, @@ -214,7 +308,8 @@ miPointerSpriteFuncRec miSpritePointerFuncs = { * other misc functions */ -static void miSpriteRemoveCursor (), miSpriteRestoreCursor(); +static void miSpriteRemoveCursor(ScreenPtr pScreen); +static void miSpriteRestoreCursor(ScreenPtr pScreen); /* * miSpriteInitialize -- called from device-dependent screen @@ -230,6 +325,9 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) { miSpriteScreenPtr pPriv; VisualPtr pVisual; +#ifdef RENDER + PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); +#endif if (miSpriteGeneration != serverGeneration) { @@ -270,7 +368,14 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) pPriv->SaveDoomedAreas = pScreen->SaveDoomedAreas; pPriv->RestoreAreas = pScreen->RestoreAreas; - +#ifdef RENDER + if (ps) + { + pPriv->Composite = ps->Composite; + pPriv->Glyphs = ps->Glyphs; + } +#endif + pPriv->pCursor = NULL; pPriv->x = 0; pPriv->y = 0; @@ -305,6 +410,13 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) pScreen->SaveDoomedAreas = miSpriteSaveDoomedAreas; pScreen->RestoreAreas = miSpriteRestoreAreas; +#ifdef RENDER + if (ps) + { + ps->Composite = miSpriteComposite; + ps->Glyphs = miSpriteGlyphs; + } +#endif return TRUE; } @@ -320,9 +432,13 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) static Bool miSpriteCloseScreen (i, pScreen) + int i; ScreenPtr pScreen; { miSpriteScreenPtr pScreenPriv; +#ifdef RENDER + PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); +#endif pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; @@ -342,7 +458,13 @@ miSpriteCloseScreen (i, pScreen) pScreen->SaveDoomedAreas = pScreenPriv->SaveDoomedAreas; pScreen->RestoreAreas = pScreenPriv->RestoreAreas; - +#ifdef RENDER + if (ps) + { + ps->Composite = pScreenPriv->Composite; + ps->Glyphs = pScreenPriv->Glyphs; + } +#endif xfree ((pointer) pScreenPriv); return (*pScreen->CloseScreen) (i, pScreen); @@ -473,7 +595,7 @@ static void miSpriteBlockHandler (i, blockData, pTimeout, pReadmask) int i; pointer blockData; - OSTimePtr pTimeout; + pointer pTimeout; pointer pReadmask; { ScreenPtr pScreen = screenInfo.screens[i]; @@ -543,7 +665,7 @@ miSpriteStoreColors (pMap, ndef, pdef) { /* Direct color - match on any of the subfields */ -#define MaskMatch(a,b,mask) ((a) & (pVisual->mask) == (b) & (pVisual->mask)) +#define MaskMatch(a,b,mask) (((a) & (pVisual->mask)) == ((b) & (pVisual->mask))) #define UpdateDAC(plane,dac,mask) {\ if (MaskMatch (pPriv->colors[plane].pixel,pdef[i].pixel,mask)) {\ @@ -592,8 +714,7 @@ miSpriteStoreColors (pMap, ndef, pdef) } static void -miSpriteFindColors (pScreen) - ScreenPtr pScreen; +miSpriteFindColors (ScreenPtr pScreen) { miSpriteScreenPtr pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; @@ -798,8 +919,8 @@ miSpriteCopyWindow (pWin, ptOldOrg, pRegion) static void miSpriteClearToBackground (pWin, x, y, w, h, generateExposures) WindowPtr pWin; - short x,y; - unsigned short w,h; + int x,y; + int w,h; Bool generateExposures; { ScreenPtr pScreen; @@ -836,7 +957,7 @@ miSpriteClearToBackground (pWin, x, y, w, h, generateExposures) static void miSpriteValidateGC (pGC, changes, pDrawable) GCPtr pGC; - Mask changes; + unsigned long changes; DrawablePtr pDrawable; { GC_FUNC_PROLOGUE (pGC); @@ -1017,6 +1138,7 @@ miSpritePutImage(pDrawable, pGC, depth, x, y, w, h, leftPad, format, pBits) int y; int w; int h; + int leftPad; int format; char *pBits; { @@ -1517,15 +1639,16 @@ miSpritePolyFillArc(pDrawable, pGC, narcs, parcs) */ static Bool -miSpriteTextOverlap (pDraw, font, x, y, n, charinfo, imageblt, w, cursorBox) - DrawablePtr pDraw; - FontPtr font; - int x, y; - unsigned int n; - CharInfoPtr *charinfo; - Bool imageblt; - unsigned int w; - BoxPtr cursorBox; +miSpriteTextOverlap ( + DrawablePtr pDraw, + FontPtr font, + int x, + int y, + unsigned int n, + CharInfoPtr *charinfo, + Bool imageblt, + unsigned int w, + BoxPtr cursorBox) { ExtentInfoRec extents; @@ -1599,23 +1722,22 @@ miSpriteTextOverlap (pDraw, font, x, y, n, charinfo, imageblt, w, cursorBox) #define TT_IMAGE16 3 static int -miSpriteText (pDraw, pGC, x, y, count, chars, fontEncoding, textType, cursorBox) - DrawablePtr pDraw; - GCPtr pGC; +miSpriteText ( + DrawablePtr pDraw, + GCPtr pGC, int x, - y; - unsigned long count; - char *chars; - FontEncoding fontEncoding; - Bool textType; - BoxPtr cursorBox; + int y, + unsigned long count, + char *chars, + FontEncoding fontEncoding, + Bool textType, + BoxPtr cursorBox) { CharInfoPtr *charinfo; register CharInfoPtr *info; unsigned long i; unsigned int n; int w; - void (*drawFunc)(); Bool imageblt; @@ -1646,27 +1768,33 @@ miSpriteText (pDraw, pGC, x, y, count, chars, fontEncoding, textType, cursorBox) switch (textType) { case TT_POLY8: - drawFunc = (void (*)())pGC->ops->PolyText8; + (*pGC->ops->PolyText8)(pDraw, pGC, x, y, (int)count, chars); break; case TT_IMAGE8: - drawFunc = pGC->ops->ImageText8; + (*pGC->ops->ImageText8)(pDraw, pGC, x, y, (int)count, chars); break; case TT_POLY16: - drawFunc = (void (*)())pGC->ops->PolyText16; + (*pGC->ops->PolyText16)(pDraw, pGC, x, y, (int)count, + (unsigned short *)chars); break; case TT_IMAGE16: - drawFunc = pGC->ops->ImageText16; + (*pGC->ops->ImageText16)(pDraw, pGC, x, y, (int)count, + (unsigned short *)chars); break; } - (*drawFunc) (pDraw, pGC, x, y, (int) count, chars); #else /* don't AVOID_GLYPHBLT */ /* * On the other hand, if the device does use GlyphBlt ultimately to do text, we * don't want to slow it down by invoking the text functions and having them call * GetGlyphs all over again, so we go directly to the GlyphBlt functions here. */ - drawFunc = imageblt ? pGC->ops->ImageGlyphBlt : pGC->ops->PolyGlyphBlt; - (*drawFunc) (pDraw, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font)); + if (imageblt) { + (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, n, charinfo, + FONTGLYPHS(pGC->font)); + } else { + (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, x, y, n, charinfo, + FONTGLYPHS(pGC->font)); + } #endif /* AVOID_GLYPHBLT */ } DEALLOCATE_LOCAL(charinfo); @@ -1848,6 +1976,133 @@ miSpriteLineHelper() } #endif +#ifdef RENDER + +# define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) + +static void +miSpritePictureOverlap (PicturePtr pPict, + INT16 x, + INT16 y, + CARD16 w, + CARD16 h) +{ + if (pPict->pDrawable->type == DRAWABLE_WINDOW) + { + WindowPtr pWin = (WindowPtr) (pPict->pDrawable); + miSpriteScreenPtr pScreenPriv = (miSpriteScreenPtr) + pPict->pDrawable->pScreen->devPrivates[miSpriteScreenIndex].ptr; + if (GC_CHECK(pWin)) + { + if (pPict->repeat) + { + x = mod(x,pWin->drawable.width); + y = mod(y,pWin->drawable.height); + } + if (ORG_OVERLAP (&pScreenPriv->saved, pWin->drawable.x, pWin->drawable.y, + x, y, w, h)) + miSpriteRemoveCursor (pWin->drawable.pScreen); + } + } +} + +#define PICTURE_PROLOGUE(ps, pScreenPriv, field) \ + ps->field = pScreenPriv->field + +#define PICTURE_EPILOGUE(ps, field, wrap) \ + ps->field = wrap + +static void +miSpriteComposite(CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + miSpriteScreenPtr pScreenPriv; + + pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + PICTURE_PROLOGUE(ps, pScreenPriv, Composite); + miSpritePictureOverlap (pSrc, xSrc, ySrc, width, height); + if (pMask) + miSpritePictureOverlap (pMask, xMask, yMask, width, height); + miSpritePictureOverlap (pDst, xDst, yDst, width, height); + + (*ps->Composite) (op, + pSrc, + pMask, + pDst, + xSrc, + ySrc, + xMask, + yMask, + xDst, + yDst, + width, + height); + + PICTURE_EPILOGUE(ps, Composite, miSpriteComposite); +} + +static void +miSpriteGlyphs(CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlist, + GlyphListPtr list, + GlyphPtr *glyphs) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + miSpriteScreenPtr pScreenPriv; + + pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + PICTURE_PROLOGUE(ps, pScreenPriv, Glyphs); + if (pSrc->pDrawable->type == DRAWABLE_WINDOW) + { + WindowPtr pSrcWin = (WindowPtr) (pSrc->pDrawable); + + if (GC_CHECK(pSrcWin)) + miSpriteRemoveCursor (pScreen); + } + if (pDst->pDrawable->type == DRAWABLE_WINDOW) + { + WindowPtr pDstWin = (WindowPtr) (pDst->pDrawable); + + if (GC_CHECK(pDstWin)) + { + BoxRec extents; + + miGlyphExtents (nlist, list, glyphs, &extents); + if (BOX_OVERLAP(&pScreenPriv->saved, + extents.x1 + pDstWin->drawable.x, + extents.y1 + pDstWin->drawable.y, + extents.x2 + pDstWin->drawable.x, + extents.y2 + pDstWin->drawable.y)) + { + miSpriteRemoveCursor (pScreen); + } + } + } + + (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs); + + PICTURE_EPILOGUE (ps, Glyphs, miSpriteGlyphs); +} +#endif + /* * miPointer interface routines */ @@ -1882,18 +2137,12 @@ static void miSpriteSetCursor (pScreen, pCursor, x, y) ScreenPtr pScreen; CursorPtr pCursor; + int x; + int y; { miSpriteScreenPtr pScreenPriv; pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - pScreenPriv->shouldBeUp = TRUE; - if (pScreenPriv->x == x && - pScreenPriv->y == y && - pScreenPriv->pCursor == pCursor && - !pScreenPriv->checkPixels) - { - return; - } if (!pCursor) { pScreenPriv->shouldBeUp = FALSE; @@ -1902,6 +2151,14 @@ miSpriteSetCursor (pScreen, pCursor, x, y) pScreenPriv->pCursor = 0; return; } + pScreenPriv->shouldBeUp = TRUE; + if (pScreenPriv->x == x && + pScreenPriv->y == y && + pScreenPriv->pCursor == pCursor && + !pScreenPriv->checkPixels) + { + return; + } pScreenPriv->x = x; pScreenPriv->y = y; pScreenPriv->pCacheWin = NullWindow; |