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.
This commit is contained in:
Eric Anholt 2004-08-30 22:16:46 +00:00
parent ccaf332ce3
commit 6ec9ecd591
4 changed files with 104 additions and 2 deletions

View File

@ -1029,8 +1029,10 @@ kaaDrawInit (ScreenPtr pScreen,
pScreen->PaintWindowBackground = kaaPaintWindow; pScreen->PaintWindowBackground = kaaPaintWindow;
pScreen->PaintWindowBorder = kaaPaintWindow; pScreen->PaintWindowBorder = kaaPaintWindow;
#ifdef RENDER #ifdef RENDER
if (ps) if (ps) {
ps->Composite = kaaComposite; ps->Composite = kaaComposite;
ps->RasterizeTrapezoid = kaaRasterizeTrapezoid;
}
#endif #endif
/* /*

View File

@ -98,4 +98,10 @@ kaaComposite(CARD8 op,
CARD16 width, CARD16 width,
CARD16 height); CARD16 height);
void
kaaRasterizeTrapezoid(PicturePtr pPict,
xTrapezoid *trap,
int xoff,
int yoff);
#endif /* _KAA_H_ */ #endif /* _KAA_H_ */

View File

@ -62,6 +62,9 @@ static void kaaCompositeFallbackPictDesc(PicturePtr pict, char *string, int n)
case PICT_a8: case PICT_a8:
snprintf(format, 20, "A8 "); snprintf(format, 20, "A8 ");
break; break;
case PICT_a1:
snprintf(format, 20, "A1 ");
break;
default: default:
snprintf(format, 20, "0x%x", (int)pict->format); snprintf(format, 20, "0x%x", (int)pict->format);
break; break;
@ -83,7 +86,6 @@ kaaPrintCompositeFallback(CARD8 op,
PicturePtr pDst) PicturePtr pDst)
{ {
char sop[20]; char sop[20];
char srcdesc[40], maskdesc[40], dstdesc[40]; char srcdesc[40], maskdesc[40], dstdesc[40];
switch(op) switch(op)
@ -109,6 +111,19 @@ kaaPrintCompositeFallback(CARD8 op,
" dst %s, \n", " dst %s, \n",
sop, srcdesc, maskdesc, dstdesc); 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 #endif
static Bool static Bool
@ -605,3 +620,71 @@ kaaComposite(CARD8 op,
xMask, yMask, xDst, yDst, width, height); xMask, yMask, xDst, yDst, width, height);
} }
#endif #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) ();
}

View File

@ -310,6 +310,11 @@ typedef struct _KdMouseMatrix {
int matrix[2][3]; int matrix[2][3];
} KdMouseMatrix; } KdMouseMatrix;
typedef struct _KaaTrapezoid {
float tl, tr, ty;
float bl, br, by;
} KaaTrapezoid;
typedef struct _KaaScreenInfo { typedef struct _KaaScreenInfo {
Bool (*PrepareSolid) (PixmapPtr pPixmap, Bool (*PrepareSolid) (PixmapPtr pPixmap,
int alu, int alu,
@ -370,6 +375,12 @@ typedef struct _KaaScreenInfo {
int height); int height);
void (*DoneComposite) (void); void (*DoneComposite) (void);
Bool (*PrepareTrapezoids) (PicturePtr pDstPicture,
PixmapPtr pDst);
void (*Trapezoids) (KaaTrapezoid *traps,
int ntraps);
void (*DoneTrapezoids) (void);
Bool (*UploadToScreen) (PixmapPtr pDst, Bool (*UploadToScreen) (PixmapPtr pDst,
char *src, char *src,
int src_pitch); int src_pitch);