First import
[xorg_rtime.git] / xorg-server-1.4 / mfb / mfbtile.c
blob73015f57d110ea8bf78518508c47edb8465a314e
1 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2 /***********************************************************
4 Copyright 1987, 1998 The Open Group
6 Permission to use, copy, modify, distribute, and sell this software and its
7 documentation for any purpose is hereby granted without fee, provided that
8 the above copyright notice appear in all copies and that both that
9 copyright notice and this permission notice appear in supporting
10 documentation.
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
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 OPEN GROUP 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.
22 Except as contained in this notice, the name of The Open Group 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 Open Group.
27 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29 All Rights Reserved
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.
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.
47 ******************************************************************/
48 #ifdef HAVE_DIX_CONFIG_H
49 #include <dix-config.h>
50 #endif
52 #include <X11/X.h>
54 #include "windowstr.h"
55 #include "regionstr.h"
56 #include "pixmapstr.h"
57 #include "scrnintstr.h"
59 #include "mfb.h"
60 #include "maskbits.h"
62 #include "mergerop.h"
63 /*
65 the boxes are already translated.
67 NOTE:
68 iy = ++iy < tileHeight ? iy : 0
69 is equivalent to iy%= tileheight, and saves a division.
72 /*
73 tile area with a PPW bit wide pixmap
75 void
76 MROP_NAME(mfbTileAreaPPW)(pDraw, nbox, pbox, alu, ptile)
77 DrawablePtr pDraw;
78 int nbox;
79 BoxPtr pbox;
80 int alu;
81 PixmapPtr ptile;
83 register PixelType *psrc;
84 /* pointer to bits in tile, if needed */
85 int tileHeight; /* height of the tile */
86 register PixelType srcpix;
87 int nlwidth; /* width in longwords of the drawable */
88 int w; /* width of current box */
89 MROP_DECLARE_REG ()
90 register int h; /* height of current box */
91 register int nlw; /* loop version of nlwMiddle */
92 register PixelType *p; /* pointer to bits we're writing */
93 PixelType startmask;
94 PixelType endmask; /* masks for reggedy bits at either end of line */
95 int nlwMiddle; /* number of longwords between sides of boxes */
96 int nlwExtra; /* to get from right of box to left of next span */
97 register int iy; /* index of current scanline in tile */
98 PixelType *pbits; /* pointer to start of drawable */
100 mfbGetPixelWidthAndPointer(pDraw, nlwidth, pbits);
102 MROP_INITIALIZE(alu,~0)
104 tileHeight = ptile->drawable.height;
105 psrc = (PixelType *)(ptile->devPrivate.ptr);
107 while (nbox--)
109 w = pbox->x2 - pbox->x1;
110 h = pbox->y2 - pbox->y1;
111 iy = pbox->y1 % tileHeight;
112 p = mfbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
114 if ( ((pbox->x1 & PIM) + w) < PPW)
116 maskpartialbits(pbox->x1, w, startmask);
117 nlwExtra = nlwidth;
118 while (h--)
120 srcpix = psrc[iy];
121 iy++;
122 if (iy == tileHeight)
123 iy = 0;
124 *p = MROP_MASK(srcpix,*p,startmask);
125 mfbScanlineInc(p, nlwExtra);
128 else
130 maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
131 nlwExtra = nlwidth - nlwMiddle;
133 if (startmask && endmask)
135 nlwExtra -= 1;
136 while (h--)
138 srcpix = psrc[iy];
139 iy++;
140 if (iy == tileHeight)
141 iy = 0;
142 nlw = nlwMiddle;
143 *p = MROP_MASK (srcpix,*p,startmask);
144 p++;
145 while (nlw--)
147 *p = MROP_SOLID(srcpix,*p);
148 p++;
151 *p = MROP_MASK(srcpix,*p,endmask);
152 mfbScanlineInc(p, nlwExtra);
155 else if (startmask && !endmask)
157 nlwExtra -= 1;
158 while (h--)
160 srcpix = psrc[iy];
161 iy++;
162 if (iy == tileHeight)
163 iy = 0;
164 nlw = nlwMiddle;
165 *p = MROP_MASK(srcpix,*p,startmask);
166 p++;
167 while (nlw--)
169 *p = MROP_SOLID(srcpix,*p);
170 p++;
172 mfbScanlineInc(p, nlwExtra);
175 else if (!startmask && endmask)
177 while (h--)
179 srcpix = psrc[iy];
180 iy++;
181 if (iy == tileHeight)
182 iy = 0;
183 nlw = nlwMiddle;
184 while (nlw--)
186 *p = MROP_SOLID(srcpix,*p);
187 p++;
190 *p = MROP_MASK(srcpix,*p,endmask);
191 mfbScanlineInc(p, nlwExtra);
194 else /* no ragged bits at either end */
196 while (h--)
198 srcpix = psrc[iy];
199 iy++;
200 if (iy == tileHeight)
201 iy = 0;
202 nlw = nlwMiddle;
203 while (nlw--)
205 *p = MROP_SOLID (srcpix,*p);
206 p++;
208 mfbScanlineInc(p, nlwExtra);
212 pbox++;
216 #if (MROP) == 0
217 void
218 mfbTileAreaPPW (pDraw, nbox, pbox, alu, ptile)
219 DrawablePtr pDraw;
220 int nbox;
221 BoxPtr pbox;
222 int alu;
223 PixmapPtr ptile;
225 void (*f)(
226 DrawablePtr /*pDraw*/,
227 int /*nbox*/,
228 BoxPtr /*pbox*/,
229 int /*alu*/,
230 PixmapPtr /*ptile*/);
232 if (alu == GXcopy)
233 f = mfbTileAreaPPWCopy;
234 else
235 f = mfbTileAreaPPWGeneral;
236 (*f) (pDraw, nbox, pbox, alu, ptile);
238 #endif