1
/* $XFree86: xc/programs/Xserver/cfb/cfbbres.c,v 3.5 2001/12/14 19:59:21 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: cfbbres.c,v 1.4 2001/02/09 02:04:37 xorgcvs Exp $ */
52
#include "cfbmskbits.h"
56
/* Solid bresenham line */
58
e2 is used less often than e1, so it's not in a register
62
cfbBresS(rop, and, xor, addrl, nlwidth, signdx, signdy, axis, x1, y1, e, e1,
66
CfbBits *addrl; /* pointer to base of bitmap */
67
int nlwidth; /* width in longwords of bitmap */
69
int signdy; /* signs of directions */
70
int axis; /* major axis (Y_AXIS or X_AXIS) */
71
int x1, y1; /* initial point */
72
register int e; /* error accumulator */
73
register int e1; /* bresenham increments */
75
int len; /* length of line */
77
register int e3 = e2-e1;
79
CfbBits piQxelXor[3],piQxelAnd[3];
81
int nlwidth3, signdx3;
84
register PixelType *addrp; /* Pixel pointer */
88
/* point to first point */
91
addrp = (PixelType *)(addrl) + (y1 * nlwidth);
92
addrb = (char *)addrp + x1 * 3;
94
piQxelXor[0] = (xor << 24) | xor;
95
piQxelXor[1] = (xor << 16)| (xor >> 8);
96
piQxelXor[2] = (xor << 8) | (xor >> 16);
97
piQxelAnd[0] = (and << 24) | and;
98
piQxelAnd[1] = (and << 16)| (and >> 8);
99
piQxelAnd[2] = (and << 8) | (and >> 16);
101
addrp = (PixelType *)(addrl) + (y1 * nlwidth) + x1;
105
e = e-e1; /* to make looping easier */
107
nlwidth3 = nlwidth * sizeof (CfbBits);
108
signdx3 = signdx * 3;
129
addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
130
switch((unsigned long)addrb & 3){ \
132
*addrp = ((*addrp)&0xFF000000)|(piQxelXor[0] & 0xFFFFFF); \
135
*addrp = ((*addrp)&0xFF)|(piQxelXor[2] & 0xFFFFFF00); \
138
*addrp = ((*addrp)&0xFFFFFF)|(piQxelXor[0] & 0xFF000000); \
139
*(addrp+1) = ((*(addrp+1))&0xFFFF0000)|(piQxelXor[1] & 0xFFFF); \
142
*addrp = ((*addrp)&0xFFFF)|(piQxelXor[1] & 0xFFFF0000); \
143
*(addrp+1) = ((*(addrp+1))&0xFFFFFF00)|(piQxelXor[2] & 0xFF); \
156
#else /* PSZ == 24 */
167
#endif /* PSZ == 24 */
175
case 3: body case 2: body case 1: body
185
else /* not GXcopy */
190
addrp = (PixelType *)((unsigned long)addrb & ~0x03);
191
switch((unsigned long)addrb & 3){
193
*addrp = (*addrp & (piQxelAnd[0]|0xFF000000))
194
^ (piQxelXor[0] & 0xFFFFFF);
197
*addrp = (*addrp & (piQxelAnd[2]|0xFF))
198
^ (piQxelXor[2] & 0xFFFFFF00);
201
*addrp = (*addrp & (piQxelAnd[0]|0xFFFFFF))
202
^ (piQxelXor[0] & 0xFF000000);
203
*(addrp+1) = (*(addrp+1) & (piQxelAnd[1]|0xFFFF0000))
204
^ (piQxelXor[1] & 0xFFFF);
207
*addrp = (*addrp & (piQxelAnd[1]|0xFFFF))
208
^ (piQxelXor[1] & 0xFFFF0000);
209
*(addrp+1) = (*(addrp+1) & (piQxelAnd[2]|0xFFFFFF00))
210
^ (piQxelXor[2] & 0xFF);
220
#else /* PSZ == 24 */
221
*addrp = DoRRop (*addrp, and, xor);
229
#endif /* PSZ == 24 */
232
#else /* !PIXEL_ADDR */
233
register CfbBits tmp, bit;
234
CfbBits leftbit, rightbit;
236
/* point to longword containing first point */
238
addrl = (addrl + (y1 * nlwidth) + ((x1 * 3) >>2);
240
addrl = (addrl + (y1 * nlwidth) + (x1 >> PWSH));
244
e = e-e1; /* to make looping easier */
246
leftbit = cfbmask[0];
248
rightbit = cfbmask[(PPW-1)<<1];
249
bit = cfbmask[(x1 & 3)<<1];
251
rightbit = cfbmask[PPW-1];
252
bit = cfbmask[x1 & PIM];
261
*addrl = DoMaskRRop (*addrl, and, xor, bit);
262
bit = SCRRIGHT(bit,1);
280
*addrl = DoMaskRRop (*addrl, and, xor, bit);
282
bit = SCRLEFT(bit,1);
302
*addrl = DoMaskRRop (*addrl, and, xor, bit);
306
bit = SCRRIGHT(bit,1);
321
*addrl = DoMaskRRop (*addrl, and, xor, bit);
325
bit = SCRLEFT(bit,1);