diff options
author | Eric Anholt <anholt@freebsd.org> | 2004-08-30 22:16:46 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2004-08-30 22:16:46 +0000 |
commit | 6ec9ecd591fba9e9b69b8ebbd2fa08c0a2beac08 (patch) | |
tree | b3d6cd505054986ff685dc6af6ca32b488948798 | |
parent | ccaf332ce3a9393715317edd3b92420c27fc94eb (diff) | |
download | xserver-6ec9ecd591fba9e9b69b8ebbd2fa08c0a2beac08.tar.gz |
Add a set of three hooks for accelerating trapezoids, and use it for the
RasterizeTrapezoid screen function. These hooks will be called for
imprecise, non-sharp trapezoids with A8 destinations.
Note that the current main consumer of trapezoids, cairo, is requesting
precise, sharp trapezoids by not changing the default Picture
attributes, but gets non-sharp effects in software because fb bases its
choice of sharp/non-sharp on the mask format being A8 vs A1, and cairo
asks for A8. Follow fb's (poor?) example by ignoring the sharp setting
and basing the choice off of the mask being A8.
-rw-r--r-- | hw/kdrive/src/kaa.c | 4 | ||||
-rw-r--r-- | hw/kdrive/src/kaa.h | 6 | ||||
-rw-r--r-- | hw/kdrive/src/kaapict.c | 85 | ||||
-rw-r--r-- | hw/kdrive/src/kdrive.h | 11 |
4 files changed, 104 insertions, 2 deletions
diff --git a/hw/kdrive/src/kaa.c b/hw/kdrive/src/kaa.c index 84b8f4b25..0aa1c19ee 100644 --- a/hw/kdrive/src/kaa.c +++ b/hw/kdrive/src/kaa.c @@ -1029,8 +1029,10 @@ kaaDrawInit (ScreenPtr pScreen, pScreen->PaintWindowBackground = kaaPaintWindow; pScreen->PaintWindowBorder = kaaPaintWindow; #ifdef RENDER - if (ps) + if (ps) { ps->Composite = kaaComposite; + ps->RasterizeTrapezoid = kaaRasterizeTrapezoid; + } #endif /* diff --git a/hw/kdrive/src/kaa.h b/hw/kdrive/src/kaa.h index c3766f174..d849de03f 100644 --- a/hw/kdrive/src/kaa.h +++ b/hw/kdrive/src/kaa.h @@ -98,4 +98,10 @@ kaaComposite(CARD8 op, CARD16 width, CARD16 height); +void +kaaRasterizeTrapezoid(PicturePtr pPict, + xTrapezoid *trap, + int xoff, + int yoff); + #endif /* _KAA_H_ */ diff --git a/hw/kdrive/src/kaapict.c b/hw/kdrive/src/kaapict.c index cccbcb7ce..8895a80f0 100644 --- a/hw/kdrive/src/kaapict.c +++ b/hw/kdrive/src/kaapict.c @@ -62,6 +62,9 @@ static void kaaCompositeFallbackPictDesc(PicturePtr pict, char *string, int n) case PICT_a8: snprintf(format, 20, "A8 "); break; + case PICT_a1: + snprintf(format, 20, "A1 "); + break; default: snprintf(format, 20, "0x%x", (int)pict->format); break; @@ -83,7 +86,6 @@ kaaPrintCompositeFallback(CARD8 op, PicturePtr pDst) { char sop[20]; - char srcdesc[40], maskdesc[40], dstdesc[40]; switch(op) @@ -109,6 +111,19 @@ kaaPrintCompositeFallback(CARD8 op, " dst %s, \n", sop, srcdesc, maskdesc, dstdesc); } + +static void +kaaPrintTrapezoidFallback(PicturePtr pDst) +{ + char dstdesc[40]; + + kaaCompositeFallbackPictDesc(pDst, dstdesc, 40); + + ErrorF("Trapezoid fallback: dst %s, %c/%s\n", + dstdesc, + (pDst->polyMode == PolyModePrecise) ? 'p' : 'i', + (pDst->polyEdge == PolyEdgeSharp) ? "a" : "aa"); +} #endif static Bool @@ -605,3 +620,71 @@ kaaComposite(CARD8 op, xMask, yMask, xDst, yDst, width, height); } #endif + +static xFixed +miLineFixedX (xLineFixed *l, xFixed y, Bool ceil) +{ + xFixed dx = l->p2.x - l->p1.x; + xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx; + xFixed dy = l->p2.y - l->p1.y; + if (ceil) + ex += (dy - 1); + return l->p1.x + (xFixed) (ex / dy); +} + +/* Need to decide just how much to trim, to maintain translation independence + * when converted to floating point. + */ +#define XFIXED_TO_FLOAT(x) (((float)((x) & 0xffffff00)) / 65536.0) + +void kaaRasterizeTrapezoid(PicturePtr pDst, + xTrapezoid *trap, + int xoff, + int yoff) +{ + KdScreenPriv (pDst->pDrawable->pScreen); + KaaScreenPriv (pDst->pDrawable->pScreen); + KaaTrapezoid ktrap; + PixmapPtr pPix; + xFixed x1, x2; + + if (!pScreenPriv->enabled || + !pKaaScr->info->PrepareTrapezoids || + pDst->pDrawable->type != DRAWABLE_PIXMAP || + pDst->polyMode == PolyModePrecise || + pDst->alphaMap || pDst->format != PICT_a8) + { + KdCheckRasterizeTrapezoid (pDst, trap, xoff, yoff); +#if KAA_DEBUG_FALLBACKS + kaaPrintTrapezoidFallback (pDst); +#endif + return; + } + pPix = (PixmapPtr)pDst->pDrawable; + + kaaPixmapUseScreen (pPix); + + if (!kaaPixmapIsOffscreen (pPix) || + !(*pKaaScr->info->PrepareTrapezoids) (pDst, pPix)) + { +#if KAA_DEBUG_FALLBACKS + kaaPrintTrapezoidFallback (pDst); +#endif + KdCheckRasterizeTrapezoid (pDst, trap, xoff, yoff); + return; + } + + ktrap.ty = XFIXED_TO_FLOAT(trap->top) + yoff; + x1 = miLineFixedX (&trap->left, trap->top, FALSE); + x2 = miLineFixedX (&trap->right, trap->top, TRUE); + ktrap.tl = XFIXED_TO_FLOAT(x1) + xoff; + ktrap.tr = XFIXED_TO_FLOAT(x2) + xoff; + ktrap.by = XFIXED_TO_FLOAT(trap->bottom) + yoff; + x1 = miLineFixedX (&trap->left, trap->bottom, FALSE); + x2 = miLineFixedX (&trap->right, trap->bottom, TRUE); + ktrap.bl = XFIXED_TO_FLOAT(x1) + xoff; + ktrap.br = XFIXED_TO_FLOAT(x2) + xoff; + + (*pKaaScr->info->Trapezoids) (&ktrap, 1); + (*pKaaScr->info->DoneTrapezoids) (); +} diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h index 23807238a..3bb73a213 100644 --- a/hw/kdrive/src/kdrive.h +++ b/hw/kdrive/src/kdrive.h @@ -310,6 +310,11 @@ typedef struct _KdMouseMatrix { int matrix[2][3]; } KdMouseMatrix; +typedef struct _KaaTrapezoid { + float tl, tr, ty; + float bl, br, by; +} KaaTrapezoid; + typedef struct _KaaScreenInfo { Bool (*PrepareSolid) (PixmapPtr pPixmap, int alu, @@ -370,6 +375,12 @@ typedef struct _KaaScreenInfo { int height); void (*DoneComposite) (void); + Bool (*PrepareTrapezoids) (PicturePtr pDstPicture, + PixmapPtr pDst); + void (*Trapezoids) (KaaTrapezoid *traps, + int ntraps); + void (*DoneTrapezoids) (void); + Bool (*UploadToScreen) (PixmapPtr pDst, char *src, int src_pitch); |