]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/mfb/mfbbres.c
Support RDP5 logon packets.
[rdpsrv] / Xserver / programs / Xserver / mfb / mfbbres.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: mfbbres.c,v 1.22 94/04/17 20:28:17 dpw Exp $ */
50 #include "X.h"
51 #include "misc.h"
52 #include "mfb.h"
53 #include "maskbits.h"
54 #include "miline.h"
55
56 /* Solid bresenham line */
57 /* NOTES
58    e2 is used less often than e1, so it's not in a register
59 */
60
61 void
62 mfbBresS(rop, addrlbase, nlwidth, signdx, signdy, axis, x1, y1, e, e1, e2, len)
63 int rop;                /* a reduced rasterop */
64 PixelType *addrlbase;   /* pointer to base of bitmap */
65 int nlwidth;            /* width in longwords of bitmap */
66 int signdx, signdy;     /* signs of directions */
67 int axis;               /* major axis (Y_AXIS or X_AXIS) */
68 int x1, y1;             /* initial point */
69 register int e;         /* error accumulator */
70 register int e1;        /* bresenham increments */
71 int e2;
72 int len;                /* length of line */
73 {
74     register int yinc;  /* increment to next scanline, in bytes */
75     register PixelType *addrl;  /* bitmask long pointer */
76     register PixelType bit;     /* current bit being set/cleared/etc.  */
77     PixelType leftbit = mask[0]; /* leftmost bit to process in new word */
78     PixelType rightbit = mask[PPW-1]; /* rightmost bit to process in new word */
79
80     register int e3 = e2-e1;
81     PixelType   tmp;
82
83     /* point to longword containing first point */
84     addrl = mfbScanline(addrlbase, x1, y1, nlwidth);
85     yinc = signdy * nlwidth;
86     e = e-e1;                   /* to make looping easier */
87     bit = mask[x1 & PIM];
88
89     if (!len)
90         return;
91     if (rop == RROP_BLACK)
92     {
93         if (axis == X_AXIS)
94         {
95             if (signdx > 0)
96             {
97                 tmp = *addrl;
98                 for (;;)
99                 { 
100                     tmp &= ~bit;
101                     if (!--len)
102                         break;
103                     bit = SCRRIGHT(bit,1);
104                     e += e1;
105                     if (e >= 0)
106                     {
107                         *addrl = tmp;
108                         mfbScanlineInc(addrl, yinc);
109                         e += e3;
110                         if (!bit)
111                         {
112                             bit = leftbit;
113                             addrl ++;
114                         }
115                         tmp = *addrl;
116                     }
117                     else if (!bit)
118                     {
119                         *addrl = tmp;
120                         bit = leftbit;
121                         addrl ++;
122                         tmp = *addrl;
123                     }
124                 }
125                 *addrl = tmp;
126             }
127             else
128             {
129                 tmp = *addrl;
130                 for (;;)
131                 { 
132                     tmp &= ~bit;
133                     if (!--len)
134                         break;
135                     e += e1;
136                     bit = SCRLEFT(bit,1);
137                     if (e >= 0)
138                     {
139                         *addrl = tmp;
140                         mfbScanlineInc(addrl, yinc);
141                         e += e3;
142                         if (!bit)
143                         {
144                             bit = rightbit;
145                             addrl --;
146                         }
147                         tmp = *addrl;
148                     }
149                     else if (!bit)
150                     {
151                         *addrl = tmp;
152                         bit = rightbit;
153                         addrl --;
154                         tmp = *addrl;
155                     }
156                 }
157                 *addrl = tmp;
158             }
159         } /* if X_AXIS */
160         else
161         {
162             if (signdx > 0)
163             {
164                 while(len--)
165                 {
166                     *addrl &= ~bit;
167                     e += e1;
168                     if (e >= 0)
169                     {
170                         bit = SCRRIGHT(bit,1);
171                         if (!bit) { bit = leftbit;addrl ++; }
172                         e += e3;
173                     }
174                     mfbScanlineInc(addrl, yinc);
175                 }
176             }
177             else
178             {
179                 while(len--)
180                 {
181                     *addrl &= ~bit;
182                     e += e1;
183                     if (e >= 0)
184                     {
185                         bit = SCRLEFT(bit,1);
186                         if (!bit) { bit = rightbit;addrl --; }
187                         e += e3;
188                     }
189                     mfbScanlineInc(addrl, yinc);
190                 }
191             }
192         } /* else Y_AXIS */
193     } 
194     else if (rop == RROP_WHITE)
195     {
196         if (axis == X_AXIS)
197         {
198             if (signdx > 0)
199             {
200                 tmp = *addrl;
201                 for (;;)
202                 {
203                     tmp |= bit;
204                     if (!--len)
205                         break;
206                     e += e1;
207                     bit = SCRRIGHT(bit,1);
208                     if (e >= 0)
209                     {
210                         *addrl = tmp;
211                         mfbScanlineInc(addrl, yinc);
212                         e += e3;
213                         if (!bit)
214                         {
215                             bit = leftbit;
216                             addrl ++;
217                         }
218                         tmp = *addrl;
219                     }
220                     else if (!bit)
221                     {
222                         *addrl = tmp;
223                         bit = leftbit;
224                         addrl ++;
225                         tmp = *addrl;
226                     }
227                 }
228                 *addrl = tmp;
229             }
230             else
231             {
232                 tmp = *addrl;
233                 for (;;)
234                 {
235                     tmp |= bit;
236                     if (!--len)
237                         break;
238                     e += e1;
239                     bit = SCRLEFT(bit,1);
240                     if (e >= 0)
241                     {
242                         *addrl = tmp;
243                         mfbScanlineInc(addrl, yinc);
244                         e += e3;
245                         if (!bit)
246                         {
247                             bit = rightbit;
248                             addrl --;
249                         }
250                         tmp = *addrl;
251                     }
252                     else if (!bit)
253                     {
254                         *addrl = tmp;
255                         bit = rightbit;
256                         addrl --;
257                         tmp = *addrl;
258                     }
259                 }
260                 *addrl = tmp;
261             }
262         } /* if X_AXIS */
263         else
264         {
265             if (signdx > 0)
266             {
267                 while(len--)
268                 {
269                     *addrl |= bit;
270                     e += e1;
271                     if (e >= 0)
272                     {
273                         bit = SCRRIGHT(bit,1);
274                         if (!bit) { bit = leftbit;addrl ++; }
275                         e += e3;
276                     }
277                     mfbScanlineInc(addrl, yinc);
278                 }
279             }
280             else
281             {
282                 while(len--)
283                 {
284                     *addrl |= bit;
285                     e += e1;
286                     if (e >= 0)
287                     {
288                         bit = SCRLEFT(bit,1);
289                         if (!bit) { bit = rightbit;addrl --; }
290                         e += e3;
291                     }
292                     mfbScanlineInc(addrl, yinc);
293                 }
294             }
295         } /* else Y_AXIS */
296     }
297     else if (rop == RROP_INVERT)
298     {
299         if (axis == X_AXIS)
300         {
301             if (signdx > 0)
302             {
303                 while(len--)
304                 {
305                     *addrl ^= bit;
306                     e += e1;
307                     if (e >= 0)
308                     {
309                         mfbScanlineInc(addrl, yinc);
310                         e += e3;
311                     }
312                     bit = SCRRIGHT(bit,1);
313                     if (!bit) { bit = leftbit;addrl ++; }
314                 }
315             }
316             else
317             {
318                 while(len--)
319                 {
320                     *addrl ^= bit;
321                     e += e1;
322                     if (e >= 0)
323                     {
324                         mfbScanlineInc(addrl, yinc);
325                         e += e3;
326                     }
327                     bit = SCRLEFT(bit,1);
328                     if (!bit) { bit = rightbit;addrl --; }
329                 }
330             }
331         } /* if X_AXIS */
332         else
333         {
334             if (signdx > 0)
335             {
336                 while(len--)
337                 {
338                     *addrl ^= bit;
339                     e += e1;
340                     if (e >= 0)
341                     {
342                         bit = SCRRIGHT(bit,1);
343                         if (!bit) { bit = leftbit;addrl ++; }
344                         e += e3;
345                     }
346                     mfbScanlineInc(addrl, yinc);
347                 }
348             }
349             else
350             {
351                 while(len--)
352                 {
353                     *addrl ^= bit;
354                     e += e1;
355                     if (e >= 0)
356                     {
357                         bit = SCRLEFT(bit,1);
358                         if (!bit) { bit = rightbit; addrl --; }
359                         e += e3;
360                     }
361                     mfbScanlineInc(addrl, yinc);
362                 }
363             }
364         } /* else Y_AXIS */
365     }
366