1 /* $XConsortium: cfbpntwin.c,v 5.18 94/04/17 20:28:57 dpw Exp $ */
2 /* $XFree86: xc/programs/Xserver/cfb/cfbpntwin.c,v 3.0 1996/06/29 09:05:45 dawes Exp $ */
3 /***********************************************************
5 Copyright (c) 1987 X Consortium
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 Except as contained in this notice, the name of the X Consortium shall not be
25 used in advertising or otherwise to promote the sale, use or other dealings
26 in this Software without prior written authorization from the X Consortium.
29 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
33 Permission to use, copy, modify, and distribute this software and its
34 documentation for any purpose and without fee is hereby granted,
35 provided that the above copyright notice appear in all copies and that
36 both that copyright notice and this permission notice appear in
37 supporting documentation, and that the name of Digital not be
38 used in advertising or publicity pertaining to distribution of the
39 software without specific, written prior permission.
41 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
42 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
43 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
44 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
45 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
46 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
49 ******************************************************************/
53 #include "windowstr.h"
54 #include "regionstr.h"
55 #include "pixmapstr.h"
56 #include "scrnintstr.h"
59 #include "cfbmskbits.h"
63 cfbPaintWindow(pWin, pRegion, what)
68 register cfbPrivWin *pPrivWin;
71 pPrivWin = cfbGetWindowPrivate(pWin);
75 switch (pWin->backgroundState) {
81 } while (pWin->backgroundState == ParentRelative);
82 (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
85 case BackgroundPixmap:
86 if (pPrivWin->fastBackground)
88 cfbFillBoxTile32 ((DrawablePtr)pWin,
89 (int)REGION_NUM_RECTS(pRegion),
90 REGION_RECTS(pRegion),
91 pPrivWin->pRotatedBackground);
95 cfbFillBoxTileOdd ((DrawablePtr)pWin,
96 (int)REGION_NUM_RECTS(pRegion),
97 REGION_RECTS(pRegion),
98 pWin->background.pixmap,
99 (int) pWin->drawable.x, (int) pWin->drawable.y);
102 case BackgroundPixel:
103 cfbFillBoxSolid ((DrawablePtr)pWin,
104 (int)REGION_NUM_RECTS(pRegion),
105 REGION_RECTS(pRegion),
106 pWin->background.pixel);
111 if (pWin->borderIsPixel)
113 cfbFillBoxSolid ((DrawablePtr)pWin,
114 (int)REGION_NUM_RECTS(pRegion),
115 REGION_RECTS(pRegion),
118 else if (pPrivWin->fastBorder)
120 cfbFillBoxTile32 ((DrawablePtr)pWin,
121 (int)REGION_NUM_RECTS(pRegion),
122 REGION_RECTS(pRegion),
123 pPrivWin->pRotatedBorder);
128 pBgWin->backgroundState == ParentRelative;
129 pBgWin = pBgWin->parent);
131 cfbFillBoxTileOdd ((DrawablePtr)pWin,
132 (int)REGION_NUM_RECTS(pRegion),
133 REGION_RECTS(pRegion),
135 (int) pBgWin->drawable.x,
136 (int) pBgWin->drawable.y);
143 * Use the RROP macros in copy mode
150 # define Expand(left,right,leftAdjust) {\
151 int part = nmiddle & RROP_UNROLL_MASK; \
153 widthStep = widthDst - nmiddle - leftAdjust; \
154 nmiddle >>= RROP_UNROLL_SHIFT; \
159 RROP_UNROLL_CASE(pdst) \
163 pdst += RROP_UNROLL; \
164 RROP_UNROLL_LOOP(pdst) \
173 # define Expand(left, right, leftAdjust) { \
175 widthStep = widthDst - nmiddle - leftAdjust; \
190 cfbFillBoxSolid (pDrawable, nBox, pBox, pixel)
191 DrawablePtr pDrawable;
196 unsigned long *pdstBase;
199 register unsigned long rrop_xor;
200 register unsigned long *pdst;
201 register unsigned long leftMask, rightMask;
206 int leftIndex, rightIndex;
207 unsigned long piQxelArray[3], xOffset, *pdstULC; /*upper left corner*/
209 piQxelArray[0] = (pixel&0xFFFFFF) | ((pixel&0xFF)<<24);
210 piQxelArray[1] = ((pixel&0xFFFF00)>>8) | ((pixel&0xFFFF)<<16);
211 piQxelArray[2] = ((pixel&0xFFFFFF)<<8) | ((pixel&0xFF0000)>>16);
214 cfbGetLongWidthAndPointer(pDrawable, widthDst, pdstBase);
216 rrop_xor = PFILL(pixel);
217 for (; nBox; nBox--, pBox++)
219 pdst = pdstBase + pBox->y1 * widthDst;
220 h = pBox->y2 - pBox->y1;
221 w = pBox->x2 - pBox->x1;
225 register char *pdstb = ((char *) pdst) + pBox->x1;
226 int incr = widthDst * PGSZB;
238 /* _Box has x1, y1, x2, y2*/
239 leftIndex = pBox->x1 & 3;
240 rightIndex = ((leftIndex+w)<5)?0:(pBox->x2 &3);
241 nmiddle = w - rightIndex;
243 nmiddle -= (4 - leftIndex);
249 pdst = pdstBase + pBox->y1 * widthDst + ((pBox->x1*3) >> 2);
256 *pdst++ = piQxelArray[0];
257 *pdst++ = piQxelArray[1];
258 *pdst = piQxelArray[2];
265 *pdst++ = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
266 *pdst++ = piQxelArray[1];
267 *pdst = piQxelArray[2];
274 *pdst++ = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
275 *pdst-- = piQxelArray[2];
281 *pdst = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
291 *pdst++ = piQxelArray[0];
292 *pdst++ = piQxelArray[1];
293 *pdst-- = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
300 *pdst++ = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
301 *pdst++ = piQxelArray[1];
302 *pdst-- = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
309 *pdst++ = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
310 *pdst-- = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
319 *pdst++ = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
322 *pdst++ = piQxelArray[0];
324 *pdst-- = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
328 case 1: /*only if leftIndex = 0 and w = 1*/
330 *pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
340 /* maskbits (pBox->x1, w, leftMask, rightMask, nmiddle);*/
348 *pdst++ = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
349 *pdst++ = piQxelArray[1];
350 *pdst++ = piQxelArray[2];
353 *pdst++ = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
354 *pdst++ = piQxelArray[2];
357 *pdst++ = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
361 *pdst++ = piQxelArray[0];
362 *pdst++ = piQxelArray[1];
363 *pdst++ = piQxelArray[2];
369 *pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
372 *pdst++ = piQxelArray[0];
373 *pdst = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
376 *pdst++ = piQxelArray[0];
377 *pdst++ = piQxelArray[1];
378 *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
387 pdst += (pBox->x1 >> PWSH);
388 if ((pBox->x1 & PIM) + w <= PPW)
390 maskpartialbits(pBox->x1, w, leftMask);
392 *pdst = (*pdst & ~leftMask) | (rrop_xor & leftMask);
398 maskbits (pBox->x1, w, leftMask, rightMask, nmiddle);
403 Expand (RROP_SOLID_MASK (pdst, leftMask); pdst++; ,
404 RROP_SOLID_MASK (pdst, rightMask); ,
409 Expand (RROP_SOLID_MASK (pdst, leftMask); pdst++;,
419 RROP_SOLID_MASK (pdst, rightMask);,
438 cfbFillBoxTile32 (pDrawable, nBox, pBox, tile)
439 DrawablePtr pDrawable;
440 int nBox; /* number of boxes to fill */
441 BoxPtr pBox; /* pointer to list of boxes to fill */
442 PixmapPtr tile; /* rotated, expanded tile */
444 register unsigned long rrop_xor;
445 register unsigned long *pdst;
453 register unsigned long leftMask;
454 register unsigned long rightMask;
459 unsigned long *pdstBase;
461 int leftIndex, rightIndex;
462 unsigned long piQxelArray[3], xOffset, *pdstULC;
465 tileHeight = tile->drawable.height;
466 psrc = (unsigned long *)tile->devPrivate.ptr;
468 cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase);
473 w = pBox->x2 - pBox->x1;
474 h = pBox->y2 - pBox->y1;
476 leftIndex = pBox->x1 & 3;
477 /* rightIndex = ((leftIndex+w)<5)?0:pBox->x2 &3;*/
478 rightIndex = pBox->x2 &3;
479 nmiddle = w - rightIndex;
481 nmiddle -= (4 - leftIndex);
487 pdst = pdstBase + ((pBox->x1 *3)>> 2) + pBox->y1 * widthDst;
488 srcy = y % tileHeight;
490 #define StepTile piQxelArray[0] = (psrc[srcy] & 0xFFFFFF) | ((psrc[srcy] & 0xFF)<<24); \
491 piQxelArray[1] = (psrc[srcy] & 0xFFFF00) | ((psrc[srcy] & 0xFFFF)<<16); \
492 piQxelArray[2] = ((psrc[srcy] & 0xFF0000)>>16) | \
493 ((psrc[srcy] & 0xFFFFFF)<<8); \
494 /*rrop_xor = psrc[srcy];*/ \
496 if (srcy == tileHeight) \
505 *pdst++ = piQxelArray[0];
506 *pdst++ = piQxelArray[1];
507 *pdst = piQxelArray[2];
515 *pdst++ = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
516 *pdst++ = piQxelArray[1];
517 *pdst = piQxelArray[2];
525 *pdst++ = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
526 *pdst-- = piQxelArray[2];
533 *pdst = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
544 *pdst++ = piQxelArray[0];
545 *pdst++ = piQxelArray[1];
546 *pdst-- = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
554 *pdst++ = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
555 *pdst++ = piQxelArray[1];
556 *pdst-- = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
564 *pdst++ = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
565 *pdst-- = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
575 *pdst++ = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
578 *pdst++ = piQxelArray[0];
580 *pdst-- = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
584 case 1: /*only if leftIndex = 0 and w = 1*/
587 *pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
606 *pdst++ = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
607 *pdst++ = piQxelArray[1];
608 *pdst++ = piQxelArray[2];
611 *pdst++ = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
612 *pdst++ = piQxelArray[2];
615 *pdst++ = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
619 *pdst++ = piQxelArray[0];
620 *pdst++ = piQxelArray[1];
621 *pdst++ = piQxelArray[2];
627 *pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
630 *pdst++ = piQxelArray[0];
631 *pdst = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
634 *pdst++ = piQxelArray[0];
635 *pdst++ = piQxelArray[1];
636 *pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
644 w = pBox->x2 - pBox->x1;
645 h = pBox->y2 - pBox->y1;
647 pdst = pdstBase + (pBox->y1 * widthDst) + (pBox->x1 >> PWSH);
648 srcy = y % tileHeight;
650 #define StepTile rrop_xor = psrc[srcy]; \
652 if (srcy == tileHeight) \
655 if ( ((pBox->x1 & PIM) + w) < PPW)
657 maskpartialbits(pBox->x1, w, leftMask);
658 rightMask = ~leftMask;
662 *pdst = (*pdst & rightMask) | (rrop_xor & leftMask);
668 maskbits(pBox->x1, w, leftMask, rightMask, nmiddle);
675 RROP_SOLID_MASK(pdst, leftMask); pdst++;,
676 RROP_SOLID_MASK(pdst, rightMask);,
682 RROP_SOLID_MASK(pdst, leftMask); pdst++;,
693 RROP_SOLID_MASK(pdst, rightMask);,