2 * Copyright IBM Corporation 1987,1988,1989
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
24 #ifdef HAVE_XORG_CONFIG_H
25 #include <xorg-config.h>
31 /* xf4bppGetReducedColorRrop( pGC, drawableDepth, returnLoc )
32 * An attempt to do "strength reduction" on color raster-ops
40 register unsigned long pm
,
41 register unsigned long fg
,
42 register unsigned long bg
,
43 register int fillStyle
,
45 ppcReducedRrop
*returnLoc
49 if ( ( alu
== GXnoop
)
50 || !( pm
&= ( ( 1 << drawableDepth
) - 1 ) ) ) {
51 returnLoc
->alu
= GXnoop
;
56 switch ( fillStyle
) {
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 */
67 case FillOpaqueStippled
:
68 if ( ( fg
& pm
) != ( bg
& pm
) ) { /* else FillSolid */
70 case GXclear
: /* 0x0 Zero 0 */
71 case GXset
: /* 0xf 1 */
72 case GXinvert
: /* 0xa NOT dst */
73 fillStyle
= FillSolid
;
75 case GXnor
: /* 0x8 NOT src AND NOT dst */
76 case GXnand
: /* 0xe NOT src OR NOT dst */
77 case GXcopy
: /* 0x3 src */
79 case GXandReverse
: /* 0x2 src AND NOT dst */
84 case GXandInverted
: /* 0x4 NOT src AND dst */
87 alu
= GXand
; /* Fall Through */
88 case GXand
: /* 0x1 src AND dst */
90 if ( ( bg
& pm
) == pm
) {
91 fillStyle
= FillStippled
;
95 case GXequiv
: /* 0x9 NOT src XOR dst */
98 alu
= GXxor
; /* Fall Through */
99 case GXxor
: /* 0x6 src XOR dst */
101 if ( !( bg
& pm
) ) {
102 fillStyle
= FillStippled
;
106 case GXorReverse
: /* 0xb src OR NOT dst */
111 case GXcopyInverted
: /* 0xc NOT src */
116 case GXorInverted
: /* 0xd NOT src OR dst */
119 alu
= GXor
; /* Fall Through */
120 case GXor
: /* 0x7 src OR dst */
122 if ( !( bg
& pm
) ) {
123 fillStyle
= FillStippled
;
129 "xf4bppGetReducedColorRrop: Unknown Alu Raster-Op" ) ;
132 break ; /* Don't Fall Through */
135 fillStyle
= FillSolid
;
140 case GXclear
: /* 0x0 Zero 0 */
141 case GXset
: /* 0xf 1 */
142 case GXinvert
: /* 0xa NOT dst */
144 case GXand
: /* 0x1 src AND dst */
148 case GXandReverse
: /* 0x2 src AND NOT dst */
150 alu
= GXnor
; /* Fall Through */
151 case GXnor
: /* 0x8 NOT src AND NOT dst */
154 else if ( ( fg
& pm
) == pm
)
157 case GXandInverted
: /* 0x4 NOT src AND dst */
161 case GXxor
: /* 0x6 src XOR dst */
165 case GXor
: /* 0x7 src OR dst */
169 case GXequiv
: /* 0x9 NOT src XOR dst */
173 case GXorReverse
: /* 0xb src OR NOT dst */
175 alu
= GXnand
; /* Fall Through */
176 case GXnand
: /* 0xe NOT src OR NOT dst */
179 else if ( ( fg
& pm
) == pm
)
182 case GXcopyInverted
: /* 0xc NOT src */
184 alu
= GXcopy
; /* Fall Through */
185 case GXcopy
: /* 0x3 src */
188 else if ( ( fg
& pm
) == pm
)
191 case GXorInverted
: /* 0xd NOT src OR dst */
197 "xf4bppGetReducedColorRrop: Unknown Alu Raster-Op" ) ;
202 ErrorF("xf4bppGetReducedColorRrop: Bad Fillstyle\n");
207 /* Final Test On Restricted Plane Mask */
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
;
222 xf4bppGetReducedColorRrop( pGC
, drawableDepth
, returnLoc
)
225 ppcReducedRrop
*returnLoc
;
228 ppcReduceGeneral( pGC
->alu
,