First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / xaa / xaaCpyWin.c
blob1ff955c6c9fca1eef2b814fb8c446fb88bf31e5a
2 #ifdef HAVE_XORG_CONFIG_H
3 #include <xorg-config.h>
4 #endif
6 #include "misc.h"
7 #include "xf86.h"
8 #include "xf86_OSproc.h"
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"
21 Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
24 void
25 XAACopyWindow(
26 WindowPtr pWin,
27 DDXPointRec ptOldOrg,
28 RegionPtr prgnSrc )
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));
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;
45 (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
46 XAA_SCREEN_EPILOGUE (pScreen, CopyWindow, XAACopyWindow);
47 return;
50 pwinRoot = WindowTable[pScreen->myNum];
52 REGION_NULL(pScreen, &rgnDst);
54 dx = ptOldOrg.x - pWin->drawable.x;
55 dy = ptOldOrg.y - pWin->drawable.y;
56 REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
57 REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
59 pbox = REGION_RECTS(&rgnDst);
60 nbox = REGION_NUM_RECTS(&rgnDst);
61 if(!nbox ||
62 !(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec)))) {
63 REGION_UNINIT(pScreen, &rgnDst);
64 return;
66 ppt = pptSrc;
68 while(nbox--) {
69 ppt->x = pbox->x1 + dx;
70 ppt->y = pbox->y1 + dy;
71 ppt++; pbox++;
74 infoRec->ScratchGC.planemask = ~0L;
75 infoRec->ScratchGC.alu = GXcopy;
77 XAADoBitBlt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
78 &(infoRec->ScratchGC), &rgnDst, pptSrc);
80 DEALLOCATE_LOCAL(pptSrc);
81 REGION_UNINIT(pScreen, &rgnDst);