Commit 5e2a7af2 authored by Eric Anholt's avatar Eric Anholt

Move the frequently-repeated code to get the pixmap that backs a drawable

    to a new function, exaGetDrawablePixmap().
parent ee3c7ccb
2006-02-02 Eric Anholt <anholt@FreeBSD.org>
* hw/xfree86/exa/exa.c: (exaGetDrawablePixmap), (exaDrawableDirty),
(exaDrawableIsOffscreen), (exaPrepareAccess), (exaFinishAccess):
* hw/xfree86/exa/exa_migration.c: (exaDrawableUseScreen),
(exaDrawableUseMemory):
* hw/xfree86/exa/exa_priv.h:
* hw/xfree86/exa/exa_render.c: (exaTryDriverSolidFill),
(exaTryDriverComposite):
Move the frequently-repeated code to get the pixmap that backs a
drawable to a new function, exaGetDrawablePixmap().
2006-02-02 Eric Anholt <anholt@FreeBSD.org>
* hw/xfree86/exa/exa_accel.c: (exaFillSpans), (exaCopyNtoN),
......
......@@ -72,18 +72,21 @@ exaGetPixmapSize(PixmapPtr pPix)
return 0;
}
PixmapPtr
exaGetDrawablePixmap(DrawablePtr pDrawable)
{
if (pDrawable->type == DRAWABLE_WINDOW)
return pDrawable->pScreen->GetWindowPixmap ((WindowPtr) pDrawable);
else
return (PixmapPtr) pDrawable;
}
void
exaDrawableDirty (DrawablePtr pDrawable)
{
PixmapPtr pPixmap;
ExaPixmapPrivPtr pExaPixmap;
if (pDrawable->type == DRAWABLE_WINDOW)
pPixmap = (*pDrawable->pScreen->GetWindowPixmap)((WindowPtr) pDrawable);
else
pPixmap = (PixmapPtr)pDrawable;
pExaPixmap = ExaGetPixmapPriv(pPixmap);
pExaPixmap = ExaGetPixmapPriv(exaGetDrawablePixmap (pDrawable));
if (pExaPixmap != NULL)
pExaPixmap->dirty = TRUE;
}
......@@ -166,6 +169,12 @@ exaPixmapIsOffscreen(PixmapPtr p)
pExaScr->info->card.memorySize);
}
Bool
exaDrawableIsOffscreen (DrawablePtr pDrawable)
{
return exaPixmapIsOffscreen (exaGetDrawablePixmap (pDrawable));
}
PixmapPtr
exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp)
{
......@@ -196,18 +205,6 @@ exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp)
return NULL;
}
Bool
exaDrawableIsOffscreen (DrawablePtr pDrawable)
{
PixmapPtr pPixmap;
if (pDrawable->type == DRAWABLE_WINDOW)
pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
else
pPixmap = (PixmapPtr) pDrawable;
return exaPixmapIsOffscreen (pPixmap);
}
void
exaPrepareAccess(DrawablePtr pDrawable, int index)
{
......@@ -215,10 +212,7 @@ exaPrepareAccess(DrawablePtr pDrawable, int index)
ExaScreenPriv (pScreen);
PixmapPtr pPixmap;
if (pDrawable->type == DRAWABLE_WINDOW)
pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
else
pPixmap = (PixmapPtr) pDrawable;
pPixmap = exaGetDrawablePixmap (pDrawable);
if (index == EXA_PREPARE_DEST)
exaDrawableDirty (pDrawable);
......@@ -248,10 +242,7 @@ exaFinishAccess(DrawablePtr pDrawable, int index)
if (pExaScr->info->accel.FinishAccess == NULL)
return;
if (pDrawable->type == DRAWABLE_WINDOW)
pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
else
pPixmap = (PixmapPtr) pDrawable;
pPixmap = exaGetDrawablePixmap (pDrawable);
if (!exaPixmapIsOffscreen (pPixmap))
return;
......
......@@ -235,27 +235,13 @@ exaMoveOutPixmap (PixmapPtr pPixmap)
void
exaDrawableUseScreen(DrawablePtr pDrawable)
{
PixmapPtr pPixmap;
if (pDrawable->type == DRAWABLE_WINDOW)
pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
else
pPixmap = (PixmapPtr) pDrawable;
exaPixmapUseScreen (pPixmap);
exaPixmapUseScreen (exaGetDrawablePixmap (pDrawable));
}
void
exaDrawableUseMemory(DrawablePtr pDrawable)
{
PixmapPtr pPixmap;
if (pDrawable->type == DRAWABLE_WINDOW)
pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
else
pPixmap = (PixmapPtr) pDrawable;
exaPixmapUseMemory (pPixmap);
exaPixmapUseMemory (exaGetDrawablePixmap (pDrawable));
}
void
......
......@@ -315,6 +315,9 @@ exaPixmapIsOffscreen(PixmapPtr p);
PixmapPtr
exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp);
PixmapPtr
exaGetDrawablePixmap(DrawablePtr pDrawable);
void
exaMoveInPixmap (PixmapPtr pPixmap);
......
......@@ -253,12 +253,7 @@ exaTryDriverSolidFill(PicturePtr pSrc,
return 0;
}
if (pSrc->pDrawable->type == DRAWABLE_WINDOW)
pSrcPix = (*pSrc->pDrawable->pScreen->GetWindowPixmap)(
(WindowPtr) (pSrc->pDrawable));
else
pSrcPix = (PixmapPtr) (pSrc->pDrawable);
pSrcPix = exaGetDrawablePixmap (pSrc->pDrawable);
exaPrepareAccess(&pSrcPix->drawable, EXA_PREPARE_SRC);
switch (pSrcPix->drawable.bitsPerPixel) {
......@@ -385,19 +380,11 @@ exaTryDriverComposite(CARD8 op,
}
if (!pSrcPix && (!pMask || pMaskPix) && pExaScr->info->accel.UploadToScratch) {
if (pSrc->pDrawable->type == DRAWABLE_WINDOW)
pSrcPix = (*pSrc->pDrawable->pScreen->GetWindowPixmap) (
(WindowPtr) pSrc->pDrawable);
else
pSrcPix = (PixmapPtr) pSrc->pDrawable;
pSrcPix = exaGetDrawablePixmap (pSrc->pDrawable);
if ((*pExaScr->info->accel.UploadToScratch) (pSrcPix, &scratch))
pSrcPix = &scratch;
} else if (pSrcPix && pMask && !pMaskPix && pExaScr->info->accel.UploadToScratch) {
if (pMask->pDrawable->type == DRAWABLE_WINDOW)
pMaskPix = (*pMask->pDrawable->pScreen->GetWindowPixmap) (
(WindowPtr) pMask->pDrawable);
else
pMaskPix = (PixmapPtr) pMask->pDrawable;
pMaskPix = exaGetDrawablePixmap (pMask->pDrawable);
if ((*pExaScr->info->accel.UploadToScratch) (pMaskPix, &scratch))
pMaskPix = &scratch;
}
......
......@@ -72,18 +72,21 @@ exaGetPixmapSize(PixmapPtr pPix)
return 0;
}
PixmapPtr
exaGetDrawablePixmap(DrawablePtr pDrawable)
{
if (pDrawable->type == DRAWABLE_WINDOW)
return pDrawable->pScreen->GetWindowPixmap ((WindowPtr) pDrawable);
else
return (PixmapPtr) pDrawable;
}
void
exaDrawableDirty (DrawablePtr pDrawable)
{
PixmapPtr pPixmap;
ExaPixmapPrivPtr pExaPixmap;
if (pDrawable->type == DRAWABLE_WINDOW)
pPixmap = (*pDrawable->pScreen->GetWindowPixmap)((WindowPtr) pDrawable);
else
pPixmap = (PixmapPtr)pDrawable;
pExaPixmap = ExaGetPixmapPriv(pPixmap);
pExaPixmap = ExaGetPixmapPriv(exaGetDrawablePixmap (pDrawable));
if (pExaPixmap != NULL)
pExaPixmap->dirty = TRUE;
}
......@@ -166,6 +169,12 @@ exaPixmapIsOffscreen(PixmapPtr p)
pExaScr->info->card.memorySize);
}
Bool
exaDrawableIsOffscreen (DrawablePtr pDrawable)
{
return exaPixmapIsOffscreen (exaGetDrawablePixmap (pDrawable));
}
PixmapPtr
exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp)
{
......@@ -196,18 +205,6 @@ exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp)
return NULL;
}
Bool
exaDrawableIsOffscreen (DrawablePtr pDrawable)
{
PixmapPtr pPixmap;
if (pDrawable->type == DRAWABLE_WINDOW)
pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
else
pPixmap = (PixmapPtr) pDrawable;
return exaPixmapIsOffscreen (pPixmap);
}
void
exaPrepareAccess(DrawablePtr pDrawable, int index)
{
......@@ -215,10 +212,7 @@ exaPrepareAccess(DrawablePtr pDrawable, int index)
ExaScreenPriv (pScreen);
PixmapPtr pPixmap;
if (pDrawable->type == DRAWABLE_WINDOW)
pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
else
pPixmap = (PixmapPtr) pDrawable;
pPixmap = exaGetDrawablePixmap (pDrawable);
if (index == EXA_PREPARE_DEST)
exaDrawableDirty (pDrawable);
......@@ -248,10 +242,7 @@ exaFinishAccess(DrawablePtr pDrawable, int index)
if (pExaScr->info->accel.FinishAccess == NULL)
return;
if (pDrawable->type == DRAWABLE_WINDOW)
pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
else
pPixmap = (PixmapPtr) pDrawable;
pPixmap = exaGetDrawablePixmap (pDrawable);
if (!exaPixmapIsOffscreen (pPixmap))
return;
......
......@@ -235,27 +235,13 @@ exaMoveOutPixmap (PixmapPtr pPixmap)
void
exaDrawableUseScreen(DrawablePtr pDrawable)
{
PixmapPtr pPixmap;
if (pDrawable->type == DRAWABLE_WINDOW)
pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
else
pPixmap = (PixmapPtr) pDrawable;
exaPixmapUseScreen (pPixmap);
exaPixmapUseScreen (exaGetDrawablePixmap (pDrawable));
}
void
exaDrawableUseMemory(DrawablePtr pDrawable)
{
PixmapPtr pPixmap;
if (pDrawable->type == DRAWABLE_WINDOW)
pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
else
pPixmap = (PixmapPtr) pDrawable;
exaPixmapUseMemory (pPixmap);
exaPixmapUseMemory (exaGetDrawablePixmap (pDrawable));
}
void
......
......@@ -315,6 +315,9 @@ exaPixmapIsOffscreen(PixmapPtr p);
PixmapPtr
exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp);
PixmapPtr
exaGetDrawablePixmap(DrawablePtr pDrawable);
void
exaMoveInPixmap (PixmapPtr pPixmap);
......
......@@ -253,12 +253,7 @@ exaTryDriverSolidFill(PicturePtr pSrc,
return 0;
}
if (pSrc->pDrawable->type == DRAWABLE_WINDOW)
pSrcPix = (*pSrc->pDrawable->pScreen->GetWindowPixmap)(
(WindowPtr) (pSrc->pDrawable));
else
pSrcPix = (PixmapPtr) (pSrc->pDrawable);
pSrcPix = exaGetDrawablePixmap (pSrc->pDrawable);
exaPrepareAccess(&pSrcPix->drawable, EXA_PREPARE_SRC);
switch (pSrcPix->drawable.bitsPerPixel) {
......@@ -385,19 +380,11 @@ exaTryDriverComposite(CARD8 op,
}
if (!pSrcPix && (!pMask || pMaskPix) && pExaScr->info->accel.UploadToScratch) {
if (pSrc->pDrawable->type == DRAWABLE_WINDOW)
pSrcPix = (*pSrc->pDrawable->pScreen->GetWindowPixmap) (
(WindowPtr) pSrc->pDrawable);
else
pSrcPix = (PixmapPtr) pSrc->pDrawable;
pSrcPix = exaGetDrawablePixmap (pSrc->pDrawable);
if ((*pExaScr->info->accel.UploadToScratch) (pSrcPix, &scratch))
pSrcPix = &scratch;
} else if (pSrcPix && pMask && !pMaskPix && pExaScr->info->accel.UploadToScratch) {
if (pMask->pDrawable->type == DRAWABLE_WINDOW)
pMaskPix = (*pMask->pDrawable->pScreen->GetWindowPixmap) (
(WindowPtr) pMask->pDrawable);
else
pMaskPix = (PixmapPtr) pMask->pDrawable;
pMaskPix = exaGetDrawablePixmap (pMask->pDrawable);
if ((*pExaScr->info->accel.UploadToScratch) (pMaskPix, &scratch))
pMaskPix = &scratch;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment