VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.3.0.0/fbrop.h@ 32915

Last change on this file since 32915 was 25078, checked in by vboxsync, 15 years ago

Additions/x11/x11include: exported and set eol-style on new headers

  • Property svn:eol-style set to native
File size: 4.8 KB
Line 
1/*
2 * Id: fbrop.h,v 1.1 1999/11/02 03:54:45 keithp Exp $
3 *
4 * Copyright © 1998 Keith Packard
5 *
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, and that the name of Keith Packard not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. Keith Packard makes no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
15 *
16 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
23 */
24
25#ifndef _FBROP_H_
26#define _FBROP_H_
27
28typedef struct _mergeRopBits {
29 FbBits ca1, cx1, ca2, cx2;
30} FbMergeRopRec, *FbMergeRopPtr;
31
32extern const FbMergeRopRec FbMergeRopBits[16];
33
34#define FbDeclareMergeRop() FbBits _ca1, _cx1, _ca2, _cx2;
35#define FbDeclarePrebuiltMergeRop() FbBits _cca, _ccx;
36
37#define FbInitializeMergeRop(alu,pm) {\
38 const FbMergeRopRec *_bits; \
39 _bits = &FbMergeRopBits[alu]; \
40 _ca1 = _bits->ca1 & pm; \
41 _cx1 = _bits->cx1 | ~pm; \
42 _ca2 = _bits->ca2 & pm; \
43 _cx2 = _bits->cx2 & pm; \
44}
45
46#define FbDestInvarientRop(alu,pm) ((pm) == FB_ALLONES && \
47 (((alu) >> 1 & 5) == ((alu) & 5)))
48
49#define FbDestInvarientMergeRop() (_ca1 == 0 && _cx1 == 0)
50
51/* AND has higher precedence than XOR */
52
53#define FbDoMergeRop(src, dst) \
54 (((dst) & (((src) & _ca1) ^ _cx1)) ^ (((src) & _ca2) ^ _cx2))
55
56#define FbDoDestInvarientMergeRop(src) (((src) & _ca2) ^ _cx2)
57
58#define FbDoMaskMergeRop(src, dst, mask) \
59 (((dst) & ((((src) & _ca1) ^ _cx1) | ~(mask))) ^ ((((src) & _ca2) ^ _cx2) & (mask)))
60
61#define FbDoLeftMaskByteMergeRop(dst, src, lb, l) { \
62 FbBits __xor = ((src) & _ca2) ^ _cx2; \
63 FbDoLeftMaskByteRRop(dst,lb,l,((src) & _ca1) ^ _cx1,__xor); \
64}
65
66#define FbDoRightMaskByteMergeRop(dst, src, rb, r) { \
67 FbBits __xor = ((src) & _ca2) ^ _cx2; \
68 FbDoRightMaskByteRRop(dst,rb,r,((src) & _ca1) ^ _cx1,__xor); \
69}
70
71#define FbDoRRop(dst, and, xor) (((dst) & (and)) ^ (xor))
72
73#define FbDoMaskRRop(dst, and, xor, mask) \
74 (((dst) & ((and) | ~(mask))) ^ (xor & mask))
75
76/*
77 * Take a single bit (0 or 1) and generate a full mask
78 */
79#define fbFillFromBit(b,t) (~((t) ((b) & 1)-1))
80
81#define fbXorT(rop,fg,pm,t) ((((fg) & fbFillFromBit((rop) >> 1,t)) | \
82 (~(fg) & fbFillFromBit((rop) >> 3,t))) & (pm))
83
84#define fbAndT(rop,fg,pm,t) ((((fg) & fbFillFromBit (rop ^ (rop>>1),t)) | \
85 (~(fg) & fbFillFromBit((rop>>2) ^ (rop>>3),t))) | \
86 ~(pm))
87
88#define fbXor(rop,fg,pm) fbXorT(rop,fg,pm,FbBits)
89
90#define fbAnd(rop,fg,pm) fbAndT(rop,fg,pm,FbBits)
91
92#define fbXorStip(rop,fg,pm) fbXorT(rop,fg,pm,FbStip)
93
94#define fbAndStip(rop,fg,pm) fbAndT(rop,fg,pm,FbStip)
95
96/*
97 * Stippling operations;
98 */
99
100extern const FbBits fbStipple16Bits[256]; /* half of table */
101#define FbStipple16Bits(b) \
102 (fbStipple16Bits[(b)&0xff] | fbStipple16Bits[(b) >> 8] << FB_HALFUNIT)
103extern const FbBits fbStipple8Bits[256];
104extern const FbBits fbStipple4Bits[16];
105extern const FbBits fbStipple2Bits[4];
106extern const FbBits fbStipple1Bits[2];
107extern const FbBits *const fbStippleTable[];
108
109#define FbStippleRRop(dst, b, fa, fx, ba, bx) \
110 (FbDoRRop(dst, fa, fx) & b) | (FbDoRRop(dst, ba, bx) & ~b)
111
112#define FbStippleRRopMask(dst, b, fa, fx, ba, bx, m) \
113 (FbDoMaskRRop(dst, fa, fx, m) & (b)) | (FbDoMaskRRop(dst, ba, bx, m) & ~(b))
114
115#define FbDoLeftMaskByteStippleRRop(dst, b, fa, fx, ba, bx, lb, l) { \
116 FbBits __xor = ((fx) & (b)) | ((bx) & ~(b)); \
117 FbDoLeftMaskByteRRop(dst, lb, l, ((fa) & (b)) | ((ba) & ~(b)), __xor); \
118}
119
120#define FbDoRightMaskByteStippleRRop(dst, b, fa, fx, ba, bx, rb, r) { \
121 FbBits __xor = ((fx) & (b)) | ((bx) & ~(b)); \
122 FbDoRightMaskByteRRop(dst, rb, r, ((fa) & (b)) | ((ba) & ~(b)), __xor); \
123}
124
125#define FbOpaqueStipple(b, fg, bg) (((fg) & (b)) | ((bg) & ~(b)))
126
127/*
128 * Compute rop for using tile code for 1-bit dest stipples; modifies
129 * existing rop to flip depending on pixel values
130 */
131#define FbStipple1RopPick(alu,b) (((alu) >> (2 - (((b) & 1) << 1))) & 3)
132
133#define FbOpaqueStipple1Rop(alu,fg,bg) (FbStipple1RopPick(alu,fg) | \
134 (FbStipple1RopPick(alu,bg) << 2))
135
136#define FbStipple1Rop(alu,fg) (FbStipple1RopPick(alu,fg) | 4)
137
138#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette