VirtualBox

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

Last change on this file was 28062, checked in by vboxsync, 15 years ago

Additions/x11/x11include: header files for building X.Org server 1.8 drivers

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