]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/mfb/mfbbresd.c
Support RDP5 logon packets.
[rdpsrv] / Xserver / programs / Xserver / mfb / mfbbresd.c
1 /***********************************************************
2
3 Copyright (c) 1987  X Consortium
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
18 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 Except as contained in this notice, the name of the X Consortium shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from the X Consortium.
25
26
27 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28
29                         All Rights Reserved
30
31 Permission to use, copy, modify, and distribute this software and its 
32 documentation for any purpose and without fee is hereby granted, 
33 provided that the above copyright notice appear in all copies and that
34 both that copyright notice and this permission notice appear in 
35 supporting documentation, and that the name of Digital not be
36 used in advertising or publicity pertaining to distribution of the
37 software without specific, written prior permission.  
38
39 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45 SOFTWARE.
46
47 ******************************************************************/
48 /* $XConsortium: mfbbresd.c,v 1.10 94/04/17 20:28:18 dpw Exp $ */
49 #include "X.h"
50 #include "misc.h"
51 #include "mfb.h"
52 #include "maskbits.h"
53 #include "miline.h"
54
55 /* Dashed bresenham line */
56
57 #define StepDash\
58     if (!--dashRemaining) { \
59         if (++ dashIndex == numInDashList) \
60             dashIndex = 0; \
61         dashRemaining = pDash[dashIndex]; \
62         rop = fgrop; \
63         if (dashIndex & 1) \
64             rop = bgrop; \
65     }
66
67 void
68 mfbBresD(fgrop, bgrop,
69          pdashIndex, pDash, numInDashList, pdashOffset, isDoubleDash,
70          addrlbase, nlwidth,
71          signdx, signdy, axis, x1, y1, e, e1, e2, len)
72 int fgrop, bgrop;
73 int *pdashIndex;        /* current dash */
74 unsigned char *pDash;   /* dash list */
75 int numInDashList;      /* total length of dash list */
76 int *pdashOffset;       /* offset into current dash */
77 int isDoubleDash;
78 PixelType *addrlbase;   /* pointer to base of bitmap */
79 int nlwidth;            /* width in longwords of bitmap */
80 int signdx, signdy;     /* signs of directions */
81 int axis;               /* major axis (Y_AXIS or X_AXIS) */
82 int x1, y1;             /* initial point */
83 register int e;         /* error accumulator */
84 register int e1;        /* bresenham increments */
85 int e2;
86 int len;                /* length of line */
87 {
88     register int yinc;  /* increment to next scanline, in bytes */
89     register PixelType *addrl;
90     register int e3 = e2-e1;
91     register unsigned long bit;
92     PixelType leftbit = mask[0]; /* leftmost bit to process in new word */
93     PixelType rightbit = mask[PPW-1]; /* rightmost bit to process in new word */
94     int dashIndex;
95     int dashOffset;
96     int dashRemaining;
97     int rop;
98
99     dashOffset = *pdashOffset;
100     dashIndex = *pdashIndex;
101     dashRemaining = pDash[dashIndex] - dashOffset;
102     rop = fgrop;
103     if (!isDoubleDash)
104         bgrop = -1;
105     if (dashIndex & 1)
106         rop = bgrop;
107
108     /* point to longword containing first point */
109     addrl = mfbScanline(addrlbase, x1, y1, nlwidth);
110     yinc = signdy * nlwidth;
111     e = e-e1;                   /* to make looping easier */
112     bit = mask[x1 & PIM];
113     if (axis == X_AXIS)
114     {
115         if (signdx > 0)
116         {
117             while(len--)
118             { 
119                 if (rop == RROP_BLACK)
120                     *addrl &= ~bit;
121                 else if (rop == RROP_WHITE)
122                     *addrl |= bit;
123                 else if (rop == RROP_INVERT)
124                     *addrl ^= bit;
125                 e += e1;
126                 if (e >= 0)
127                 {
128                     mfbScanlineInc(addrl, yinc);
129                     e += e3;
130                 }
131                 bit = SCRRIGHT(bit,1);
132                 if (!bit) { bit = leftbit;addrl ++; }
133                 StepDash
134             }
135         }
136         else
137         {
138             while(len--)
139             { 
140                 if (rop == RROP_BLACK)
141                     *addrl &= ~bit;
142                 else if (rop == RROP_WHITE)
143                     *addrl |= bit;
144                 else if (rop == RROP_INVERT)
145                     *addrl ^= bit;
146                 e += e1;
147                 if (e >= 0)
148                 {
149                     mfbScanlineInc(addrl, yinc);
150                     e += e3;
151                 }
152                 bit = SCRLEFT(bit,1);
153                 if (!bit) { bit = rightbit;addrl --; }
154                 StepDash
155             }
156         }
157     } /* if X_AXIS */
158     else
159     {
160         if (signdx > 0)
161         {
162             while(len--)
163             {
164                 if (rop == RROP_BLACK)
165                     *addrl &= ~bit;
166                 else if (rop == RROP_WHITE)
167                     *addrl |= bit;
168                 else if (rop == RROP_INVERT)
169                     *addrl ^= bit;
170                 e += e1;
171                 if (e >= 0)
172                 {
173                     bit = SCRRIGHT(bit,1);
174                     if (!bit) { bit = leftbit;addrl ++; }
175                     e += e3;
176                 }
177                 mfbScanlineInc(addrl, yinc);
178                 StepDash
179             }
180         }
181         else
182         {
183             while(len--)
184             {
185                 if (rop == RROP_BLACK)
186                     *addrl &= ~bit;
187                 else if (rop == RROP_WHITE)
188                     *addrl |= bit;
189                 else if (rop == RROP_INVERT)
190                     *addrl ^= bit;
191                 e += e1;
192                 if (e >= 0)
193                 {
194                     bit = SCRLEFT(bit,1);
195                     if (!bit) { bit = rightbit;addrl --; }
196                     e += e3;
197                 }
198                 mfbScanlineInc(addrl, yinc);
199                 StepDash
200             }
201         }
202     } /* else Y_AXIS */
203     *pdashIndex = dashIndex;
204     *pdashOffset = pDash[dashIndex] - dashRemaining;
205