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.
25 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29 Permission to use, copy, modify, and distribute this software and its
30 documentation for any purpose and without fee is hereby granted,
31 provided that the above copyright notice appear in all copies and that
32 both that copyright notice and this permission notice appear in
33 supporting documentation, and that the name of Digital not be
34 used in advertising or publicity pertaining to distribution of the
35 software without specific, written prior permission.
37 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45 ******************************************************************/
46 #ifdef HAVE_DIX_CONFIG_H
47 #include <dix-config.h>
52 #include "scrnintstr.h"
53 #include "pixmapstr.h"
54 #include "regionstr.h"
60 /* These were stolen from mfb. They don't really belong here. */
61 #define LONG2CHARSSAMEORDER(x) ((MiBits)(x))
62 #define LONG2CHARSDIFFORDER( x ) ( ( ( ( x ) & (MiBits)0x000000FF ) << 0x18 ) \
63 | ( ( ( x ) & (MiBits)0x0000FF00 ) << 0x08 ) \
64 | ( ( ( x ) & (MiBits)0x00FF0000 ) >> 0x08 ) \
65 | ( ( ( x ) & (MiBits)0xFF000000 ) >> 0x18 ) )
68 #define PPW (PGSZB<<3) /* assuming 8 bits per byte */
74 /* miPushPixels -- squeegees the fill style of pGC through pBitMap
75 * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
76 * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
77 * is set in the bitmap, the fill style is put onto the drawable using
78 * the GC's logical function. The drawable is not changed where the bitmap
79 * has a zero bit or outside the area covered by the stencil.
82 this code works if the 1-bit deep pixmap format returned by GetSpans
83 is the same as the format defined by the mfb code (i.e. 32-bit padding
84 per scanline, scanline unit = 32 bits; later, this might mean
85 bitsizeof(int) padding and sacnline unit == bitsizeof(int).)
90 * in order to have both (MSB_FIRST and LSB_FIRST) versions of this
91 * in the server, we need to rename one of them
94 miPushPixels(GCPtr pGC
, PixmapPtr pBitMap
, DrawablePtr pDrawable
,
95 int dx
, int dy
, int xOrg
, int yOrg
)
97 int h
, dxDivPPW
, ibEnd
;
102 int ipt
; /* index into above arrays */
104 DDXPointRec pt
[NPT
], ptThisLine
;
110 if (screenInfo
.bitmapBitOrder
== IMAGE_BYTE_ORDER
)
111 if (screenInfo
.bitmapBitOrder
== LSBFirst
)
112 startmask
= (MiBits
) (-1) ^ LONG2CHARSSAMEORDER((MiBits
) (-1) << 1);
114 startmask
= (MiBits
) (-1) ^ LONG2CHARSSAMEORDER((MiBits
) (-1) >> 1);
115 else if (screenInfo
.bitmapBitOrder
== LSBFirst
)
116 startmask
= (MiBits
) (-1) ^ LONG2CHARSDIFFORDER((MiBits
) (-1) << 1);
118 startmask
= (MiBits
) (-1) ^ LONG2CHARSDIFFORDER((MiBits
) (-1) >> 1);
121 pwLineStart
= malloc(BitmapBytePad(dx
));
127 for (h
= 0, ptThisLine
.x
= 0, ptThisLine
.y
= 0; h
< dy
; h
++, ptThisLine
.y
++) {
129 (*pBitMap
->drawable
.pScreen
->GetSpans
) ((DrawablePtr
) pBitMap
, dx
,
131 (char *) pwLineStart
);
134 /* Process all words which are fully in the pixmap */
137 pwEnd
= pwLineStart
+ dxDivPPW
;
143 msk
= (MiBits
) (-1) ^ SCRRIGHT((MiBits
) (-1), 1);
145 for (ib
= 0; ib
< PPW
; ib
++) {
148 pt
[ipt
].x
= ((pw
- pwLineStart
) << PWSH
) + ib
+ xOrg
;
149 pt
[ipt
].y
= h
+ yOrg
;
156 width
[ipt
] = ((pw
- pwLineStart
) << PWSH
) +
157 ib
+ xOrg
- pt
[ipt
].x
;
159 (*pGC
->ops
->FillSpans
) (pDrawable
, pGC
,
160 NPT
, pt
, width
, TRUE
);
168 /* This is not quite right, but it'll do for now */
169 if (screenInfo
.bitmapBitOrder
== IMAGE_BYTE_ORDER
)
170 if (screenInfo
.bitmapBitOrder
== LSBFirst
)
172 LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk
) << 1);
175 LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk
) >> 1);
176 else if (screenInfo
.bitmapBitOrder
== LSBFirst
)
177 msk
= LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk
) << 1);
179 msk
= LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk
) >> 1);
181 msk
= SCRRIGHT(msk
, 1);
188 /* Process final partial word on line */
193 msk
= (MiBits
) (-1) ^ SCRRIGHT((MiBits
) (-1), 1);
195 for (ib
= 0; ib
< ibEnd
; ib
++) {
199 pt
[ipt
].x
= ((pw
- pwLineStart
) << PWSH
) + ib
+ xOrg
;
200 pt
[ipt
].y
= h
+ yOrg
;
207 width
[ipt
] = ((pw
- pwLineStart
) << PWSH
) +
208 ib
+ xOrg
- pt
[ipt
].x
;
210 (*pGC
->ops
->FillSpans
) (pDrawable
,
211 pGC
, NPT
, pt
, width
, TRUE
);
218 /* This is not quite right, but it'll do for now */
219 if (screenInfo
.bitmapBitOrder
== IMAGE_BYTE_ORDER
)
220 if (screenInfo
.bitmapBitOrder
== LSBFirst
)
222 LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk
) << 1);
225 LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk
) >> 1);
226 else if (screenInfo
.bitmapBitOrder
== LSBFirst
)
227 msk
= LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk
) << 1);
229 msk
= LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk
) >> 1);
231 msk
= SCRRIGHT(msk
, 1);
235 /* If scanline ended with last bit set, end the box */
237 width
[ipt
] = dx
+ xOrg
- pt
[ipt
].x
;
239 (*pGC
->ops
->FillSpans
) (pDrawable
, pGC
, NPT
, pt
, width
, TRUE
);
245 /* Flush any remaining spans */
247 (*pGC
->ops
->FillSpans
) (pDrawable
, pGC
, ipt
, pt
, width
, TRUE
);