#define PSZ 32
#include "scrnintstr.h"
#include "pixmapstr.h"
#include "regionstr.h"
#include "mistruct.h"
#include "fontstruct.h"
#include "dixfontstr.h"
#include "cfb.h"
#include "cfbmskbits.h"
#include "cfb8bit.h"
#include "mibstore.h"
#include "mifillarc.h"
#include "miwideline.h"
#include "fastblt.h"
#include "mergerop.h"
#include "migc.h"
#include "mi.h"
#include "leo.h"
#include "leo_gc.h"
int LeoScreenPrivateIndex;
int LeoGCPrivateIndex;
int LeoWindowPrivateIndex;
int LeoGeneration;
int leoRopTable[16] = {
LEO_ATTR_RGBE_ENABLE|LEO_ROP_ZERO,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_AND_OLD,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_AND_NOLD,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_AND_OLD,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_OLD,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_XOR_OLD,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_OR_OLD,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_AND_NOLD,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_XOR_NOLD,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_NOLD,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_OR_NOLD,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_OR_OLD,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_OR_NOLD,
LEO_ATTR_RGBE_ENABLE|LEO_ROP_ONES
};
static void
LeoCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
LeoPtr pLeo = LeoGetScreenPrivate (pScreen);
DDXPointPtr pptSrc;
DDXPointPtr ppt;
RegionPtr prgnDst;
BoxPtr pbox;
int dx, dy;
int i, nbox;
WindowPtr pwinRoot;
if (pLeo->vtSema)
return;
dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, &pWin->borderClip, prgnSrc);
pbox = REGION_RECTS(prgnDst);
nbox = REGION_NUM_RECTS(prgnDst);
if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
return;
ppt = pptSrc;
for (i = nbox; --i >= 0; ppt++, pbox++) {
ppt->x = pbox->x1 + dx;
ppt->y = pbox->y1 + dy;
}
LeoDoBitblt ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
GXcopy, prgnDst, pptSrc, ~0L);
DEALLOCATE_LOCAL(pptSrc);
REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
}
void LeoVtChange (ScreenPtr pScreen, int enter)
{
LeoPtr pLeo = LeoGetScreenPrivate (pScreen);
LeoCommand0 *lc0 = pLeo->lc0;
LeoDraw *ld0 = pLeo->ld0;
ld0->wid = 1;
ld0->widclip = 0;
ld0->wmask = 0xffff;
ld0->planemask = 0xffffff;
ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID;
ld0->fg = 0;
ld0->vclipmin = 0;
ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16);
while (lc0->csr & LEO_CSR_BLT_BUSY);
lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11);
lc0->fill = 0;
while (lc0->csr & LEO_CSR_BLT_BUSY);
lc0->addrspace = LEO_ADDRSPC_OBGR;
ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
}
extern Bool LeoCreateGC (GCPtr pGC);
Bool LeoAccelInit (ScreenPtr pScreen, LeoPtr pLeo)
{
LeoCommand0 *lc0;
LeoDraw *ld0;
if (serverGeneration != LeoGeneration) {
LeoScreenPrivateIndex = AllocateScreenPrivateIndex ();
if (LeoScreenPrivateIndex == -1) return FALSE;
LeoGCPrivateIndex = AllocateGCPrivateIndex ();
LeoWindowPrivateIndex = AllocateWindowPrivateIndex ();
LeoGeneration = serverGeneration;
}
if (!AllocateGCPrivate(pScreen, LeoGCPrivateIndex, sizeof(LeoPrivGCRec))) return FALSE;
if (!AllocateWindowPrivate(pScreen, LeoWindowPrivateIndex, 0)) return FALSE;
pScreen->devPrivates[LeoScreenPrivateIndex].ptr = pLeo;
pLeo->lc0 = lc0 = (LeoCommand0 *) ((char *)pLeo->fb + LEO_LC0_VOFF);
pLeo->ld0 = ld0 = (LeoDraw *) ((char *)pLeo->fb + LEO_LD0_VOFF);
if (!pLeo->NoAccel) {
pScreen->CreateGC = LeoCreateGC;
pScreen->CopyWindow = LeoCopyWindow;
}
ld0->wid = 1;
ld0->widclip = 0;
ld0->wmask = 0xffff;
ld0->planemask = 0xffffff;
ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID;
ld0->fg = 0;
ld0->vclipmin = 0;
ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16);
pLeo->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16);
pLeo->width = pLeo->psdp->width;
pLeo->height = pLeo->psdp->height;
while (lc0->csr & LEO_CSR_BLT_BUSY);
lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11);
lc0->fill = 0;
while (lc0->csr & LEO_CSR_BLT_BUSY);
lc0->addrspace = LEO_ADDRSPC_OBGR;
ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
return TRUE;
}