]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/mfb/mfbtile.c
Support RDP5 logon packets.
[rdpsrv] / Xserver / programs / Xserver / mfb / mfbtile.c
1 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2 /***********************************************************
3
4 Copyright (c) 1987  X Consortium
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
19 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23 Except as contained in this notice, the name of the X Consortium shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from the X Consortium.
26
27
28 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30                         All Rights Reserved
31
32 Permission to use, copy, modify, and distribute this software and its 
33 documentation for any purpose and without fee is hereby granted, 
34 provided that the above copyright notice appear in all copies and that
35 both that copyright notice and this permission notice appear in 
36 supporting documentation, and that the name of Digital not be
37 used in advertising or publicity pertaining to distribution of the
38 software without specific, written prior permission.  
39
40 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46 SOFTWARE.
47
48 ******************************************************************/
49 /* $XConsortium: mfbtile.c,v 5.8 94/04/17 20:28:36 dpw Exp $ */
50 #include "X.h"
51
52 #include "windowstr.h"
53 #include "regionstr.h"
54 #include "pixmapstr.h"
55 #include "scrnintstr.h"
56
57 #include "mfb.h"
58 #include "maskbits.h"
59
60 #include "mergerop.h"
61 /* 
62
63    the boxes are already translated.
64
65    NOTE:
66    iy = ++iy < tileHeight ? iy : 0
67 is equivalent to iy%= tileheight, and saves a division.
68 */
69
70 /* 
71     tile area with a PPW bit wide pixmap 
72 */
73 void
74 MROP_NAME(mfbTileAreaPPW)(pDraw, nbox, pbox, alu, ptile)
75     DrawablePtr pDraw;
76     int nbox;
77     BoxPtr pbox;
78     int alu;
79     PixmapPtr ptile;
80 {
81     register PixelType *psrc;
82                         /* pointer to bits in tile, if needed */
83     int tileHeight;     /* height of the tile */
84     register PixelType srcpix;  
85     int nlwidth;        /* width in longwords of the drawable */
86     int w;              /* width of current box */
87     MROP_DECLARE_REG ()
88     register int h;     /* height of current box */
89     register int nlw;   /* loop version of nlwMiddle */
90     register PixelType *p;      /* pointer to bits we're writing */
91     PixelType startmask;
92     PixelType endmask;  /* masks for reggedy bits at either end of line */
93     int nlwMiddle;      /* number of longwords between sides of boxes */
94     int nlwExtra;       /* to get from right of box to left of next span */
95     register int iy;    /* index of current scanline in tile */
96     PixelType *pbits;   /* pointer to start of drawable */
97
98     mfbGetPixelWidthAndPointer(pDraw, nlwidth, pbits);
99
100     MROP_INITIALIZE(alu,~0)
101
102     tileHeight = ptile->drawable.height;
103     psrc = (PixelType *)(ptile->devPrivate.ptr);
104
105     while (nbox--)
106     {
107         w = pbox->x2 - pbox->x1;
108         h = pbox->y2 - pbox->y1;
109         iy = pbox->y1 % tileHeight;
110         p = mfbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
111
112         if ( ((pbox->x1 & PIM) + w) < PPW)
113         {
114             maskpartialbits(pbox->x1, w, startmask);
115             nlwExtra = nlwidth;
116             while (h--)
117             {
118                 srcpix = psrc[iy];
119                 iy++;
120                 if (iy == tileHeight)
121                     iy = 0;
122                 *p = MROP_MASK(srcpix,*p,startmask);
123                 mfbScanlineInc(p, nlwExtra);
124             }
125         }
126         else
127         {
128             maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
129             nlwExtra = nlwidth - nlwMiddle;
130
131             if (startmask && endmask)
132             {
133                 nlwExtra -= 1;
134                 while (h--)
135                 {
136                     srcpix = psrc[iy];
137                     iy++;
138                     if (iy == tileHeight)
139                         iy = 0;
140                     nlw = nlwMiddle;
141                     *p = MROP_MASK (srcpix,*p,startmask);
142                     p++;
143                     while (nlw--)
144                     {
145                         *p = MROP_SOLID(srcpix,*p);
146                         p++;
147                     }
148
149                     *p = MROP_MASK(srcpix,*p,endmask);
150                     mfbScanlineInc(p, nlwExtra);
151                 }
152             }
153             else if (startmask && !endmask)
154             {
155                 nlwExtra -= 1;
156                 while (h--)
157                 {
158                     srcpix = psrc[iy];
159                     iy++;
160                     if (iy == tileHeight)
161                         iy = 0;
162                     nlw = nlwMiddle;
163                     *p = MROP_MASK(srcpix,*p,startmask);
164                     p++;
165                     while (nlw--)
166                     {
167                         *p = MROP_SOLID(srcpix,*p);
168                         p++;
169                     }
170                     mfbScanlineInc(p, nlwExtra);
171                 }
172             }
173             else if (!startmask && endmask)
174             {
175                 while (h--)
176                 {
177                     srcpix = psrc[iy];
178                     iy++;
179                     if (iy == tileHeight)
180                         iy = 0;
181                     nlw = nlwMiddle;
182                     while (nlw--)
183                     {
184                         *p = MROP_SOLID(srcpix,*p);
185                         p++;
186                     }
187
188                     *p = MROP_MASK(srcpix,*p,endmask);
189                     mfbScanlineInc(p, nlwExtra);
190                 }
191             }
192             else /* no ragged bits at either end */
193             {
194                 while (h--)
195                 {
196                     srcpix = psrc[iy];
197                     iy++;
198                     if (iy == tileHeight)
199                         iy = 0;
200                     nlw = nlwMiddle;
201                     while (nlw--)
202                     {
203                         *p = MROP_SOLID (srcpix,*p);
204                         p++;
205                     }
206                     mfbScanlineInc(p, nlwExtra);
207                 }
208             }
209         }
210         pbox++;
211     }
212 }
213
214 #if (MROP) == 0
215 void
216 mfbTileAreaPPW (pDraw, nbox, pbox, alu, ptile)
217     DrawablePtr pDraw;
218     int nbox;
219     BoxPtr pbox;
220     int alu;
221     PixmapPtr ptile;
222 {
223     void    (*f)(), mfbTileAreaPPWCopy(), mfbTileAreaPPWGeneral();
224     
225     if (alu == GXcopy)
226         f = mfbTileAreaPPWCopy;
227     else
228         f = mfbTileAreaPPWGeneral;
229     (*f) (pDraw, nbox, pbox, alu, ptile);
230 }
231 #endif