1 /***********************************************************
3 Copyright (c) 1987 X Consortium
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:
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 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.
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.
27 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
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
47 ******************************************************************/
48 /* $XConsortium: mfbpushpxl.c,v 5.6 94/04/17 20:28:31 dpw Exp $ */
52 #include "scrnintstr.h"
53 #include "pixmapstr.h"
54 #include "miscstruct.h"
56 #include "regionstr.h"
59 /* mfbSolidPP is courtesy of xhacks@csri.toronto.edu
61 For fillStyle==FillSolid, a monochrome PushPixels can be reduced to
62 a ROP in the following way: (Note that the ROP is the same as the
63 result of ROP(src=0x3,dst=0x5))
68 GXclear 0x0 0000 0100 0100 0
69 GXand 0x1 0001 0100 0101 s&d
70 GXandReverse 0x2 0010 0100 0110 s&~d
71 GXcopy 0x3 0011 0100 0111 s
72 GXandInverted 0x4 0100 0101 0100 ~s&d
73 GXnoop 0x5 0101 0101 0101 d
74 GXxor 0x6 0110 0101 0110 s^d
75 GXor 0x7 0111 0101 0111 s|d
76 GXnor 0x8 1000 0110 0100 ~s&~d
77 GXequiv 0x9 1001 0110 0101 ~s^d
78 GXinvert 0xa 1010 0110 0110 ~d
79 GXorReverse 0xb 1011 0110 0111 s|~d
80 GXcopyInverted 0xc 1100 0111 0100 ~s
81 GXorInverted 0xd 1101 0111 0101 ~s|d
82 GXnand 0xe 1110 0111 0110 ~s|~d
83 GXset 0xf 1111 0111 0111 1
85 For src=0: newRop = 0x4|(rop>>2)
86 For src=1: newRop = 0x4|(rop&3)
89 /* mfbSolidPP -- squeegees the forground color of pGC through pBitMap
90 * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
91 * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
92 * is set in the bitmap, the fill style is put onto the drawable using
93 * the GC's logical function. The drawable is not changed where the bitmap
94 * has a zero bit or outside the area covered by the stencil.
97 mfbSolidPP(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
100 DrawablePtr pDrawable;
101 int dx, dy, xOrg, yOrg;
107 register DDXPointPtr ppt;
108 register BoxPtr pbox;
111 if (!pGC->planemask & 1) return;
113 /* compute the reduced rop function */
115 if (!(pGC->fgPixel&1)) alu >>= 2;
116 alu = (alu & 0x3) | 0x4;
117 if (alu == GXnoop) return;
121 srcBox.x2 = xOrg + dx;
122 srcBox.y2 = yOrg + dy;
123 REGION_INIT(pGC->pScreen, &rgnDst, &srcBox, 1);
125 /* clip the shape of the dst to the destination composite clip */
126 REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst,
127 ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip);
129 if (!REGION_NIL(&rgnDst))
131 i = REGION_NUM_RECTS(&rgnDst);
132 pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec));
135 for (pbox = REGION_RECTS(&rgnDst), ppt = pptSrc;
139 ppt->x = pbox->x1 - xOrg;
140 ppt->y = pbox->y1 - yOrg;
142 mfbDoBitblt((DrawablePtr)pBitMap, pDrawable, alu, &rgnDst, pptSrc);
143 DEALLOCATE_LOCAL(pptSrc);
146 REGION_UNINIT(pGC->pScreen, &rgnDst);
151 /* mfbPushPixels -- squeegees the forground color of pGC through pBitMap
152 * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
153 * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
154 * is set in the bitmap, the fill style is put onto the drawable using
155 * the GC's logical function. The drawable is not changed where the bitmap
156 * has a zero bit or outside the area covered by the stencil.
159 mfbPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
162 DrawablePtr pDrawable;
163 int dx, dy, xOrg, yOrg;
165 int h, dxDivPPW, ibEnd;
166 PixelType *pwLineStart;
167 register PixelType *pw, *pwEnd;
168 register PixelType mask;
170 register PixelType w;
171 register int ipt; /* index into above arrays */
176 /* Now scan convert the pixmap and use the result to call fillspans in
177 * in the drawable with the original GC */
180 for(h = 0; h < dy; h++)
184 (((char *)(pBitMap->devPrivate.ptr))+(h * pBitMap->devKind));
186 /* Process all words which are fully in the pixmap */
189 pwEnd = pwLineStart + dxDivPPW;
194 for(ib = 0; ib < PPW; ib++)
200 pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
201 pt[ipt].y = h + yOrg;
210 width[ipt] = ((pw - pwLineStart) << PWSH) +
211 ib + xOrg - pt[ipt].x;
214 (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt,
222 mask = SCRRIGHT(mask, 1);
229 /* Process final partial word on line */
232 for(ib = 0; ib < ibEnd; ib++)
239 pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
240 pt[ipt].y = h + yOrg;
249 width[ipt] = ((pw - pwLineStart) << PWSH) +
250 ib + xOrg - pt[ipt].x;
253 (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt,
260 mask = SCRRIGHT(mask, 1);
263 /* If scanline ended with last bit set, end the box */
266 width[ipt] = dx + xOrg - pt[ipt].x;
269 (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt, width, TRUE);
274 /* Flush any remaining spans */
277 (*pGC->ops->FillSpans)(pDrawable, pGC, ipt, pt, width, TRUE);