1
/* $XFree86: xc/programs/Xserver/iplan2p4/iplbitblt.c,v 3.1tsi Exp $ */
8
Copyright (c) 1989 X Consortium
10
Permission is hereby granted, free of charge, to any person obtaining a copy
11
of this software and associated documentation files (the "Software"), to deal
12
in the Software without restriction, including without limitation the rights
13
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
copies of the Software, and to permit persons to whom the Software is
15
furnished to do so, subject to the following conditions:
17
The above copyright notice and this permission notice shall be included in
18
all copies or substantial portions of the Software.
20
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
24
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
Except as contained in this notice, the name of the X Consortium shall not be
28
used in advertising or otherwise to promote the sale, use or other dealings
29
in this Software without prior written authorization from the X Consortium.
34
/* $XConsortium: iplbitblt.c,v 5.51 94/05/27 11:00:56 dpw Exp $ */
36
/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
39
#ifdef HAVE_DIX_CONFIG_H
40
#include <dix-config.h>
45
#include <X11/Xproto.h>
47
#include "windowstr.h"
48
#include "scrnintstr.h"
49
#include "pixmapstr.h"
50
#include "regionstr.h"
53
#define MFB_CONSTS_ONLY
56
#include "iplmskbits.h"
59
iplBitBlt (pSrcDrawable, pDstDrawable,
60
pGC, srcx, srcy, width, height, dstx, dsty, doBitBlt, bitPlane)
61
register DrawablePtr pSrcDrawable;
62
register DrawablePtr pDstDrawable;
68
unsigned long bitPlane;
70
RegionPtr prgnSrcClip; /* may be a new region, or just a copy */
71
Bool freeSrcClip = FALSE;
73
RegionPtr prgnExposed;
76
register DDXPointPtr ppt;
81
xRectangle origSource;
85
int fastClip = 0; /* for fast clipping with pixmap source */
86
int fastExpose = 0; /* for fast exposures with pixmap source */
90
origSource.width = width;
91
origSource.height = height;
95
if ((pSrcDrawable != pDstDrawable) &&
96
pSrcDrawable->pScreen->SourceValidate)
98
(*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, srcx, srcy, width, height);
101
srcx += pSrcDrawable->x;
102
srcy += pSrcDrawable->y;
104
/* clip the source */
106
if (pSrcDrawable->type == DRAWABLE_PIXMAP)
108
if ((pSrcDrawable == pDstDrawable) &&
109
(pGC->clientClipType == CT_NONE))
111
prgnSrcClip = iplGetCompositeClip(pGC);
120
if (pGC->subWindowMode == IncludeInferiors)
122
if (!((WindowPtr) pSrcDrawable)->parent)
125
* special case bitblt from root window in
126
* IncludeInferiors mode; just like from a pixmap
130
else if ((pSrcDrawable == pDstDrawable) &&
131
(pGC->clientClipType == CT_NONE))
133
prgnSrcClip = iplGetCompositeClip(pGC);
137
prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable);
143
prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList;
149
fastBox.x2 = srcx + width;
150
fastBox.y2 = srcy + height;
152
/* Don't create a source region if we are doing a fast clip */
157
* clip the source; if regions extend beyond the source size,
158
* make sure exposure events get sent
160
if (fastBox.x1 < pSrcDrawable->x)
162
fastBox.x1 = pSrcDrawable->x;
165
if (fastBox.y1 < pSrcDrawable->y)
167
fastBox.y1 = pSrcDrawable->y;
170
if (fastBox.x2 > pSrcDrawable->x + (int) pSrcDrawable->width)
172
fastBox.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
175
if (fastBox.y2 > pSrcDrawable->y + (int) pSrcDrawable->height)
177
fastBox.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
183
REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
184
REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
187
dstx += pDstDrawable->x;
188
dsty += pDstDrawable->y;
190
if (pDstDrawable->type == DRAWABLE_WINDOW)
192
if (!((WindowPtr)pDstDrawable)->realized)
195
REGION_UNINIT(pGC->pScreen, &rgnDst);
197
REGION_DESTROY(pGC->pScreen, prgnSrcClip);
205
/* Translate and clip the dst to the destination composite clip */
210
/* Translate the region directly */
216
/* If the destination composite clip is one rectangle we can
217
do the clip directly. Otherwise we have to create a full
218
blown region and call intersect */
220
/* XXX because CopyPlane uses this routine for 8-to-1 bit
221
* copies, this next line *must* also correctly fetch the
222
* composite clip from an mfb gc
225
cclip = iplGetCompositeClip(pGC);
226
if (REGION_NUM_RECTS(cclip) == 1)
228
BoxPtr pBox = REGION_RECTS(cclip);
230
if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1;
231
if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2;
232
if (fastBox.y1 < pBox->y1) fastBox.y1 = pBox->y1;
233
if (fastBox.y2 > pBox->y2) fastBox.y2 = pBox->y2;
235
/* Check to see if the region is empty */
236
if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2)
238
REGION_NULL(pGC->pScreen, &rgnDst);
242
REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
247
/* We must turn off fastClip now, since we must create
248
a full blown region. It is intersected with the
249
composite clip below. */
251
REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
256
REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
261
REGION_INTERSECT(pGC->pScreen, &rgnDst,
263
iplGetCompositeClip(pGC));
266
/* Do bit blitting */
267
numRects = REGION_NUM_RECTS(&rgnDst);
268
if (numRects && width && height)
270
if(!(pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(numRects *
271
sizeof(DDXPointRec))))
273
REGION_UNINIT(pGC->pScreen, &rgnDst);
275
REGION_DESTROY(pGC->pScreen, prgnSrcClip);
278
pbox = REGION_RECTS(&rgnDst);
280
for (i = numRects; --i >= 0; pbox++, ppt++)
282
ppt->x = pbox->x1 + dx;
283
ppt->y = pbox->y1 + dy;
286
(*doBitBlt) (pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc, pGC->planemask, bitPlane);
287
DEALLOCATE_LOCAL(pptSrc);
293
extern RegionPtr miHandleExposures();
295
/* Pixmap sources generate a NoExposed (we return NULL to do this) */
298
miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
299
origSource.x, origSource.y,
300
(int)origSource.width,
301
(int)origSource.height,
302
origDest.x, origDest.y, bitPlane);
304
REGION_UNINIT(pGC->pScreen, &rgnDst);
306
REGION_DESTROY(pGC->pScreen, prgnSrcClip);
312
iplDoBitblt (pSrc, pDst, alu, prgnDst, pptSrc, planemask)
313
DrawablePtr pSrc, pDst;
317
unsigned long planemask;
319
void (*blt)() = iplDoBitbltGeneral;
320
if ((planemask & INTER_PMSK) == INTER_PMSK) {
323
blt = iplDoBitbltCopy;
326
blt = iplDoBitbltXor;
333
(*blt) (pSrc, pDst, alu, prgnDst, pptSrc, planemask);
337
iplCopyArea(pSrcDrawable, pDstDrawable,
338
pGC, srcx, srcy, width, height, dstx, dsty)
339
register DrawablePtr pSrcDrawable;
340
register DrawablePtr pDstDrawable;
348
doBitBlt = iplDoBitbltCopy;
349
if (pGC->alu != GXcopy || (pGC->planemask & INTER_PMSK) != INTER_PMSK)
351
doBitBlt = iplDoBitbltGeneral;
352
if ((pGC->planemask & INTER_PMSK) == INTER_PMSK)
356
doBitBlt = iplDoBitbltXor;
359
doBitBlt = iplDoBitbltOr;
364
return iplBitBlt (pSrcDrawable, pDstDrawable,
365
pGC, srcx, srcy, width, height, dstx, dsty, doBitBlt, 0L);
368
/* shared among all different ipl depths through linker magic */
369
RegionPtr (*iplPuntCopyPlane)();
371
RegionPtr iplCopyPlane(pSrcDrawable, pDstDrawable,
372
pGC, srcx, srcy, width, height, dstx, dsty, bitPlane)
373
DrawablePtr pSrcDrawable;
374
DrawablePtr pDstDrawable;
379
unsigned long bitPlane;
382
extern RegionPtr miHandleExposures();
385
ret = (*iplPuntCopyPlane) (pSrcDrawable, pDstDrawable,
386
pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);