2 * Push Pixels for 8 bit displays.
7 Copyright (c) 1989 X Consortium
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 Except as contained in this notice, the name of the X Consortium shall not be
27 used in advertising or otherwise to promote the sale, use or other dealings
28 in this Software without prior written authorization from the X Consortium.
30 /* $XConsortium: cfbpush8.c,v 5.14 94/04/17 20:28:58 dpw Exp $ */
38 #include "windowstr.h"
39 #include "scrnintstr.h"
40 #include "pixmapstr.h"
41 #include "regionstr.h"
43 #include "cfbmskbits.h"
45 #define MFB_CONSTS_ONLY
49 cfbPushPixels8 (pGC, pBitmap, pDrawable, dx, dy, xOrg, yOrg)
52 DrawablePtr pDrawable;
53 int dx, dy, xOrg, yOrg;
55 register unsigned long *src, *dst;
56 register unsigned long pixel;
57 register unsigned long c, bits;
58 unsigned long *pdstLine, *psrcLine;
59 unsigned long *pdstBase;
63 int nBitmapLongs, nPixmapLongs;
64 int nBitmapTmp, nPixmapTmp;
65 unsigned long rightMask;
71 bbox.x2 = bbox.x1 + dx;
72 bbox.y2 = bbox.y1 + dy;
73 devPriv = cfbGetGCPrivate(pGC);
75 switch (RECT_IN_REGION(pGC->pScreen, devPriv->pCompositeClip, &bbox))
78 mfbPushPixels(pGC, pBitmap, pDrawable, dx, dy, xOrg, yOrg);
83 cfbGetLongWidthAndPointer (pDrawable, dstWidth, pdstBase)
85 psrcLine = (unsigned long *) pBitmap->devPrivate.ptr;
86 srcWidth = (int) pBitmap->devKind >> PWSH;
90 nBitmapLongs = (dx + xoff) >> MFB_PWSH;
91 nPixmapLongs = (dx + PGSZB + xoff) >> PWSH;
93 rightMask = ~cfb8BitLenMasks[((dx + xoff) & MFB_PIM)];
95 pdstLine = pdstBase + (yOrg * dstWidth) + (xOrg >> PWSH);
100 nPixmapTmp = nPixmapLongs;
101 nBitmapTmp = nBitmapLongs;
107 c |= BitRight (bits, xoff);
108 WriteBitGroup(dst, pixel, GetBitGroup(c));
111 WriteBitGroup(dst, pixel, GetBitGroup(c));
114 WriteBitGroup(dst, pixel, GetBitGroup(c));
117 WriteBitGroup(dst, pixel, GetBitGroup(c));
120 WriteBitGroup(dst, pixel, GetBitGroup(c));
123 WriteBitGroup(dst, pixel, GetBitGroup(c));
126 WriteBitGroup(dst, pixel, GetBitGroup(c));
129 WriteBitGroup(dst, pixel, GetBitGroup(c));
135 c = BitLeft (bits, PGSZ - xoff);
137 if (BitLeft (rightMask, xoff))
138 c |= BitRight (*src, xoff);
140 switch (nPixmapTmp) {
142 WriteBitGroup(dst, pixel, GetBitGroup(c));
146 WriteBitGroup(dst, pixel, GetBitGroup(c));
150 WriteBitGroup(dst, pixel, GetBitGroup(c));
154 WriteBitGroup(dst, pixel, GetBitGroup(c));
158 WriteBitGroup(dst, pixel, GetBitGroup(c));
162 WriteBitGroup(dst, pixel, GetBitGroup(c));
166 WriteBitGroup(dst, pixel, GetBitGroup(c));
170 WriteBitGroup(dst, pixel, GetBitGroup(c));
176 pdstLine += dstWidth;
177 psrcLine += srcWidth;