home *** CD-ROM | disk | FTP | other *** search
- /*
- * skyway copy area: same as cfb except uses skyway accelerator.
- */
-
- /*
- Copyright 1989 by the Massachusetts Institute of Technology
-
- Permission to use, copy, modify, and distribute this software and its
- documentation for any purpose and without fee is hereby granted,
- provided that the above copyright notice appear in all copies and that
- both that copyright notice and this permission notice appear in
- supporting documentation, and that the name of M.I.T. not be used in
- advertising or publicity pertaining to distribution of the software
- without specific, written prior permission. M.I.T. makes no
- representations about the suitability of this software for any
- purpose. It is provided "as is" without express or implied warranty.
-
- */
- /* $XConsortium: skyBitBlt.c,v 1.2 91/11/08 19:31:16 eswu Exp $ */
-
- #include "X.h"
- #include "Xmd.h"
- #include "Xproto.h"
- #include "gcstruct.h"
- #include "windowstr.h"
- #include "scrnintstr.h"
- #include "pixmapstr.h"
- #include "regionstr.h"
-
- #include "cfb.h"
- #include "cfbmskbits.h"
- #include "cfb8bit.h"
- #include "fastblt.h"
-
-
- extern int cfbDoBitbltCopy();
- extern int cfbDoBitbltXor();
- extern int cfbDoBitbltOr();
- extern int cfbDoBitbltGeneral();
- extern int cfbDoBitblt();
-
- extern RegionPtr cfbBitBlt();
-
-
- RegionPtr
- skyCopyArea(pSrcDrawable, pDstDrawable,
- pGC, srcx, srcy, width, height, dstx, dsty)
- register DrawablePtr pSrcDrawable;
- register DrawablePtr pDstDrawable;
- GC *pGC;
- int srcx, srcy;
- int width, height;
- int dstx, dsty;
- {
- int (*doBitBlt) ();
- int skyDoBitblt_WinToWin();
-
- doBitBlt = cfbDoBitbltCopy;
-
- if ((pSrcDrawable->type == DRAWABLE_WINDOW) &&
- (pDstDrawable->type == DRAWABLE_WINDOW))
- {
- doBitBlt = skyDoBitblt_WinToWin;
- }
- else if (pGC->alu != GXcopy || (pGC->planemask & PMSK) != PMSK)
- {
- doBitBlt = cfbDoBitbltGeneral;
- if ((pGC->planemask & PMSK) == PMSK)
- {
- switch (pGC->alu) {
- case GXxor:
- doBitBlt = cfbDoBitbltXor;
- break;
- case GXor:
- doBitBlt = cfbDoBitbltOr;
- break;
- }
- }
- }
- return cfbBitBlt (pSrcDrawable, pDstDrawable,
- pGC, srcx, srcy, width, height, dstx, dsty, doBitBlt, 0);
- }
-
-
-
- int
- skyDoBitblt_WinToWin(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
- DrawablePtr pSrc, pDst;
- int alu;
- RegionPtr prgnDst;
- DDXPointPtr pptSrc;
- unsigned long planemask;
- {
- BoxPtr pbox;
- int nbox;
-
- BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
- /* temporaries for shuffling rectangles */
- DDXPointPtr pptTmp, pptNew1, pptNew2;
- /* shuffling boxes entails shuffling the
- source points too */
- int w, h;
- int xdir; /* 1 = left right, -1 = right left/ */
- int ydir; /* 1 = top down, -1 = bottom up */
-
- int careful;
-
-
- /* XXX we have to err on the side of safety when both are windows,
- * because we don't know if IncludeInferiors is being used.
- */
- careful = ((pSrc == pDst) ||
- ((pSrc->type == DRAWABLE_WINDOW) &&
- (pDst->type == DRAWABLE_WINDOW)));
-
- pbox = REGION_RECTS(prgnDst);
- nbox = REGION_NUM_RECTS(prgnDst);
-
- pboxNew1 = NULL;
- pptNew1 = NULL;
- pboxNew2 = NULL;
- pptNew2 = NULL;
- if (careful && (pptSrc->y < pbox->y1))
- {
- /* walk source botttom to top */
- ydir = -1;
-
- if (nbox > 1)
- {
- /* keep ordering in each band, reverse order of bands */
- pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
- if(!pboxNew1)
- return;
- pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);
- if(!pptNew1)
- {
- DEALLOCATE_LOCAL(pboxNew1);
- return;
- }
- pboxBase = pboxNext = pbox+nbox-1;
- while (pboxBase >= pbox)
- {
- while ((pboxNext >= pbox) &&
- (pboxBase->y1 == pboxNext->y1))
- pboxNext--;
- pboxTmp = pboxNext+1;
- pptTmp = pptSrc + (pboxTmp - pbox);
- while (pboxTmp <= pboxBase)
- {
- *pboxNew1++ = *pboxTmp++;
- *pptNew1++ = *pptTmp++;
- }
- pboxBase = pboxNext;
- }
- pboxNew1 -= nbox;
- pbox = pboxNew1;
- pptNew1 -= nbox;
- pptSrc = pptNew1;
- }
- }
- else
- {
- /* walk source top to bottom */
- ydir = 1;
- }
-
- if (careful && (pptSrc->x < pbox->x1))
- {
- /* walk source right to left */
- xdir = -1;
-
- if (nbox > 1)
- {
- /* reverse order of rects in each band */
- pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
- pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);
- if(!pboxNew2 || !pptNew2)
- {
- if (pptNew2) DEALLOCATE_LOCAL(pptNew2);
- if (pboxNew2) DEALLOCATE_LOCAL(pboxNew2);
- if (pboxNew1)
- {
- DEALLOCATE_LOCAL(pptNew1);
- DEALLOCATE_LOCAL(pboxNew1);
- }
- return;
- }
- pboxBase = pboxNext = pbox;
- while (pboxBase < pbox+nbox)
- {
- while ((pboxNext < pbox+nbox) &&
- (pboxNext->y1 == pboxBase->y1))
- pboxNext++;
- pboxTmp = pboxNext;
- pptTmp = pptSrc + (pboxTmp - pbox);
- while (pboxTmp != pboxBase)
- {
- *pboxNew2++ = *--pboxTmp;
- *pptNew2++ = *--pptTmp;
- }
- pboxBase = pboxNext;
- }
- pboxNew2 -= nbox;
- pbox = pboxNew2;
- pptNew2 -= nbox;
- pptSrc = pptNew2;
- }
- }
- else
- {
- /* walk source left to right */
- xdir = 1;
- }
-
- while(nbox--)
- {
- w = pbox->x2 - pbox->x1;
- h = pbox->y2 - pbox->y1;
-
-
- /*-------*/
-
-
- SkywayBitBlt(alu, pDst->pScreen, planemask,
- pptSrc->x, pptSrc->y, /* source x,y */
- pbox->x1, pbox->y1, /* dest x,y */
- w, h); /* width, height */
-
-
- /*-------*/
-
- pbox++;
- pptSrc++;
- }
-
- if (pboxNew2)
- {
- DEALLOCATE_LOCAL(pptNew2);
- DEALLOCATE_LOCAL(pboxNew2);
- }
- if (pboxNew1)
- {
- DEALLOCATE_LOCAL(pptNew1);
- DEALLOCATE_LOCAL(pboxNew1);
- }
- }
-