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_XWIN_CONFIG_H
48 #include <xwin-config.h>
52 #include "scrnintstr.h"
53 #include "pixmapstr.h"
54 #include "miscstruct.h"
55 #include "../mfb/maskbits.h"
60 /* winPushPixels -- squeegees the fill style of pGC through pBitMap
61 * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
62 * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
63 * is set in the bitmap, the fill style is put onto the drawable using
64 * the GC's logical function. The drawable is not changed where the bitmap
65 * has a zero bit or outside the area covered by the stencil.
68 this code works if the 1-bit deep pixmap format returned by GetSpans
69 is the same as the format defined by the mfb code (i.e. 32-bit padding
70 per scanline, scanline unit = 32 bits; later, this might mean
71 bitsizeof(int) padding and sacnline unit == bitsizeof(int).)
76 * in order to have both (MSB_FIRST and LSB_FIRST) versions of this
77 * in the server, we need to rename one of them
80 winPushPixels (GCPtr pGC
, PixmapPtr pBitMap
, DrawablePtr pDrawable
,
81 int dx
, int dy
, int xOrg
, int yOrg
)
83 int h
, dxDivPPW
, ibEnd
;
85 register MiBits
*pw
, *pwEnd
;
88 register int ipt
; /* index into above arrays */
90 DDXPointRec pt
[NPT
], ptThisLine
;
95 startmask
= (MiBits
)(-1) ^
96 LONG2CHARSDIFFORDER((MiBits
)(-1) >> 1);
98 pwLineStart
= (MiBits
*)xalloc(BitmapBytePad(dx
));
104 for(h
= 0, ptThisLine
.x
= 0, ptThisLine
.y
= 0;
109 (*pBitMap
->drawable
.pScreen
->GetSpans
)((DrawablePtr
)pBitMap
, dx
,
110 &ptThisLine
, &dx
, 1, (char *)pwLineStart
);
113 /* Process all words which are fully in the pixmap */
116 pwEnd
= pwLineStart
+ dxDivPPW
;
123 msk
= (MiBits
)(-1) ^ SCRRIGHT((MiBits
)(-1), 1);
125 for(ib
= 0; ib
< PPW
; ib
++)
131 pt
[ipt
].x
= ((pw
- pwLineStart
) << PWSH
) + ib
+ xOrg
;
132 pt
[ipt
].y
= h
+ yOrg
;
141 width
[ipt
] = ((pw
- pwLineStart
) << PWSH
) +
142 ib
+ xOrg
- pt
[ipt
].x
;
145 (*pGC
->ops
->FillSpans
)(pDrawable
, pGC
,
146 NPT
, pt
, width
, TRUE
);
154 /* This is not quite right, but it'll do for now */
155 msk
= LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk
) >> 1);
157 msk
= SCRRIGHT(msk
, 1);
165 /* Process final partial word on line */
170 msk
= (MiBits
)(-1) ^ SCRRIGHT((MiBits
)(-1), 1);
172 for(ib
= 0; ib
< ibEnd
; ib
++)
179 pt
[ipt
].x
= ((pw
- pwLineStart
) << PWSH
) + ib
+ xOrg
;
180 pt
[ipt
].y
= h
+ yOrg
;
189 width
[ipt
] = ((pw
- pwLineStart
) << PWSH
) +
190 ib
+ xOrg
- pt
[ipt
].x
;
193 (*pGC
->ops
->FillSpans
)(pDrawable
,
194 pGC
, NPT
, pt
, width
, TRUE
);
201 /* This is not quite right, but it'll do for now */
202 msk
= LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk
) >> 1);
204 msk
= SCRRIGHT(msk
, 1);
208 /* If scanline ended with last bit set, end the box */
211 width
[ipt
] = dx
+ xOrg
- pt
[ipt
].x
;
214 (*pGC
->ops
->FillSpans
)(pDrawable
, pGC
, NPT
, pt
, width
, TRUE
);
220 /* Flush any remaining spans */
223 (*pGC
->ops
->FillSpans
)(pDrawable
, pGC
, ipt
, pt
, width
, TRUE
);