1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
/*
This is a lighter version of cfbBitBlt. We calculate the boxes
when accelerating pixmap->screen and screen->screen copies.
We also pass the GC to the doBitBlt function so that it has access
to the fg and bg so CopyPlane can use this.
*/
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
#include "misc.h"
#include "xf86.h"
#include "xf86_OSproc.h"
#include <X11/X.h>
#include "mi.h"
#include "pixmapstr.h"
#include "gcstruct.h"
#include "windowstr.h"
#include "xaalocal.h"
RegionPtr
XAABitBlt(
DrawablePtr pSrcDrawable,
DrawablePtr pDstDrawable,
GC *pGC,
int srcx, int srcy,
int width, int height,
int dstx, int dsty,
void (*doBitBlt)(DrawablePtr, DrawablePtr, GCPtr, RegionPtr, DDXPointPtr),
unsigned long bitPlane )
{
RegionPtr prgnSrcClip = NULL; /* may be a new region, or just a copy */
RegionPtr prgnExposed;
Bool freeSrcClip = FALSE;
RegionRec rgnDst;
DDXPointPtr pptSrc, ppt;
DDXPointRec origDest;
BoxPtr pbox;
BoxRec fastBox;
int i, dx, dy, numRects;
xRectangle origSource;
int fastClip = 0; /* for fast clipping with pixmap source */
int fastExpose = 0; /* for fast exposures with pixmap source */
origSource.x = srcx;
origSource.y = srcy;
origSource.width = width;
origSource.height = height;
origDest.x = dstx;
origDest.y = dsty;
if((pSrcDrawable != pDstDrawable) &&
pSrcDrawable->pScreen->SourceValidate) {
(*pSrcDrawable->pScreen->SourceValidate) (
pSrcDrawable, srcx, srcy, width, height);
}
srcx += pSrcDrawable->x;
srcy += pSrcDrawable->y;
/* clip the source */
if (pSrcDrawable->type == DRAWABLE_PIXMAP) {
if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE))
prgnSrcClip = pGC->pCompositeClip;
else
fastClip = 1;
} else { /* Window */
if (pGC->subWindowMode == IncludeInferiors) {
if (!((WindowPtr) pSrcDrawable)->parent) {
/*
* special case bitblt from root window in
* IncludeInferiors mode; just like from a pixmap
*/
fastClip = 1;
} else if ((pSrcDrawable == pDstDrawable) &&
(pGC->clientClipType == CT_NONE)) {
prgnSrcClip = pGC->pCompositeClip;
} else {
prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable);
freeSrcClip = TRUE;
}
} else {
prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList;
}
}
fastBox.x1 = srcx;
fastBox.y1 = srcy;
fastBox.x2 = srcx + width;
fastBox.y2 = srcy + height;
/* Don't create a source region if we are doing a fast clip */
if (fastClip) {
fastExpose = 1;
/*
* clip the source; if regions extend beyond the source size,
* make sure exposure events get sent
*/
if (fastBox.x1 < pSrcDrawable->x) {
fastBox.x1 = pSrcDrawable->x;
fastExpose = 0;
}
if (fastBox.y1 < pSrcDrawable->y) {
fastBox.y1 = pSrcDrawable->y;
fastExpose = 0;
}
if (fastBox.x2 > pSrcDrawable->x + (int) pSrcDrawable->width) {
fastBox.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
fastExpose = 0;
}
if (fastBox.y2 > pSrcDrawable->y + (int) pSrcDrawable->height) {
fastBox.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
fastExpose = 0;
}
} else {
REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
}
dstx += pDstDrawable->x;
dsty += pDstDrawable->y;
if (pDstDrawable->type == DRAWABLE_WINDOW) {
if (!((WindowPtr)pDstDrawable)->realized) {
if (!fastClip)
REGION_UNINIT(pGC->pScreen, &rgnDst);
if (freeSrcClip)
REGION_DESTROY(pGC->pScreen, prgnSrcClip);
return NULL;
}
}
dx = srcx - dstx;
dy = srcy - dsty;
/* Translate and clip the dst to the destination composite clip */
if (fastClip) {
RegionPtr cclip;
/* Translate the region directly */
fastBox.x1 -= dx;
fastBox.x2 -= dx;
fastBox.y1 -= dy;
fastBox.y2 -= dy;
/* If the destination composite clip is one rectangle we can
do the clip directly. Otherwise we have to create a full
blown region and call intersect */
cclip = pGC->pCompositeClip;
if (REGION_NUM_RECTS(cclip) == 1) {
BoxPtr pBox = REGION_RECTS(cclip);
if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1;
if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2;
if (fastBox.y1 < pBox->y1) fastBox.y1 = pBox->y1;
if (fastBox.y2 > pBox->y2) fastBox.y2 = pBox->y2;
/* Check to see if the region is empty */
if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2) {
REGION_NULL(pGC->pScreen, &rgnDst);
} else {
REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
}
} else {
/* We must turn off fastClip now, since we must create
a full blown region. It is intersected with the
composite clip below. */
fastClip = 0;
REGION_INIT(pGC->pScreen, &rgnDst, &fastBox,1);
}
} else {
REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
}
if (!fastClip) {
REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst,
pGC->pCompositeClip);
}
/* Do bit blitting */
numRects = REGION_NUM_RECTS(&rgnDst);
if (numRects && width && height) {
if(!(pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(numRects *
sizeof(DDXPointRec)))) {
REGION_UNINIT(pGC->pScreen, &rgnDst);
if (freeSrcClip)
REGION_DESTROY(pGC->pScreen, prgnSrcClip);
return NULL;
}
pbox = REGION_RECTS(&rgnDst);
ppt = pptSrc;
for (i = numRects; --i >= 0; pbox++, ppt++) {
ppt->x = pbox->x1 + dx;
ppt->y = pbox->y1 + dy;
}
(*doBitBlt) (pSrcDrawable, pDstDrawable, pGC, &rgnDst, pptSrc);
DEALLOCATE_LOCAL(pptSrc);
}
prgnExposed = NULL;
if (pGC->fExpose) {
/* Pixmap sources generate a NoExposed (we return NULL to do this) */
if (!fastExpose)
prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
origSource.x, origSource.y,
(int)origSource.width,
(int)origSource.height,
origDest.x, origDest.y, bitPlane);
}
REGION_UNINIT(pGC->pScreen, &rgnDst);
if (freeSrcClip)
REGION_DESTROY(pGC->pScreen, prgnSrcClip);
return prgnExposed;
}
|