1 /***********************************************************
3 Copyright 1987, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
26 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
30 Permission to use, copy, modify, and distribute this software and its
31 documentation for any purpose and without fee is hereby granted,
32 provided that the above copyright notice appear in all copies and that
33 both that copyright notice and this permission notice appear in
34 supporting documentation, and that the name of Digital not be
35 used in advertising or publicity pertaining to distribution of the
36 software without specific, written prior permission.
38 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46 ******************************************************************/
47 #ifdef HAVE_DIX_CONFIG_H
48 #include <dix-config.h>
53 #include "scrnintstr.h"
54 #include "pixmapstr.h"
55 #include "regionstr.h"
56 #include "../mfb/maskbits.h"
61 /* miPushPixels -- squeegees the fill style of pGC through pBitMap
62 * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
63 * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
64 * is set in the bitmap, the fill style is put onto the drawable using
65 * the GC's logical function. The drawable is not changed where the bitmap
66 * has a zero bit or outside the area covered by the stencil.
69 this code works if the 1-bit deep pixmap format returned by GetSpans
70 is the same as the format defined by the mfb code (i.e. 32-bit padding
71 per scanline, scanline unit = 32 bits; later, this might mean
72 bitsizeof(int) padding and sacnline unit == bitsizeof(int).)
77 * in order to have both (MSB_FIRST and LSB_FIRST) versions of this
78 * in the server, we need to rename one of them
81 miPushPixels(pGC
, pBitMap
, pDrawable
, dx
, dy
, xOrg
, yOrg
)
84 DrawablePtr pDrawable
;
85 int dx
, dy
, xOrg
, yOrg
;
87 int h
, dxDivPPW
, ibEnd
;
92 int ipt
; /* index into above arrays */
94 DDXPointRec pt
[NPT
], ptThisLine
;
98 if (screenInfo
.bitmapBitOrder
== IMAGE_BYTE_ORDER
)
99 if (screenInfo
.bitmapBitOrder
== LSBFirst
)
100 startmask
= (MiBits
)(-1) ^
101 LONG2CHARSSAMEORDER((MiBits
)(-1) << 1);
103 startmask
= (MiBits
)(-1) ^
104 LONG2CHARSSAMEORDER((MiBits
)(-1) >> 1);
106 if (screenInfo
.bitmapBitOrder
== LSBFirst
)
107 startmask
= (MiBits
)(-1) ^
108 LONG2CHARSDIFFORDER((MiBits
)(-1) << 1);
110 startmask
= (MiBits
)(-1) ^
111 LONG2CHARSDIFFORDER((MiBits
)(-1) >> 1);
114 pwLineStart
= (MiBits
*)xalloc(BitmapBytePad(dx
));
120 for(h
= 0, ptThisLine
.x
= 0, ptThisLine
.y
= 0;
125 (*pBitMap
->drawable
.pScreen
->GetSpans
)((DrawablePtr
)pBitMap
, dx
,
126 &ptThisLine
, &dx
, 1, (char *)pwLineStart
);
129 /* Process all words which are fully in the pixmap */
132 pwEnd
= pwLineStart
+ dxDivPPW
;
139 msk
= (MiBits
)(-1) ^ SCRRIGHT((MiBits
)(-1), 1);
141 for(ib
= 0; ib
< PPW
; ib
++)
147 pt
[ipt
].x
= ((pw
- pwLineStart
) << PWSH
) + ib
+ xOrg
;
148 pt
[ipt
].y
= h
+ yOrg
;
157 width
[ipt
] = ((pw
- pwLineStart
) << PWSH
) +
158 ib
+ xOrg
- pt
[ipt
].x
;
161 (*pGC
->ops
->FillSpans
)(pDrawable
, pGC
,
162 NPT
, pt
, width
, TRUE
);
170 /* This is not quite right, but it'll do for now */
171 if (screenInfo
.bitmapBitOrder
== IMAGE_BYTE_ORDER
)
172 if (screenInfo
.bitmapBitOrder
== LSBFirst
)
173 msk
= LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk
) << 1);
175 msk
= LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk
) >> 1);
177 if (screenInfo
.bitmapBitOrder
== LSBFirst
)
178 msk
= LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk
) << 1);
180 msk
= LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk
) >> 1);
182 msk
= SCRRIGHT(msk
, 1);
190 /* Process final partial word on line */
195 msk
= (MiBits
)(-1) ^ SCRRIGHT((MiBits
)(-1), 1);
197 for(ib
= 0; ib
< ibEnd
; ib
++)
204 pt
[ipt
].x
= ((pw
- pwLineStart
) << PWSH
) + ib
+ xOrg
;
205 pt
[ipt
].y
= h
+ yOrg
;
214 width
[ipt
] = ((pw
- pwLineStart
) << PWSH
) +
215 ib
+ xOrg
- pt
[ipt
].x
;
218 (*pGC
->ops
->FillSpans
)(pDrawable
,
219 pGC
, NPT
, pt
, width
, TRUE
);
226 /* This is not quite right, but it'll do for now */
227 if (screenInfo
.bitmapBitOrder
== IMAGE_BYTE_ORDER
)
228 if (screenInfo
.bitmapBitOrder
== LSBFirst
)
229 msk
= LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk
) << 1);
231 msk
= LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk
) >> 1);
233 if (screenInfo
.bitmapBitOrder
== LSBFirst
)
234 msk
= LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk
) << 1);
236 msk
= LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk
) >> 1);
238 msk
= SCRRIGHT(msk
, 1);
242 /* If scanline ended with last bit set, end the box */
245 width
[ipt
] = dx
+ xOrg
- pt
[ipt
].x
;
248 (*pGC
->ops
->FillSpans
)(pDrawable
, pGC
, NPT
, pt
, width
, TRUE
);
254 /* Flush any remaining spans */
257 (*pGC
->ops
->FillSpans
)(pDrawable
, pGC
, ipt
, pt
, width
, TRUE
);