1
/* $XFree86: xc/programs/Xserver/mi/mipushpxl.c,v 3.12 2001/12/14 20:00:26 dawes Exp $ */
2
/***********************************************************
4
Copyright 1987, 1998 The Open Group
6
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
the above copyright notice appear in all copies and that both that
9
copyright notice and this permission notice appear in supporting
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
OPEN GROUP 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 Open Group 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 Open Group.
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
/* $Xorg: mipushpxl.c,v 1.4 2001/02/09 02:05:21 xorgcvs Exp $ */
49
#ifdef HAVE_DIX_CONFIG_H
50
#include <dix-config.h>
55
#include "scrnintstr.h"
56
#include "pixmapstr.h"
57
#include "regionstr.h"
58
#include "../mfb/maskbits.h"
63
/* miPushPixels -- squeegees the fill style of pGC through pBitMap
64
* into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
65
* be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
66
* is set in the bitmap, the fill style is put onto the drawable using
67
* the GC's logical function. The drawable is not changed where the bitmap
68
* has a zero bit or outside the area covered by the stencil.
71
this code works if the 1-bit deep pixmap format returned by GetSpans
72
is the same as the format defined by the mfb code (i.e. 32-bit padding
73
per scanline, scanline unit = 32 bits; later, this might mean
74
bitsizeof(int) padding and sacnline unit == bitsizeof(int).)
79
* in order to have both (MSB_FIRST and LSB_FIRST) versions of this
80
* in the server, we need to rename one of them
83
miPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
86
DrawablePtr pDrawable;
87
int dx, dy, xOrg, yOrg;
89
int h, dxDivPPW, ibEnd;
91
register MiBits *pw, *pwEnd;
94
register int ipt; /* index into above arrays */
96
DDXPointRec pt[NPT], ptThisLine;
100
if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER)
101
if (screenInfo.bitmapBitOrder == LSBFirst)
102
startmask = (MiBits)(-1) ^
103
LONG2CHARSSAMEORDER((MiBits)(-1) << 1);
105
startmask = (MiBits)(-1) ^
106
LONG2CHARSSAMEORDER((MiBits)(-1) >> 1);
108
if (screenInfo.bitmapBitOrder == LSBFirst)
109
startmask = (MiBits)(-1) ^
110
LONG2CHARSDIFFORDER((MiBits)(-1) << 1);
112
startmask = (MiBits)(-1) ^
113
LONG2CHARSDIFFORDER((MiBits)(-1) >> 1);
116
pwLineStart = (MiBits *)xalloc(BitmapBytePad(dx));
122
for(h = 0, ptThisLine.x = 0, ptThisLine.y = 0;
127
(*pBitMap->drawable.pScreen->GetSpans)((DrawablePtr)pBitMap, dx,
128
&ptThisLine, &dx, 1, (char *)pwLineStart);
131
/* Process all words which are fully in the pixmap */
134
pwEnd = pwLineStart + dxDivPPW;
141
msk = (MiBits)(-1) ^ SCRRIGHT((MiBits)(-1), 1);
143
for(ib = 0; ib < PPW; ib++)
149
pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
150
pt[ipt].y = h + yOrg;
159
width[ipt] = ((pw - pwLineStart) << PWSH) +
160
ib + xOrg - pt[ipt].x;
163
(*pGC->ops->FillSpans)(pDrawable, pGC,
164
NPT, pt, width, TRUE);
172
/* This is not quite right, but it'll do for now */
173
if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER)
174
if (screenInfo.bitmapBitOrder == LSBFirst)
175
msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) << 1);
177
msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) >> 1);
179
if (screenInfo.bitmapBitOrder == LSBFirst)
180
msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) << 1);
182
msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) >> 1);
184
msk = SCRRIGHT(msk, 1);
192
/* Process final partial word on line */
197
msk = (MiBits)(-1) ^ SCRRIGHT((MiBits)(-1), 1);
199
for(ib = 0; ib < ibEnd; ib++)
206
pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
207
pt[ipt].y = h + yOrg;
216
width[ipt] = ((pw - pwLineStart) << PWSH) +
217
ib + xOrg - pt[ipt].x;
220
(*pGC->ops->FillSpans)(pDrawable,
221
pGC, NPT, pt, width, TRUE);
228
/* This is not quite right, but it'll do for now */
229
if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER)
230
if (screenInfo.bitmapBitOrder == LSBFirst)
231
msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) << 1);
233
msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) >> 1);
235
if (screenInfo.bitmapBitOrder == LSBFirst)
236
msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) << 1);
238
msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) >> 1);
240
msk = SCRRIGHT(msk, 1);
244
/* If scanline ended with last bit set, end the box */
247
width[ipt] = dx + xOrg - pt[ipt].x;
250
(*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt, width, TRUE);
256
/* Flush any remaining spans */
259
(*pGC->ops->FillSpans)(pDrawable, pGC, ipt, pt, width, TRUE);