Use pixmaps instead of drawables in the kaa functions. Have the mga server

support accelerated operations on offscreen pixmaps.
This commit is contained in:
Anders Carlsson 2003-10-13 02:19:47 +00:00
parent 47a9fab5e2
commit 44f2e82f1b
3 changed files with 69 additions and 69 deletions

View File

@ -92,33 +92,22 @@ mgaSetup (ScreenPtr pScreen, int wait)
} }
Bool Bool
mgaPrepareSolid (DrawablePtr pDrawable, int alu, Pixel pm, Pixel fg) mgaPrepareSolid (PixmapPtr pPixmap, int alu, Pixel pm, Pixel fg)
{ {
KdScreenPriv(pDrawable->pScreen); KdScreenPriv(pPixmap->drawable.pScreen);
mgaScreenInfo (pScreenPriv); mgaScreenInfo (pScreenPriv);
int cmd; int cmd;
int dst_org;
cmd = MGA_OPCOD_TRAP | MGA_DWGCTL_SOLID | MGA_DWGCTL_ARZERO | MGA_DWGCTL_SGNZERO | cmd = MGA_OPCOD_TRAP | MGA_DWGCTL_SOLID | MGA_DWGCTL_ARZERO | MGA_DWGCTL_SGNZERO |
MGA_DWGCTL_SHIFTZERO | mgaRop[alu]; MGA_DWGCTL_SHIFTZERO | mgaRop[alu];
mgaSetup (pDrawable->pScreen, 5); dst_org = (int)pPixmap->devPrivate.ptr - (int)mgas->screen;
if (pDrawable->type == DRAWABLE_WINDOW) mgaSetup (pPixmap->drawable.pScreen, 5);
{
MGA_OUT32 (mmio, MGA_REG_DSTORG, 0);
MGA_OUT32 (mmio, MGA_REG_PITCH, pitch);
}
else
{
PixmapPtr pPixmap = (PixmapPtr)pDrawable;
int dst_org;
dst_org = (int)pPixmap->devPrivate.ptr - (int)mgas->screen;
MGA_OUT32 (mmio, MGA_REG_DSTORG, dst_org);
MGA_OUT32 (mmio, MGA_REG_PITCH, pPixmap->devKind / (pPixmap->drawable.bitsPerPixel >> 3));
}
MGA_OUT32 (mmio, MGA_REG_DSTORG, dst_org);
MGA_OUT32 (mmio, MGA_REG_PITCH, pPixmap->devKind / (pPixmap->drawable.bitsPerPixel >> 3));
MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd); MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd);
MGA_OUT32 (mmio, MGA_REG_FCOL, fg); MGA_OUT32 (mmio, MGA_REG_FCOL, fg);
MGA_OUT32 (mmio, MGA_REG_PLNWT, pm); MGA_OUT32 (mmio, MGA_REG_PLNWT, pm);
@ -144,8 +133,12 @@ mgaDoneSolid (void)
#define BLIT_UP 4 #define BLIT_UP 4
Bool Bool
mgaPrepareCopy (DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, int dx, int dy, int alu, Pixel pm) mgaPrepareCopy (PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap,
int dx, int dy, int alu, Pixel pm)
{ {
KdScreenPriv(pSrcPixmap->drawable.pScreen);
mgaScreenInfo (pScreenPriv);
int cmd; int cmd;
cmd = MGA_OPCOD_BITBLT | MGA_DWGCTL_BFCOL | MGA_DWGCTL_SHIFTZERO | mgaRop[alu]; cmd = MGA_OPCOD_BITBLT | MGA_DWGCTL_BFCOL | MGA_DWGCTL_SHIFTZERO | mgaRop[alu];
@ -157,39 +150,13 @@ mgaPrepareCopy (DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, int dx, int
if (dx < 0) if (dx < 0)
dir |= BLIT_LEFT; dir |= BLIT_LEFT;
mgaSetup (pDstDrawable->pScreen, 6); mgaSetup (pSrcPixmap->drawable.pScreen, 7);
if (pSrcDrawable->type == DRAWABLE_WINDOW)
{
MGA_OUT32 (mmio, MGA_REG_SRCORG, 0);
src_pitch = pitch;
}
else
{
KdScreenPriv(pSrcDrawable->pScreen);
mgaScreenInfo (pScreenPriv);
PixmapPtr pPixmap = (PixmapPtr)pSrcDrawable;
MGA_OUT32 (mmio, MGA_REG_SRCORG, ((int)pPixmap->devPrivate.ptr - (int)mgas->screen));
src_pitch = pPixmap->devKind / (pPixmap->drawable.bitsPerPixel >> 3);
}
if (pDstDrawable->type == DRAWABLE_WINDOW)
{
MGA_OUT32 (mmio, MGA_REG_DSTORG, 0);
MGA_OUT32 (mmio, MGA_REG_PITCH, pitch);
}
else
{
KdScreenPriv(pDstDrawable->pScreen);
mgaScreenInfo (pScreenPriv);
PixmapPtr pPixmap = (PixmapPtr)pDstDrawable;
MGA_OUT32 (mmio, MGA_REG_DSTORG, ((int)pPixmap->devPrivate.ptr - (int)mgas->screen));
MGA_OUT32 (mmio, MGA_REG_PITCH, pPixmap->devKind / (pPixmap->drawable.bitsPerPixel >> 3));
}
MGA_OUT32 (mmio, MGA_REG_SRCORG, ((int)pSrcPixmap->devPrivate.ptr - (int)mgas->screen));
MGA_OUT32 (mmio, MGA_REG_DSTORG, ((int)pDstPixmap->devPrivate.ptr - (int)mgas->screen));
MGA_OUT32 (mmio, MGA_REG_PITCH, pDstPixmap->devKind / (pDstPixmap->drawable.bitsPerPixel >> 3));
src_pitch = pSrcPixmap->devKind / (pSrcPixmap->drawable.bitsPerPixel >> 3);
MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd); MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd);
MGA_OUT32 (mmio, MGA_REG_SGN, dir); MGA_OUT32 (mmio, MGA_REG_SGN, dir);
MGA_OUT32 (mmio, MGA_REG_PLNWT, pm); MGA_OUT32 (mmio, MGA_REG_PLNWT, pm);

View File

@ -64,6 +64,9 @@ typedef struct {
#define KaaPixmapPriv(p) KaaPixmapPrivPtr pKaaPixmap = KaaGetPixmapPriv (p) #define KaaPixmapPriv(p) KaaPixmapPrivPtr pKaaPixmap = KaaGetPixmapPriv (p)
#define KaaPixmapPitch(w) (((w) + (pKaaScr->info->offscreenPitch - 1)) & ~(pKaaScr->info->offscreenPitch - 1)) #define KaaPixmapPitch(w) (((w) + (pKaaScr->info->offscreenPitch - 1)) & ~(pKaaScr->info->offscreenPitch - 1))
#define KaaDrawableIsOffscreenPixmap(d) (d->type == DRAWABLE_PIXMAP && \
KaaGetPixmapPriv ((PixmapPtr)(d))->offscreenArea != NULL && \
!KaaGetPixmapPriv ((PixmapPtr)(d))->offscreenArea->swappedOut)
#define KAA_SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \ #define KAA_SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
((KaaScreenPrivPtr) (pScreen)->devPrivates[kaaScreenPrivateIndex].ptr)->field) ((KaaScreenPrivPtr) (pScreen)->devPrivates[kaaScreenPrivateIndex].ptr)->field)
@ -107,7 +110,7 @@ kaaMoveInPixmap (KdOffscreenArea *area)
PixmapPtr pPixmap = area->privData; PixmapPtr pPixmap = area->privData;
ScreenPtr pScreen = pPixmap->drawable.pScreen; ScreenPtr pScreen = pPixmap->drawable.pScreen;
KaaScreenPriv (pScreen); KaaScreenPriv (pScreen);
PixmapPtr pScreenPixmap = (*pScreen->GetScreenPixmap) (pScreen); PixmapPtr pScreenPixmap = (*pScreen->GetScreenPixmap) (pScreen);
int dst_pitch, src_pitch; int dst_pitch, src_pitch;
unsigned char *dst, *src; unsigned char *dst, *src;
int i; int i;
@ -249,6 +252,28 @@ kaaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth)
return pPixmap; return pPixmap;
} }
PixmapPtr
kaaGetDrawingPixmap (DrawablePtr pDrawable, int *x, int *y)
{
if (pDrawable->type == DRAWABLE_WINDOW) {
if (x)
*x = pDrawable->x;
if (y)
*y = pDrawable->y;
return (*pDrawable->pScreen->GetScreenPixmap) (pDrawable->pScreen);
}
else if (KaaDrawableIsOffscreenPixmap (pDrawable))
{
if (x)
*x = 0;
if (y)
*y = 0;
return ((PixmapPtr)pDrawable);
}
else
return NULL;
}
void void
kaaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n, kaaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
@ -258,15 +283,17 @@ kaaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
KdScreenPriv (pScreen); KdScreenPriv (pScreen);
KaaScreenPriv (pScreen); KaaScreenPriv (pScreen);
RegionPtr pClip = fbGetCompositeClip(pGC); RegionPtr pClip = fbGetCompositeClip(pGC);
PixmapPtr pPixmap;
BoxPtr pextent, pbox; BoxPtr pextent, pbox;
int nbox; int nbox;
int extentX1, extentX2, extentY1, extentY2; int extentX1, extentX2, extentY1, extentY2;
int fullX1, fullX2, fullY1; int fullX1, fullX2, fullY1;
int partX1, partX2; int partX1, partX2;
if (!pScreenPriv->enabled || if (!pScreenPriv->enabled ||
pGC->fillStyle != FillSolid || pGC->fillStyle != FillSolid ||
!(*pKaaScr->info->PrepareSolid) (pDrawable, !(pPixmap = kaaGetDrawingPixmap (pDrawable, NULL, NULL)) ||
!(*pKaaScr->info->PrepareSolid) (pPixmap,
pGC->alu, pGC->alu,
pGC->planemask, pGC->planemask,
pGC->fgPixel)) pGC->fgPixel))
@ -344,6 +371,7 @@ kaaCopyNtoN (DrawablePtr pSrcDrawable,
{ {
KdScreenPriv (pDstDrawable->pScreen); KdScreenPriv (pDstDrawable->pScreen);
KaaScreenPriv (pDstDrawable->pScreen); KaaScreenPriv (pDstDrawable->pScreen);
PixmapPtr pSrcPixmap, pDstPixmap;
int srcX, srcY, dstX, dstY; int srcX, srcY, dstX, dstY;
int w, h; int w, h;
CARD32 flags; CARD32 flags;
@ -351,9 +379,10 @@ kaaCopyNtoN (DrawablePtr pSrcDrawable,
CARD8 alu; CARD8 alu;
if (pScreenPriv->enabled && if (pScreenPriv->enabled &&
pSrcDrawable->type == DRAWABLE_WINDOW && (pSrcPixmap = kaaGetDrawingPixmap (pSrcDrawable, NULL, NULL)) &&
(*pKaaScr->info->PrepareCopy) (pSrcDrawable, (pDstPixmap = kaaGetDrawingPixmap (pDstDrawable, NULL, NULL)) &&
pDstDrawable, (*pKaaScr->info->PrepareCopy) (pSrcPixmap,
pDstPixmap,
dx, dx,
dy, dy,
pGC ? pGC->alu : GXcopy, pGC ? pGC->alu : GXcopy,
@ -399,6 +428,7 @@ kaaPolyFillRect(DrawablePtr pDrawable,
KdScreenPriv (pDrawable->pScreen); KdScreenPriv (pDrawable->pScreen);
KaaScreenPriv (pDrawable->pScreen); KaaScreenPriv (pDrawable->pScreen);
RegionPtr pClip = fbGetCompositeClip(pGC); RegionPtr pClip = fbGetCompositeClip(pGC);
PixmapPtr pPixmap;
register BoxPtr pbox; register BoxPtr pbox;
BoxPtr pextent; BoxPtr pextent;
int extentX1, extentX2, extentY1, extentY2; int extentX1, extentX2, extentY1, extentY2;
@ -406,10 +436,11 @@ kaaPolyFillRect(DrawablePtr pDrawable,
int partX1, partX2, partY1, partY2; int partX1, partX2, partY1, partY2;
int xorg, yorg; int xorg, yorg;
int n; int n;
if (!pScreenPriv->enabled || if (!pScreenPriv->enabled ||
pGC->fillStyle != FillSolid || pGC->fillStyle != FillSolid ||
!(*pKaaScr->info->PrepareSolid) (pDrawable, !(pPixmap = kaaGetDrawingPixmap (pDrawable, &xorg, &yorg)) ||
!(*pKaaScr->info->PrepareSolid) (pPixmap,
pGC->alu, pGC->alu,
pGC->planemask, pGC->planemask,
pGC->fgPixel)) pGC->fgPixel))
@ -418,9 +449,6 @@ kaaPolyFillRect(DrawablePtr pDrawable,
return; return;
} }
xorg = pDrawable->x;
yorg = pDrawable->y;
pextent = REGION_EXTENTS(pGC->pScreen, pClip); pextent = REGION_EXTENTS(pGC->pScreen, pClip);
extentX1 = pextent->x1; extentX1 = pextent->x1;
extentY1 = pextent->y1; extentY1 = pextent->y1;
@ -499,13 +527,15 @@ kaaSolidBoxClipped (DrawablePtr pDrawable,
{ {
KdScreenPriv (pDrawable->pScreen); KdScreenPriv (pDrawable->pScreen);
KaaScreenPriv (pDrawable->pScreen); KaaScreenPriv (pDrawable->pScreen);
PixmapPtr pPixmap;
BoxPtr pbox; BoxPtr pbox;
int nbox; int nbox;
int partX1, partX2, partY1, partY2; int partX1, partX2, partY1, partY2;
CARD32 cmd; CARD32 cmd;
if (!pScreenPriv->enabled || if (!pScreenPriv->enabled ||
!(*pKaaScr->info->PrepareSolid) (pDrawable, GXcopy, pm, fg)) !(pPixmap = kaaGetDrawingPixmap (pDrawable, NULL, NULL)) ||
!(*pKaaScr->info->PrepareSolid) (pPixmap, GXcopy, pm, fg))
{ {
KdCheckSync (pDrawable->pScreen); KdCheckSync (pDrawable->pScreen);
fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel); fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel);
@ -711,7 +741,8 @@ kaaValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
fbValidateGC (pGC, changes, pDrawable); fbValidateGC (pGC, changes, pDrawable);
if (pDrawable->type == DRAWABLE_WINDOW) if (pDrawable->type == DRAWABLE_WINDOW ||
KaaDrawableIsOffscreenPixmap (pDrawable))
pGC->ops = (GCOps *) &kaaOps; pGC->ops = (GCOps *) &kaaOps;
else else
pGC->ops = (GCOps *) &kdAsyncPixmapGCOps; pGC->ops = (GCOps *) &kdAsyncPixmapGCOps;
@ -772,9 +803,11 @@ kaaFillRegionSolid (DrawablePtr pDrawable,
{ {
KdScreenPriv(pDrawable->pScreen); KdScreenPriv(pDrawable->pScreen);
KaaScreenPriv(pDrawable->pScreen); KaaScreenPriv(pDrawable->pScreen);
PixmapPtr pPixmap;
if (pScreenPriv->enabled && if (pScreenPriv->enabled &&
(*pKaaScr->info->PrepareSolid) (pDrawable, GXcopy, FB_ALLONES, pixel)) (pPixmap = kaaGetDrawingPixmap (pDrawable, NULL, NULL)) &&
(*pKaaScr->info->PrepareSolid) (pPixmap, GXcopy, FB_ALLONES, pixel))
{ {
int nbox = REGION_NUM_RECTS (pRegion); int nbox = REGION_NUM_RECTS (pRegion);
BoxPtr pBox = REGION_RECTS (pRegion); BoxPtr pBox = REGION_RECTS (pRegion);

View File

@ -278,15 +278,15 @@ typedef struct _KdMouseMatrix {
} KdMouseMatrix; } KdMouseMatrix;
typedef struct _KaaScreenInfo { typedef struct _KaaScreenInfo {
Bool (*PrepareSolid) (DrawablePtr pDrawable, Bool (*PrepareSolid) (PixmapPtr pPixmap,
int alu, int alu,
Pixel planemask, Pixel planemask,
Pixel fg); Pixel fg);
void (*Solid) (int x1, int y1, int x2, int y2); void (*Solid) (int x1, int y1, int x2, int y2);
void (*DoneSolid) (void); void (*DoneSolid) (void);
Bool (*PrepareCopy) (DrawablePtr pSrcDrawable, Bool (*PrepareCopy) (PixmapPtr pSrcPixmap,
DrawablePtr pDstDrawable, PixmapPtr pDstPixmap,
Bool upsidedown, Bool upsidedown,
Bool reverse, Bool reverse,
int alu, int alu,