Home | History | Annotate | Line # | Download | only in xaa
      1 
      2 #ifdef HAVE_XORG_CONFIG_H
      3 #include <xorg-config.h>
      4 #endif
      5 
      6 #include "misc.h"
      7 #include "xf86.h"
      8 #include "xf86_OSproc.h"
      9 
     10 #include <X11/X.h>
     11 #include "scrnintstr.h"
     12 #include "windowstr.h"
     13 #include "xf86str.h"
     14 #include "xaa.h"
     15 #include "xaalocal.h"
     16 #include "gcstruct.h"
     17 #include "pixmapstr.h"
     18 #include "xaawrap.h"
     19 
     20 /*
     21     Written by Harm Hanemaayer (H.Hanemaayer (at) inter.nl.net).
     22 */
     23 
     24 void
     25 XAACopyWindow(
     26     WindowPtr pWin,
     27     DDXPointRec ptOldOrg,
     28     RegionPtr prgnSrc )
     29 {
     30     DDXPointPtr pptSrc, ppt;
     31     RegionRec rgnDst;
     32     BoxPtr pbox;
     33     int dx, dy, nbox;
     34     WindowPtr pwinRoot;
     35     ScreenPtr pScreen = pWin->drawable.pScreen;
     36     XAAInfoRecPtr infoRec =
     37 	GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable));
     38 
     39     if (!infoRec->pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) {
     40 	XAA_SCREEN_PROLOGUE (pScreen, CopyWindow);
     41 	if(infoRec->pScrn->vtSema && infoRec->NeedToSync) {
     42 	    (*infoRec->Sync)(infoRec->pScrn);
     43 	    infoRec->NeedToSync = FALSE;
     44 	}
     45         (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
     46 	XAA_SCREEN_EPILOGUE (pScreen, CopyWindow, XAACopyWindow);
     47     	return;
     48     }
     49 
     50     pwinRoot = pScreen->root;
     51 
     52     RegionNull(&rgnDst);
     53 
     54     dx = ptOldOrg.x - pWin->drawable.x;
     55     dy = ptOldOrg.y - pWin->drawable.y;
     56     RegionTranslate(prgnSrc, -dx, -dy);
     57     RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
     58 
     59     pbox = RegionRects(&rgnDst);
     60     nbox = RegionNumRects(&rgnDst);
     61     if(!nbox ||
     62       !(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) {
     63 	RegionUninit(&rgnDst);
     64 	return;
     65     }
     66     ppt = pptSrc;
     67 
     68     while(nbox--) {
     69 	ppt->x = pbox->x1 + dx;
     70 	ppt->y = pbox->y1 + dy;
     71 	ppt++; pbox++;
     72     }
     73 
     74     infoRec->ScratchGC.planemask = ~0L;
     75     infoRec->ScratchGC.alu = GXcopy;
     76 
     77     XAADoBitBlt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
     78         		&(infoRec->ScratchGC), &rgnDst, pptSrc);
     79 
     80     free(pptSrc);
     81     RegionUninit(&rgnDst);
     82 }
     83