2 * Fill 32 bit tiled rectangles. Used by both PolyFillRect and PaintWindow.
3 * no depth dependencies.
8 Copyright (c) 1989 X Consortium
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
24 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 Except as contained in this notice, the name of the X Consortium shall not be
28 used in advertising or otherwise to promote the sale, use or other dealings
29 in this Software without prior written authorization from the X Consortium.
32 /* $XConsortium: cfbtile32.c,v 1.8 94/04/17 20:29:05 dpw Exp $ */
33 /* $XFree86: xc/programs/Xserver/cfb/cfbtile32.c,v 3.0 1996/06/29 09:05:53 dawes Exp $ */
40 #include "pixmapstr.h"
41 #include "scrnintstr.h"
42 #include "windowstr.h"
45 #include "cfbmskbits.h"
54 #define SHARED_IDCACHE
58 #define STORE(p) (*(p) = MROP_PREBUILT_SOLID(srcpix,*(p)))
59 /*#define STORE24(p,index) {\
60 register int idx = ((index) & 3)<< 1; \
61 *(p) = (((MROP_PREBUILT_SOLID(srcpix,*(p))<<cfb24Shift[idx])&cfbmask[idx])| \
62 (*(p)&cfbrmask[idx])); \
65 *(p) = (((MROP_PREBUILT_SOLID(srcpix,*(p))>>cfb24Shift[idx])&cfbmask[idx])| \
66 (*(p)&cfbrmask[idx])); \
69 #define STORE24(p,index) MROP_PREBUILT_SOLID24(srcpix, (p), index)
71 #define STORE_MASK(p,mask) (*(p) = MROP_PREBUILT_MASK(srcpix,*(p),(mask)))
72 #define QSTORE(p) ((*(p) = MROP_PREBUILT_SOLID(((srcpix<<24)|srcpix),*(p))), \
73 (p)++,(*(p) = MROP_PREBUILT_SOLID(((srcpix<<16)|(srcpix>>8)),*(p))), \
74 (p)++,(*(p) = MROP_PREBUILT_SOLID(((srcpix<<8)|(srcpix>>16)),*(p))))
78 /* XXX TJR: I doubt that this optimised case works (because the non-24 bit case
79 was broken), so I've added the #if 0 below. Someone who knows what they're
80 doing can re-enable it if they fix it */
82 #if (MROP == Mcopy) && defined(FAST_CONSTANT_OFFSET_MODE) && defined(SHARED_IDCACHE) && 0
83 # define Expand(left,right) {\
84 int part = nlwMiddle & ((PGSZB*2)-1); \
86 nlwMiddle >>= PWSH + 3; \
88 srcpix = psrc[srcy]; \
89 MROP_PREBUILD(srcpix); \
91 if (srcy == tileHeight) \
97 STORE24(p - 7, xtmp - 7); \
99 STORE24(p - 6, xtmp - 6); \
101 STORE24(p - 5, xtmp - 5); \
103 STORE24(p - 4, xtmp - 4); \
105 STORE24(p - 3, xtmp - 3); \
107 STORE24(p - 2, xtmp - 2); \
109 STORE24(p - 1, xtmp - 1); \
113 STORE24 (p + 0, xtmp + 0); \
114 STORE24 (p + 1, xtmp + 1); \
115 STORE24 (p + 2, xtmp + 2); \
116 STORE24 (p + 3, xtmp + 3); \
117 STORE24 (p + 4, xtmp + 4); \
118 STORE24 (p + 5, xtmp + 5); \
119 STORE24 (p + 6, xtmp + 6); \
120 STORE24 (p + 7, xtmp + 7); \
130 #define Expand(left,right) {\
132 srcpix = psrc[srcy]; \
133 MROP_PREBUILD(srcpix); \
135 if (srcy == tileHeight) \
150 #define STORE(p) (*(p) = MROP_PREBUILT_SOLID(srcpix,*(p)))
152 #if (MROP == Mcopy) && defined(FAST_CONSTANT_OFFSET_MODE) && defined(SHARED_IDCACHE)
153 # define Expand(left,right) {\
154 int part = nlwMiddle & 7; \
157 srcpix = psrc[srcy]; \
158 MROP_PREBUILD(srcpix); \
160 if (srcy == tileHeight) \
198 #define Expand(left,right) {\
200 srcpix = psrc[srcy]; \
201 MROP_PREBUILD(srcpix); \
203 if (srcy == tileHeight) \
220 MROP_NAME(cfbFillRectTile32) (pDrawable, pGC, nBox, pBox)
221 DrawablePtr pDrawable;
223 int nBox; /* number of boxes to fill */
224 BoxPtr pBox; /* pointer to list of boxes to fill */
226 register unsigned long srcpix;
227 unsigned long *psrc; /* pointer to bits in tile, if needed */
228 int tileHeight; /* height of the tile */
230 int nlwDst; /* width in longwords of the dest pixmap */
231 int w; /* width of current box */
232 register int h; /* height of current box */
233 register unsigned long startmask;
234 register unsigned long endmask; /* masks for reggedy bits at either end of line */
235 int nlwMiddle; /* number of longwords between sides of boxes */
236 int nlwExtra; /* to get from right of box to left of next span */
237 register int nlw; /* loop version of nlwMiddle */
238 register unsigned long *p; /* pointer to bits we're writing */
239 int y; /* current scan line */
240 int srcy; /* current tile position */
242 unsigned long *pbits;/* pointer to start of pixmap */
243 PixmapPtr tile; /* rotated, expanded tile */
245 MROP_PREBUILT_DECLARE()
250 tile = cfbGetGCPrivate(pGC)->pRotatedPixmap;
251 tileHeight = tile->drawable.height;
252 psrc = (unsigned long *)tile->devPrivate.ptr;
254 MROP_INITIALIZE(pGC->alu, pGC->planemask);
256 cfbGetLongWidthAndPointer (pDrawable, nlwDst, pbits)
260 w = pBox->x2 - pBox->x1;
261 h = pBox->y2 - pBox->y1;
265 p = pbits + (y * nlwDst) + ((pBox->x1*3) >> 2);
266 /* p = pbits + (y * nlwDst) + ((pBox->x1>> 2)*3);*/
268 p = pbits + (y * nlwDst) + (pBox->x1 >> PWSH);
270 srcy = y % tileHeight;
273 if (w == 1 && ((pBox->x1 & 3) == 0 || (pBox->x1 & 3) == 3))
275 if ( ((pBox->x1 & PIM) + w) <= PPW)
278 maskpartialbits(pBox->x1, w, startmask);
283 MROP_PREBUILD(srcpix);
285 if (srcy == tileHeight)
287 *p = MROP_PREBUILT_MASK (srcpix, *p, startmask);
293 maskbits(pBox->x1, w, startmask, endmask, nlwMiddle);
294 nlwExtra = nlwDst - nlwMiddle;
301 Expand(*p = MROP_PREBUILT_MASK(srcpix, *p, startmask); p++;,
302 *p = MROP_PREBUILT_MASK(srcpix, *p, endmask);)
306 Expand(*p = MROP_PREBUILT_MASK(srcpix, *p, startmask); p++;,
315 *p = MROP_PREBUILT_MASK(srcpix, *p, endmask);)
329 MROP_NAME(cfbTile32FS)(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
330 DrawablePtr pDrawable;
332 int nInit; /* number of spans to fill */
333 DDXPointPtr pptInit; /* pointer to list of start points */
334 int *pwidthInit; /* pointer to list of n widths */
337 /* next three parameters are post-clip */
338 int n; /* number of spans to fill */
339 DDXPointPtr ppt; /* pointer to list of start points */
340 int *pwidth;/* pointer to list of n widths */
341 unsigned long *pbits; /* pointer to start of bitmap */
342 int nlwDst; /* width in longwords of bitmap */
343 register unsigned long *p; /* pointer to current longword in bitmap */
344 register int w; /* current span width */
347 register unsigned long startmask;
348 register unsigned long endmask;
349 register unsigned long srcpix;
351 int *pwidthFree;/* copies of the pointers to free */
354 unsigned long *psrc; /* pointer to bits in tile */
355 int tileHeight;/* height of the tile */
357 MROP_PREBUILT_DECLARE()
362 n = nInit * miFindMaxBand( cfbGetCompositeClip(pGC) );
363 pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int));
364 pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
365 if(!pptFree || !pwidthFree)
367 if (pptFree) DEALLOCATE_LOCAL(pptFree);
368 if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
373 n = miClipSpans( cfbGetCompositeClip(pGC),
374 pptInit, pwidthInit, nInit,
375 ppt, pwidth, fSorted);
377 tile = cfbGetGCPrivate(pGC)->pRotatedPixmap;
378 tileHeight = tile->drawable.height;
379 psrc = (unsigned long *)tile->devPrivate.ptr;
381 MROP_INITIALIZE(pGC->alu, pGC->planemask);
383 cfbGetLongWidthAndPointer (pDrawable, nlwDst, pbits)
386 if (!(tileHeight & (tileHeight-1)))
396 /* p = pbits + (y * nlwDst) + ((x*3) >> 2);*/
398 p = pbits + (y * nlwDst) + ((x >> 2)*3);
400 p = pbits + (y * nlwDst) + (x >> PWSH);
402 srcpix = psrc[y & tileHeight];
403 MROP_PREBUILD(srcpix);
408 if ((x & PIM) + w < PPW)
411 maskpartialbits(x, w, startmask);
412 *p = MROP_PREBUILT_MASK (srcpix, *p, startmask);
416 maskbits(x, w, startmask, endmask, nlw);
419 *p = MROP_PREBUILT_MASK(srcpix, *p, startmask);
440 *p = MROP_PREBUILT_MASK(srcpix, *p, endmask);
455 /* p = pbits + (y * nlwDst) + ((x *3)>> 2);*/
456 p = pbits + (y * nlwDst) + ((x >> 2)*3);
459 p = pbits + (y * nlwDst) + (x >> PWSH);
461 srcpix = psrc[y % tileHeight];
462 MROP_PREBUILD(srcpix);
467 if ((x & PIM) + w < PPW)
470 maskpartialbits(x, w, startmask);
471 *p = MROP_PREBUILT_MASK (srcpix, *p, startmask);
475 maskbits(x, w, startmask, endmask, nlw);
478 *p = MROP_PREBUILT_MASK(srcpix, *p, startmask);
499 *p = MROP_PREBUILT_MASK(srcpix, *p, endmask);
504 DEALLOCATE_LOCAL(pptFree);
505 DEALLOCATE_LOCAL(pwidthFree);