]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/mi/mifillrct.c
Import X server from vnc-3.3.7.
[rdpsrv] / Xserver / programs / Xserver / mi / mifillrct.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: mifillrct.c,v 5.1 94/04/17 20:27:34 keith Exp $ */
49
50 #include "X.h"
51 #include "Xprotostr.h"
52 #include "gcstruct.h"
53 #include "windowstr.h"
54 #include "pixmap.h"
55
56 #include "misc.h"
57
58 /* mi rectangles
59    written by newman, with debts to all and sundry
60 */
61
62 /* MIPOLYFILLRECT -- public entry for PolyFillRect request
63  * very straight forward: translate rectangles if necessary
64  * then call FillSpans to fill each rectangle.  We let FillSpans worry about
65  * clipping to the destination
66  */
67 void
68 miPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
69     DrawablePtr pDrawable;
70     GCPtr       pGC;
71     int         nrectFill;      /* number of rectangles to fill */
72     xRectangle  *prectInit;     /* Pointer to first rectangle to fill */
73 {
74     int i;
75     register int        height;
76     register int        width;
77     register xRectangle *prect; 
78     int                 xorg;
79     register int        yorg;
80     int                 maxheight;
81     DDXPointPtr         pptFirst;
82     register DDXPointPtr ppt;
83     int                 *pwFirst;
84     register int        *pw;
85
86     if (pGC->miTranslate)
87     {
88         xorg = pDrawable->x;
89         yorg = pDrawable->y;
90         prect = prectInit;
91         maxheight = 0;
92         for (i = 0; i<nrectFill; i++, prect++)
93         {
94             prect->x += xorg;
95             prect->y += yorg;
96             maxheight = max(maxheight, prect->height);
97         }
98     }
99     else
100     {
101         prect = prectInit;
102         maxheight = 0;
103         for (i = 0; i<nrectFill; i++, prect++)
104             maxheight = max(maxheight, prect->height);
105     }
106
107     pptFirst = (DDXPointPtr) ALLOCATE_LOCAL(maxheight * sizeof(DDXPointRec));
108     pwFirst = (int *) ALLOCATE_LOCAL(maxheight * sizeof(int));
109     if(!pptFirst || !pwFirst)
110     {
111         if (pwFirst) DEALLOCATE_LOCAL(pwFirst);
112         if (pptFirst) DEALLOCATE_LOCAL(pptFirst);
113         return;
114     }
115
116     prect = prectInit;
117     while(nrectFill--)
118     {
119         ppt = pptFirst;
120         pw = pwFirst;
121         height = prect->height;
122         width = prect->width;
123         xorg = prect->x;
124         yorg = prect->y;
125         while(height--)
126         {
127             *pw++ = width;
128             ppt->x = xorg;
129             ppt->y = yorg;
130             ppt++;
131             yorg++;
132         }
133         (* pGC->ops->FillSpans)(pDrawable, pGC, 
134                            prect->height, pptFirst, pwFirst,
135                            1);
136         prect++;
137     }
138     DEALLOCATE_LOCAL(pwFirst);
139     DEALLOCATE_LOCAL(pptFirst);
140 }