]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/mi/mipushpxl.c
Support RDP5 logon packets.
[rdpsrv] / Xserver / programs / Xserver / mi / mipushpxl.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: mipushpxl.c,v 5.5 94/04/17 20:27:47 dpw Exp $ */
49 /* $XFree86: xc/programs/Xserver/mi/mipushpxl.c,v 3.1 1996/12/09 12:02:49 dawes Exp $ */
50 #include "X.h"
51 #include "gcstruct.h"
52 #include "scrnintstr.h"
53 #include "pixmapstr.h"
54 #include "miscstruct.h"
55 #include "../mfb/maskbits.h"
56
57 #define NPT 128
58
59 /* miPushPixels -- squeegees the fill style of pGC through pBitMap
60  * into pDrawable.  pBitMap is a stencil (dx by dy of it is used, it may
61  * be bigger) which is placed on the drawable at xOrg, yOrg.  Where a 1 bit
62  * is set in the bitmap, the fill style is put onto the drawable using
63  * the GC's logical function. The drawable is not changed where the bitmap
64  * has a zero bit or outside the area covered by the stencil.
65
66 WARNING:
67     this code works if the 1-bit deep pixmap format returned by GetSpans
68 is the same as the format defined by the mfb code (i.e. 32-bit padding
69 per scanline, scanline unit = 32 bits; later, this might mean
70 bitsizeof(int) padding and sacnline unit == bitsizeof(int).)
71
72  */
73 void
74 miPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
75     GCPtr       pGC;
76     PixmapPtr   pBitMap;
77     DrawablePtr pDrawable;
78     int         dx, dy, xOrg, yOrg;
79 {
80     int         h, dxDivPPW, ibEnd;
81     unsigned long *pwLineStart;
82     register unsigned long      *pw, *pwEnd;
83     register unsigned long msk;
84     register int ib, w;
85     register int ipt;           /* index into above arrays */
86     Bool        fInBox;
87     DDXPointRec pt[NPT], ptThisLine;
88     int         width[NPT];
89
90     pwLineStart = (unsigned long *)xalloc(BitmapBytePad(dx));
91     if (!pwLineStart)
92         return;
93     ipt = 0;
94     dxDivPPW = dx/PPW;
95
96     for(h = 0, ptThisLine.x = 0, ptThisLine.y = 0; 
97         h < dy; 
98         h++, ptThisLine.y++)
99     {
100
101         (*pBitMap->drawable.pScreen->GetSpans)((DrawablePtr)pBitMap, dx,
102                         &ptThisLine, &dx, 1, (char *)pwLineStart);
103
104         pw = pwLineStart;
105         /* Process all words which are fully in the pixmap */
106         
107         fInBox = FALSE;
108         pwEnd = pwLineStart + dxDivPPW;
109         while(pw  < pwEnd)
110         {
111             w = *pw;
112             msk = endtab[1];
113             for(ib = 0; ib < PPW; ib++)
114             {
115                 if(w & msk)
116                 {
117                     if(!fInBox)
118                     {
119                         pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
120                         pt[ipt].y = h + yOrg;
121                         /* start new box */
122                         fInBox = TRUE;
123                     }
124                 }
125                 else
126                 {
127                     if(fInBox)
128                     {
129                         width[ipt] = ((pw - pwLineStart) << PWSH) + 
130                                      ib + xOrg - pt[ipt].x;
131                         if (++ipt >= NPT)
132                         {
133                             (*pGC->ops->FillSpans)(pDrawable, pGC, 
134                                               NPT, pt, width, TRUE);
135                             ipt = 0;
136                         }
137                         /* end box */
138                         fInBox = FALSE;
139                     }
140                 }
141                 msk = SCRRIGHT(msk, 1);
142             }
143             pw++;
144         }
145         ibEnd = dx & PIM;
146         if(ibEnd)
147         {
148             /* Process final partial word on line */
149             w = *pw;
150             msk = endtab[1];
151             for(ib = 0; ib < ibEnd; ib++)
152             {
153                 if(w & msk)
154                 {
155                     if(!fInBox)
156                     {
157                         /* start new box */
158                         pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
159                         pt[ipt].y = h + yOrg;
160                         fInBox = TRUE;
161                     }
162                 }
163                 else
164                 {
165                     if(fInBox)
166                     {
167                         /* end box */
168                         width[ipt] = ((pw - pwLineStart) << PWSH) + 
169                                      ib + xOrg - pt[ipt].x;
170                         if (++ipt >= NPT)
171                         {
172                             (*pGC->ops->FillSpans)(pDrawable, 
173                                               pGC, NPT, pt, width, TRUE);
174                             ipt = 0;
175                         }
176                         fInBox = FALSE;
177                     }
178                 }
179                 msk = SCRRIGHT(msk, 1);
180             }
181         }
182         /* If scanline ended with last bit set, end the box */
183         if(fInBox)
184         {
185             width[ipt] = dx + xOrg - pt[ipt].x;
186             if (++ipt >= NPT)
187             {
188                 (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt, width, TRUE);
189                 ipt = 0;
190             }
191         }
192     }
193     xfree(pwLineStart);
194     /* Flush any remaining spans */
195     if (ipt)
196     {
197         (*pGC->ops->FillSpans)(pDrawable, pGC, ipt, pt, width, TRUE);
198     }
199 }