Initial commit
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / xf4bpp / ppcCReduce.c
blobc567e6fd10c9630724dfb79cb9533604465b3e7d
1 /*
2 * Copyright IBM Corporation 1987,1988,1989
4 * All Rights Reserved
6 * Permission to use, copy, modify, and distribute this software and its
7 * documentation for any purpose and without fee is hereby granted,
8 * provided that the above copyright notice appear in all copies and that
9 * both that copyright notice and this permission notice appear in
10 * supporting documentation, and that the name of IBM not be
11 * used in advertising or publicity pertaining to distribution of the
12 * software without specific, written prior permission.
14 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
16 * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
19 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20 * SOFTWARE.
24 #ifdef HAVE_XORG_CONFIG_H
25 #include <xorg-config.h>
26 #endif
28 #include "xf4bpp.h"
29 #include "ppcGCstr.h"
31 /* xf4bppGetReducedColorRrop( pGC, drawableDepth, returnLoc )
32 * An attempt to do "strength reduction" on color raster-ops
33 * P. Shupak 1/88
36 static void
37 ppcReduceGeneral
39 register int alu,
40 register unsigned long pm,
41 register unsigned long fg,
42 register unsigned long bg,
43 register int fillStyle,
44 int drawableDepth,
45 ppcReducedRrop *returnLoc
49 if ( ( alu == GXnoop )
50 || !( pm &= ( ( 1 << drawableDepth ) - 1 ) ) ) {
51 returnLoc->alu = GXnoop ;
52 return ;
55 #ifdef DELETE_THIS
56 switch ( fillStyle ) {
57 case FillTiled:
58 switch ( alu ) {
59 case GXclear: /* 0x0 Zero 0 */
60 case GXinvert: /* 0xa NOT dst */
61 case GXset: /* 0xf 1 */
62 fillStyle = FillSolid ;
63 default: /* We Can't Do Much Here */
64 break ;
66 break ;
67 case FillOpaqueStippled:
68 if ( ( fg & pm ) != ( bg & pm ) ) { /* else FillSolid */
69 switch ( alu ) {
70 case GXclear: /* 0x0 Zero 0 */
71 case GXset: /* 0xf 1 */
72 case GXinvert: /* 0xa NOT dst */
73 fillStyle = FillSolid ;
74 break ;
75 case GXnor: /* 0x8 NOT src AND NOT dst */
76 case GXnand: /* 0xe NOT src OR NOT dst */
77 case GXcopy: /* 0x3 src */
78 break ;
79 case GXandReverse: /* 0x2 src AND NOT dst */
80 fg = ~fg ;
81 bg = ~bg ;
82 alu = GXnor ;
83 break ;
84 case GXandInverted: /* 0x4 NOT src AND dst */
85 fg = ~fg ;
86 bg = ~bg ;
87 alu = GXand ; /* Fall Through */
88 case GXand: /* 0x1 src AND dst */
89 pm &= ~( fg & bg ) ;
90 if ( ( bg & pm ) == pm ) {
91 fillStyle = FillStippled ;
92 alu = GXclear ;
94 break ;
95 case GXequiv: /* 0x9 NOT src XOR dst */
96 fg = ~fg ;
97 bg = ~bg ;
98 alu = GXxor ; /* Fall Through */
99 case GXxor: /* 0x6 src XOR dst */
100 pm &= ( fg | bg ) ;
101 if ( !( bg & pm ) ) {
102 fillStyle = FillStippled ;
103 alu = GXinvert ;
105 break ;
106 case GXorReverse: /* 0xb src OR NOT dst */
107 fg = ~fg ;
108 bg = ~bg ;
109 alu = GXnand ;
110 break ;
111 case GXcopyInverted: /* 0xc NOT src */
112 fg = ~fg ;
113 bg = ~bg ;
114 alu = GXcopy ;
115 break ;
116 case GXorInverted: /* 0xd NOT src OR dst */
117 fg = ~fg ;
118 bg = ~bg ;
119 alu = GXor ; /* Fall Through */
120 case GXor: /* 0x7 src OR dst */
121 pm &= ( fg | bg ) ;
122 if ( !( bg & pm ) ) {
123 fillStyle = FillStippled ;
124 alu = GXset ;
126 break ;
127 default:
128 ErrorF(
129 "xf4bppGetReducedColorRrop: Unknown Alu Raster-Op" ) ;
130 break ;
132 break ; /* Don't Fall Through */
134 else
135 fillStyle = FillSolid ;
136 /* Fall Through */
137 case FillStippled:
138 case FillSolid:
139 switch ( alu ) {
140 case GXclear: /* 0x0 Zero 0 */
141 case GXset: /* 0xf 1 */
142 case GXinvert: /* 0xa NOT dst */
143 break ;
144 case GXand: /* 0x1 src AND dst */
145 pm &= ~fg ;
146 alu = GXclear ;
147 break ;
148 case GXandReverse: /* 0x2 src AND NOT dst */
149 fg = ~fg ;
150 alu = GXnor ; /* Fall Through */
151 case GXnor: /* 0x8 NOT src AND NOT dst */
152 if ( !( fg & pm ) )
153 alu = GXclear ;
154 else if ( ( fg & pm ) == pm )
155 alu = GXinvert ;
156 break ;
157 case GXandInverted: /* 0x4 NOT src AND dst */
158 pm &= fg ;
159 alu = GXclear ;
160 break ;
161 case GXxor: /* 0x6 src XOR dst */
162 pm &= fg ;
163 alu = GXinvert ;
164 break ;
165 case GXor: /* 0x7 src OR dst */
166 pm &= fg ;
167 alu = GXset ;
168 break ;
169 case GXequiv: /* 0x9 NOT src XOR dst */
170 pm &= ~fg ;
171 alu = GXinvert ;
172 break ;
173 case GXorReverse: /* 0xb src OR NOT dst */
174 fg = ~fg ;
175 alu = GXnand ; /* Fall Through */
176 case GXnand: /* 0xe NOT src OR NOT dst */
177 if ( !( fg & pm ) )
178 alu = GXset ;
179 else if ( ( fg & pm ) == pm )
180 alu = GXinvert ;
181 break ;
182 case GXcopyInverted: /* 0xc NOT src */
183 fg = ~fg ;
184 alu = GXcopy ; /* Fall Through */
185 case GXcopy: /* 0x3 src */
186 if ( !( fg & pm ) )
187 alu = GXclear ;
188 else if ( ( fg & pm ) == pm )
189 alu = GXset ;
190 break ;
191 case GXorInverted: /* 0xd NOT src OR dst */
192 pm &= ~fg ;
193 alu = GXset ;
194 break ;
195 default:
196 ErrorF(
197 "xf4bppGetReducedColorRrop: Unknown Alu Raster-Op" ) ;
198 break ;
200 break;
201 default:
202 ErrorF("xf4bppGetReducedColorRrop: Bad Fillstyle\n");
203 break;
205 #endif
207 /* Final Test On Restricted Plane Mask */
208 if ( !pm )
209 alu = GXnoop ;
211 /* Set Actual Returned Values */
212 returnLoc->planemask = pm ;
213 returnLoc->fgPixel = fg ;
214 returnLoc->bgPixel = bg ;
215 returnLoc->alu = alu ;
216 returnLoc->fillStyle = fillStyle ;
218 return ;
221 void
222 xf4bppGetReducedColorRrop( pGC, drawableDepth, returnLoc )
223 GC *pGC ;
224 int drawableDepth ;
225 ppcReducedRrop *returnLoc ;
228 ppcReduceGeneral( pGC->alu,
229 pGC->planemask,
230 pGC->fgPixel,
231 pGC->bgPixel,
232 pGC->fillStyle,
233 drawableDepth,
234 returnLoc ) ;
236 return ;