]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/cfb/cfbpush8.c
Import X server from vnc-3.3.7.
[rdpsrv] / Xserver / programs / Xserver / cfb / cfbpush8.c
1 /*
2  * Push Pixels for 8 bit displays.
3  */
4
5 /*
6
7 Copyright (c) 1989  X Consortium
8
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:
15
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18
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.
25
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.
29 */
30 /* $XConsortium: cfbpush8.c,v 5.14 94/04/17 20:28:58 dpw Exp $ */
31
32 #if PSZ == 8
33
34 #include        "X.h"
35 #include        "Xmd.h"
36 #include        "Xproto.h"
37 #include        "gcstruct.h"
38 #include        "windowstr.h"
39 #include        "scrnintstr.h"
40 #include        "pixmapstr.h"
41 #include        "regionstr.h"
42 #include        "cfb.h"
43 #include        "cfbmskbits.h"
44 #include        "cfb8bit.h"
45 #define MFB_CONSTS_ONLY
46 #include        "maskbits.h"
47
48 void
49 cfbPushPixels8 (pGC, pBitmap, pDrawable, dx, dy, xOrg, yOrg)
50     GCPtr       pGC;
51     PixmapPtr   pBitmap;
52     DrawablePtr pDrawable;
53     int         dx, dy, xOrg, yOrg;
54 {
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;
60     int             srcWidth;
61     int             dstWidth;
62     int             xoff;
63     int             nBitmapLongs, nPixmapLongs;
64     int             nBitmapTmp, nPixmapTmp;
65     unsigned long   rightMask;
66     BoxRec          bbox;
67     cfbPrivGCPtr    devPriv;
68
69     bbox.x1 = xOrg;
70     bbox.y1 = yOrg;
71     bbox.x2 = bbox.x1 + dx;
72     bbox.y2 = bbox.y1 + dy;
73     devPriv = cfbGetGCPrivate(pGC);
74     
75     switch (RECT_IN_REGION(pGC->pScreen, devPriv->pCompositeClip, &bbox))
76     {
77       case rgnPART:
78         mfbPushPixels(pGC, pBitmap, pDrawable, dx, dy, xOrg, yOrg);
79       case rgnOUT:
80         return;
81     }
82
83     cfbGetLongWidthAndPointer (pDrawable, dstWidth, pdstBase)
84
85     psrcLine = (unsigned long *) pBitmap->devPrivate.ptr;
86     srcWidth = (int) pBitmap->devKind >> PWSH;
87     
88     pixel = devPriv->xor;
89     xoff = xOrg & PIM;
90     nBitmapLongs = (dx + xoff) >> MFB_PWSH;
91     nPixmapLongs = (dx + PGSZB + xoff) >> PWSH;
92
93     rightMask = ~cfb8BitLenMasks[((dx + xoff) & MFB_PIM)];
94
95     pdstLine = pdstBase + (yOrg * dstWidth) + (xOrg >> PWSH);
96
97     while (dy--)
98     {
99         c = 0;
100         nPixmapTmp = nPixmapLongs;
101         nBitmapTmp = nBitmapLongs;
102         src = psrcLine;
103         dst = pdstLine;
104         while (nBitmapTmp--)
105         {
106             bits = *src++;
107             c |= BitRight (bits, xoff);
108             WriteBitGroup(dst, pixel, GetBitGroup(c));
109             NextBitGroup(c);
110             dst++;
111             WriteBitGroup(dst, pixel, GetBitGroup(c));
112             NextBitGroup(c);
113             dst++;
114             WriteBitGroup(dst, pixel, GetBitGroup(c));
115             NextBitGroup(c);
116             dst++;
117             WriteBitGroup(dst, pixel, GetBitGroup(c));
118             NextBitGroup(c);
119             dst++;
120             WriteBitGroup(dst, pixel, GetBitGroup(c));
121             NextBitGroup(c);
122             dst++;
123             WriteBitGroup(dst, pixel, GetBitGroup(c));
124             NextBitGroup(c);
125             dst++;
126             WriteBitGroup(dst, pixel, GetBitGroup(c));
127             NextBitGroup(c);
128             dst++;
129             WriteBitGroup(dst, pixel, GetBitGroup(c));
130             NextBitGroup(c);
131             dst++;
132             nPixmapTmp -= 8;
133             c = 0;
134             if (xoff)
135                 c = BitLeft (bits, PGSZ - xoff);
136         }
137         if (BitLeft (rightMask, xoff))
138             c |= BitRight (*src, xoff);
139         c &= rightMask;
140         switch (nPixmapTmp) {
141         case 8:
142             WriteBitGroup(dst, pixel, GetBitGroup(c));
143             NextBitGroup(c);
144             dst++;
145         case 7:
146             WriteBitGroup(dst, pixel, GetBitGroup(c));
147             NextBitGroup(c);
148             dst++;
149         case 6:
150             WriteBitGroup(dst, pixel, GetBitGroup(c));
151             NextBitGroup(c);
152             dst++;
153         case 5:
154             WriteBitGroup(dst, pixel, GetBitGroup(c));
155             NextBitGroup(c);
156             dst++;
157         case 4:
158             WriteBitGroup(dst, pixel, GetBitGroup(c));
159             NextBitGroup(c);
160             dst++;
161         case 3:
162             WriteBitGroup(dst, pixel, GetBitGroup(c));
163             NextBitGroup(c);
164             dst++;
165         case 2:
166             WriteBitGroup(dst, pixel, GetBitGroup(c));
167             NextBitGroup(c);
168             dst++;
169         case 1:
170             WriteBitGroup(dst, pixel, GetBitGroup(c));
171             NextBitGroup(c);
172             dst++;
173         case 0:
174             break;
175         }
176         pdstLine += dstWidth;
177         psrcLine += srcWidth;
178     }
179 }
180
181 #endif