2 * Copyright © 1998 Keith Packard
3 * Copyright © 2012 Intel Corporation
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of Keith Packard not be used in
10 * advertising or publicity pertaining to distribution of the software without
11 * specific, written prior permission. Keith Packard makes no
12 * representations about the suitability of this software for any purpose. It
13 * is provided "as is" without express or implied warranty.
15 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21 * PERFORMANCE OF THIS SOFTWARE.
27 #define FbDestInvarientRop(alu,pm) ((pm) == FB_ALLONES && \
28 (((alu) >> 1 & 5) == ((alu) & 5)))
30 #define FbDestInvarientMergeRop() (_ca1 == 0 && _cx1 == 0)
32 /* AND has higher precedence than XOR */
34 #define FbDoMergeRop(src, dst) \
35 (((dst) & (((src) & _ca1) ^ _cx1)) ^ (((src) & _ca2) ^ _cx2))
37 #define FbDoDestInvarientMergeRop(src) (((src) & _ca2) ^ _cx2)
39 #define FbDoMaskMergeRop(src, dst, mask) \
40 (((dst) & ((((src) & _ca1) ^ _cx1) | ~(mask))) ^ ((((src) & _ca2) ^ _cx2) & (mask)))
42 #define FbDoLeftMaskByteMergeRop(dst, src, lb, l) { \
43 FbBits __xor = ((src) & _ca2) ^ _cx2; \
44 FbDoLeftMaskByteRRop(dst,lb,l,((src) & _ca1) ^ _cx1,__xor); \
47 #define FbDoRightMaskByteMergeRop(dst, src, rb, r) { \
48 FbBits __xor = ((src) & _ca2) ^ _cx2; \
49 FbDoRightMaskByteRRop(dst,rb,r,((src) & _ca1) ^ _cx1,__xor); \
52 #define FbDoRRop(dst, and, xor) (((dst) & (and)) ^ (xor))
54 #define FbDoMaskRRop(dst, and, xor, mask) \
55 (((dst) & ((and) | ~(mask))) ^ (xor & mask))
58 * Take a single bit (0 or 1) and generate a full mask
60 #define fbFillFromBit(b,t) (~((t) ((b) & 1)-1))
62 #define fbXorT(rop,fg,pm,t) ((((fg) & fbFillFromBit((rop) >> 1,t)) | \
63 (~(fg) & fbFillFromBit((rop) >> 3,t))) & (pm))
65 #define fbAndT(rop,fg,pm,t) ((((fg) & fbFillFromBit (rop ^ (rop>>1),t)) | \
66 (~(fg) & fbFillFromBit((rop>>2) ^ (rop>>3),t))) | \
69 #define fbXor(rop,fg,pm) fbXorT(rop,fg,pm,FbBits)
71 #define fbAnd(rop,fg,pm) fbAndT(rop,fg,pm,FbBits)
73 #define fbXorStip(rop,fg,pm) fbXorT(rop,fg,pm,FbStip)
75 #define fbAndStip(rop,fg,pm) fbAndT(rop,fg,pm,FbStip)
78 * Stippling operations;
80 extern const FbBits *const fbStippleTable[];
82 #define FbStippleRRop(dst, b, fa, fx, ba, bx) \
83 (FbDoRRop(dst, fa, fx) & b) | (FbDoRRop(dst, ba, bx) & ~b)
85 #define FbStippleRRopMask(dst, b, fa, fx, ba, bx, m) \
86 (FbDoMaskRRop(dst, fa, fx, m) & (b)) | (FbDoMaskRRop(dst, ba, bx, m) & ~(b))
88 #define FbDoLeftMaskByteStippleRRop(dst, b, fa, fx, ba, bx, lb, l) { \
89 FbBits __xor = ((fx) & (b)) | ((bx) & ~(b)); \
90 FbDoLeftMaskByteRRop(dst, lb, l, ((fa) & (b)) | ((ba) & ~(b)), __xor); \
93 #define FbDoRightMaskByteStippleRRop(dst, b, fa, fx, ba, bx, rb, r) { \
94 FbBits __xor = ((fx) & (b)) | ((bx) & ~(b)); \
95 FbDoRightMaskByteRRop(dst, rb, r, ((fa) & (b)) | ((ba) & ~(b)), __xor); \
98 #define FbOpaqueStipple(b, fg, bg) (((fg) & (b)) | ((bg) & ~(b)))
101 * Compute rop for using tile code for 1-bit dest stipples; modifies
102 * existing rop to flip depending on pixel values
104 #define FbStipple1RopPick(alu,b) (((alu) >> (2 - (((b) & 1) << 1))) & 3)
106 #define FbOpaqueStipple1Rop(alu,fg,bg) (FbStipple1RopPick(alu,fg) | \
107 (FbStipple1RopPick(alu,bg) << 2))
109 #define FbStipple1Rop(alu,fg) (FbStipple1RopPick(alu,fg) | 4)