First import
[xorg_rtime.git] / xorg-server-1.4 / mfb / mfbhrzvert.c
blob7616f9bf2104e5c8e610febd25a44b9340623942
1 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
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
10 documentation.
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.
29 All Rights Reserved
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
45 SOFTWARE.
47 ******************************************************************/
48 #ifdef HAVE_DIX_CONFIG_H
49 #include <dix-config.h>
50 #endif
52 #include <X11/X.h>
54 #include "gc.h"
55 #include "window.h"
56 #include "pixmap.h"
57 #include "region.h"
59 #include "mfb.h"
60 #include "maskbits.h"
62 /* horizontal solid line
63 abs(len) > 1
65 void
66 mfbHorzS(rop, addrl, nlwidth, x1, y1, len)
67 int rop; /* a reduced rasterop */
68 register PixelType *addrl; /* pointer to base of bitmap */
69 register int nlwidth; /* width in longwords of bitmap */
70 int x1; /* initial point */
71 int y1;
72 int len; /* length of line */
74 register PixelType startmask;
75 register PixelType endmask;
76 register int nlmiddle;
79 /* force the line to go left to right
80 but don't draw the last point
82 if (len < 0)
84 x1 += len;
85 x1 += 1;
86 len = -len;
89 addrl = mfbScanline(addrl, x1, y1, nlwidth);
91 /* all bits inside same longword */
92 if ( ((x1 & PIM) + len) < PPW)
94 maskpartialbits(x1, len, startmask);
95 if (rop == RROP_BLACK)
97 *addrl &= ~startmask;
99 else if (rop == RROP_WHITE)
101 *addrl |= startmask;
103 else if (rop == RROP_INVERT)
105 *addrl ^= startmask;
108 else
110 maskbits(x1, len, startmask, endmask, nlmiddle);
111 if (rop == RROP_BLACK)
113 if (startmask)
114 *addrl++ &= ~startmask;
115 Duff (nlmiddle, *addrl++ = 0x0);
116 if (endmask)
117 *addrl &= ~endmask;
119 else if (rop == RROP_WHITE)
121 if (startmask)
122 *addrl++ |= startmask;
123 Duff (nlmiddle, *addrl++ = ~0);
124 if (endmask)
125 *addrl |= endmask;
127 else if (rop == RROP_INVERT)
129 if (startmask)
130 *addrl++ ^= startmask;
131 Duff (nlmiddle, *addrl++ ^= ~0);
132 if (endmask)
133 *addrl ^= endmask;
138 /* vertical solid line
139 this uses do loops because pcc (Ultrix 1.2, bsd 4.2) generates
140 better code. sigh. we know that len will never be 0 or 1, so
141 it's OK to use it.
144 void
145 mfbVertS(rop, addrl, nlwidth, x1, y1, len)
146 int rop; /* a reduced rasterop */
147 register PixelType *addrl; /* pointer to base of bitmap */
148 register int nlwidth; /* width in longwords of bitmap */
149 int x1, y1; /* initial point */
150 register int len; /* length of line */
152 register PixelType bitmask;
154 addrl = mfbScanline(addrl, x1, y1, nlwidth);
156 if (len < 0)
158 nlwidth = -nlwidth;
159 len = -len;
162 if (rop == RROP_BLACK)
164 bitmask = rmask[x1 & PIM];
165 Duff(len, *addrl &= bitmask; mfbScanlineInc(addrl, nlwidth) );
167 else if (rop == RROP_WHITE)
169 bitmask = mask[x1 & PIM];
170 Duff(len, *addrl |= bitmask; mfbScanlineInc(addrl, nlwidth) );
172 else if (rop == RROP_INVERT)
174 bitmask = mask[x1 & PIM];
175 Duff(len, *addrl ^= bitmask; mfbScanlineInc(addrl, nlwidth) );