VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.5.3/cfbrrop.h@ 17448

Last change on this file since 17448 was 17448, checked in by vboxsync, 16 years ago

Additions/x11: added a full header set for X.Org server 1.5 and 1.6

  • Property svn:eol-style set to native
File size: 13.1 KB
Line 
1/*
2 *
3Copyright 1989, 1998 The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21Except as contained in this notice, the name of The Open Group shall not be
22used in advertising or otherwise to promote the sale, use or other dealings
23in this Software without prior written authorization from The Open Group.
24 *
25 * Author: Keith Packard, MIT X Consortium
26 */
27
28
29#ifdef HAVE_DIX_CONFIG_H
30#include <dix-config.h>
31#endif
32
33#ifndef GXcopy
34#include <X11/X.h>
35#endif
36
37#define RROP_FETCH_GC(gc) \
38 RROP_FETCH_GCPRIV((cfbPrivGCPtr)dixLookupPrivate(&(gc)->devPrivates, \
39 cfbGCPrivateKey))
40
41#ifndef RROP
42#define RROP GXset
43#endif
44
45#if RROP == GXcopy
46#if PSZ == 24
47#define RROP_DECLARE register CfbBits rrop_xor; \
48 CfbBits piQxelXor[3], spiQxelXor[8];
49#define RROP_FETCH_GCPRIV(devPriv) rrop_xor = (devPriv)->xor; \
50 spiQxelXor[0] = rrop_xor & 0xFFFFFF; \
51 spiQxelXor[2] = rrop_xor << 24; \
52 spiQxelXor[3] = (rrop_xor & 0xFFFF00)>> 8; \
53 spiQxelXor[4] = rrop_xor << 16; \
54 spiQxelXor[5] = (rrop_xor & 0xFF0000)>> 16; \
55 spiQxelXor[6] = rrop_xor << 8; \
56 spiQxelXor[1] = spiQxelXor[7] = 0; \
57 piQxelXor[0] = (rrop_xor & 0xFFFFFF)|(rrop_xor << 24); \
58 piQxelXor[1] = (rrop_xor << 16)|((rrop_xor & 0xFFFF00)>> 8); \
59 piQxelXor[2] = (rrop_xor << 8)|((rrop_xor & 0xFF0000)>> 16);
60#define RROP_SOLID24(dst,index) {\
61 register int idx = ((index) & 3)<< 1; \
62 *(dst) = (*(dst) & cfbrmask[idx])|spiQxelXor[idx]; \
63 if (idx == 2 || idx == 4){ \
64 idx++; \
65 *((dst)+1) = (*((dst)+1) & cfbrmask[idx])|spiQxelXor[idx]; \
66 } \
67 }
68#define RROP_SOLID(dst, idx) \
69 (*(dst) = piQxelXor[(idx)])
70#define RROP_SOLID_MASK(dst,mask,idx) \
71 (*(dst) = (*(dst) & ~(mask))|(piQxelXor[(idx)] & (mask)))
72#define RROP_UNDECLARE (void)piQxelXor; (void)spiQxelXor;
73#else
74#define RROP_FETCH_GCPRIV(devPriv) rrop_xor = (devPriv)->xor;
75#define RROP_DECLARE register CfbBits rrop_xor;
76#define RROP_SOLID(dst) (*(dst) = (rrop_xor))
77#define RROP_SOLID_MASK(dst,mask) (*(dst) = (*(dst) & ~(mask)) | ((rrop_xor) & (mask)))
78#define RROP_UNDECLARE
79#endif
80#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,Copy)
81#endif /* GXcopy */
82
83#if RROP == GXxor
84#if PSZ == 24
85#define RROP_DECLARE register CfbBits rrop_xor; \
86 CfbBits piQxelXor[3], spiQxelXor[8];
87#define RROP_FETCH_GCPRIV(devPriv) rrop_xor = (devPriv)->xor; \
88 spiQxelXor[0] = rrop_xor & 0xFFFFFF; \
89 spiQxelXor[2] = rrop_xor << 24; \
90 spiQxelXor[3] = (rrop_xor & 0xFFFF00)>> 8; \
91 spiQxelXor[4] = rrop_xor << 16; \
92 spiQxelXor[5] = (rrop_xor & 0xFF0000)>> 16; \
93 spiQxelXor[6] = rrop_xor << 8; \
94 spiQxelXor[1] = spiQxelXor[7] = 0; \
95 piQxelXor[0] = (rrop_xor & 0xFFFFFF)|(rrop_xor << 24); \
96 piQxelXor[1] = (rrop_xor << 16)|((rrop_xor & 0xFFFF00)>> 8); \
97 piQxelXor[2] = (rrop_xor << 8)|((rrop_xor & 0xFF0000)>> 16);
98#define RROP_SOLID24(dst,index) {\
99 register int idx = ((index) & 3)<< 1; \
100 *(dst) ^= spiQxelXor[idx]; \
101 if (idx == 2 || idx == 4) \
102 *((dst)+1) ^= spiQxelXor[idx+1]; \
103 }
104#define RROP_SOLID(dst,idx) \
105 (*(dst) ^= piQxelXor[(idx)])
106#define RROP_SOLID_MASK(dst,mask,idx) \
107 (*(dst) ^= (piQxelXor[(idx)] & (mask)))
108#define RROP_UNDECLARE (void)piQxelXor; (void)spiQxelXor;
109#else
110#define RROP_DECLARE register CfbBits rrop_xor;
111#define RROP_FETCH_GCPRIV(devPriv) rrop_xor = (devPriv)->xor;
112#define RROP_SOLID(dst) (*(dst) ^= (rrop_xor))
113#define RROP_SOLID_MASK(dst,mask) (*(dst) ^= ((rrop_xor) & (mask)))
114#define RROP_UNDECLARE
115#endif
116#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,Xor)
117#endif /* GXxor */
118
119#if RROP == GXand
120#if PSZ == 24
121#define RROP_DECLARE register CfbBits rrop_and; \
122 CfbBits piQxelAnd[3], spiQxelAnd[6];
123#define RROP_FETCH_GCPRIV(devPriv) rrop_and = (devPriv)->and; \
124 spiQxelAnd[0] = (rrop_and & 0xFFFFFF) | 0xFF000000; \
125 spiQxelAnd[2] = (rrop_and << 24) | 0xFFFFFF; \
126 spiQxelAnd[3] = ((rrop_and & 0xFFFF00)>> 8) | 0xFFFF0000; \
127 spiQxelAnd[4] = (rrop_and << 16) | 0xFFFF; \
128 spiQxelAnd[5] = ((rrop_and & 0xFF0000)>> 16) | 0xFFFFFF00; \
129 spiQxelAnd[1] = (rrop_and << 8) | 0xFF; \
130 piQxelAnd[0] = (rrop_and & 0xFFFFFF)|(rrop_and << 24); \
131 piQxelAnd[1] = (rrop_and << 16)|((rrop_and & 0xFFFF00)>> 8); \
132 piQxelAnd[2] = (rrop_and << 8)|((rrop_and & 0xFF0000)>> 16);
133#define RROP_SOLID24(dst,index) {\
134 switch((index) & 3){ \
135 case 0: \
136 *(dst) &= spiQxelAnd[0]; \
137 break; \
138 case 3: \
139 *(dst) &= spiQxelAnd[1]; \
140 break; \
141 case 1: \
142 *(dst) &= spiQxelAnd[2]; \
143 *((dst)+1) &= spiQxelAnd[3]; \
144 break; \
145 case 2: \
146 *(dst) &= spiQxelAnd[4]; \
147 *((dst)+1) &= spiQxelAnd[5]; \
148 break; \
149 } \
150 }
151#define RROP_SOLID(dst,idx) \
152 (*(dst) &= piQxelAnd[(idx)])
153#define RROP_SOLID_MASK(dst,mask,idx) \
154 (*(dst) &= (piQxelAnd[(idx)] | ~(mask)))
155#define RROP_UNDECLARE (void)piQxelAnd; (void)spiQxelAnd;
156#else
157#define RROP_DECLARE register CfbBits rrop_and;
158#define RROP_FETCH_GCPRIV(devPriv) rrop_and = (devPriv)->and;
159#define RROP_SOLID(dst) (*(dst) &= (rrop_and))
160#define RROP_SOLID_MASK(dst,mask) (*(dst) &= ((rrop_and) | ~(mask)))
161#define RROP_UNDECLARE
162#endif
163#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,And)
164#endif /* GXand */
165
166#if RROP == GXor
167#if PSZ == 24
168#define RROP_DECLARE register CfbBits rrop_or; \
169 CfbBits piQxelOr[3], spiQxelOr[6];
170#define RROP_FETCH_GCPRIV(devPriv) rrop_or = (devPriv)->xor; \
171 spiQxelOr[0] = rrop_or & 0xFFFFFF; \
172 spiQxelOr[1] = rrop_or << 24; \
173 spiQxelOr[2] = rrop_or << 16; \
174 spiQxelOr[3] = rrop_or << 8; \
175 spiQxelOr[4] = (rrop_or & 0xFFFF00)>> 8; \
176 spiQxelOr[5] = (rrop_or & 0xFF0000)>> 16; \
177 piQxelOr[0] = (rrop_or & 0xFFFFFF)|(rrop_or << 24); \
178 piQxelOr[1] = (rrop_or << 16)|((rrop_or & 0xFFFF00)>> 8); \
179 piQxelOr[2] = (rrop_or << 8)|((rrop_or & 0xFF0000)>> 16);
180#define RROP_SOLID24(dst,index) {\
181 switch((index) & 3){ \
182 case 0: \
183 *(dst) |= spiQxelOr[0]; \
184 break; \
185 case 3: \
186 *(dst) |= spiQxelOr[3]; \
187 break; \
188 case 1: \
189 *(dst) |= spiQxelOr[1]; \
190 *((dst)+1) |= spiQxelOr[4]; \
191 break; \
192 case 2: \
193 *(dst) |= spiQxelOr[2]; \
194 *((dst)+1) |= spiQxelOr[5]; \
195 break; \
196 } \
197 }
198#define RROP_SOLID(dst,idx) \
199 (*(dst) |= piQxelOr[(idx)])
200#define RROP_SOLID_MASK(dst,mask,idx) \
201 (*(dst) |= (piQxelOr[(idx)] & (mask)))
202#define RROP_UNDECLARE (void)piQxelOr; (void)spiQxelOr;
203#else
204#define RROP_DECLARE register CfbBits rrop_or;
205#define RROP_FETCH_GCPRIV(devPriv) rrop_or = (devPriv)->xor;
206#define RROP_SOLID(dst) (*(dst) |= (rrop_or))
207#define RROP_SOLID_MASK(dst,mask) (*(dst) |= ((rrop_or) & (mask)))
208#define RROP_UNDECLARE
209#endif
210#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,Or)
211#endif /* GXor */
212
213#if RROP == GXnoop
214#define RROP_DECLARE
215#define RROP_FETCH_GCPRIV(devPriv)
216#define RROP_SOLID(dst)
217#define RROP_SOLID_MASK(dst,mask)
218#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,Noop)
219#define RROP_UNDECLARE
220#endif /* GXnoop */
221
222#if RROP == GXset
223#if PSZ == 24
224#define RROP_DECLARE register CfbBits rrop_and, rrop_xor; \
225 CfbBits piQxelAnd[3], piQxelXor[3], spiQxelAnd[6], spiQxelXor[6];
226#define RROP_FETCH_GCPRIV(devPriv) rrop_and = (devPriv)->and; \
227 rrop_xor = (devPriv)->xor; \
228 spiQxelXor[0] = rrop_xor & 0xFFFFFF; \
229 spiQxelXor[1] = rrop_xor << 24; \
230 spiQxelXor[2] = rrop_xor << 16; \
231 spiQxelXor[3] = rrop_xor << 8; \
232 spiQxelXor[4] = (rrop_xor & 0xFFFF00)>> 8; \
233 spiQxelXor[5] = (rrop_xor & 0xFF0000)>> 16; \
234 spiQxelAnd[0] = (rrop_and & 0xFFFFFF) | 0xFF000000; \
235 spiQxelAnd[1] = (rrop_and << 24) | 0xFFFFFF; \
236 spiQxelAnd[2] = (rrop_and << 16) | 0xFFFF; \
237 spiQxelAnd[3] = (rrop_and << 8) | 0xFF; \
238 spiQxelAnd[4] = ((rrop_and & 0xFFFF00)>> 8) | 0xFFFF0000; \
239 spiQxelAnd[5] = ((rrop_and & 0xFF0000)>> 16) | 0xFFFFFF00; \
240 piQxelAnd[0] = (rrop_and & 0xFFFFFF)|(rrop_and << 24); \
241 piQxelAnd[1] = (rrop_and << 16)|((rrop_and & 0xFFFF00)>> 8); \
242 piQxelAnd[2] = (rrop_and << 8)|((rrop_and & 0xFF0000)>> 16); \
243 piQxelXor[0] = (rrop_xor & 0xFFFFFF)|(rrop_xor << 24); \
244 piQxelXor[1] = (rrop_xor << 16)|((rrop_xor & 0xFFFF00)>> 8); \
245 piQxelXor[2] = (rrop_xor << 8)|((rrop_xor & 0xFF0000)>> 16);
246#define RROP_SOLID24(dst,index) {\
247 switch((index) & 3){ \
248 case 0: \
249 *(dst) = ((*(dst) & (piQxelAnd[0] |0xFF000000))^(piQxelXor[0] & 0xFFFFFF)); \
250 break; \
251 case 3: \
252 *(dst) = ((*(dst) & (piQxelAnd[2]|0xFF))^(piQxelXor[2] & 0xFFFFFF00)); \
253 break; \
254 case 1: \
255 *(dst) = ((*(dst) & (piQxelAnd[0]|0xFFFFFF))^(piQxelXor[0] & 0xFF000000)); \
256 *((dst)+1) = ((*((dst)+1) & (piQxelAnd[1]|0xFFFF0000))^(piQxelXor[1] & 0xFFFF)); \
257 break; \
258 case 2: \
259 *(dst) = ((*(dst) & (piQxelAnd[1]|0xFFFF))^(piQxelXor[1] & 0xFFFF0000)); \
260 *((dst)+1) = ((*((dst)+1) & (piQxelAnd[2]|0xFFFFFF00))^(piQxelXor[2] & 0xFF)); \
261 break; \
262 } \
263 }
264#define RROP_SOLID(dst,idx) \
265 (*(dst) = DoRRop (*(dst), piQxelAnd[(idx)], piQxelXor[(idx)]))
266#define RROP_SOLID_MASK(dst,mask,idx) \
267 (*(dst) = DoMaskRRop (*(dst), piQxelAnd[(idx)], piQxelXor[(idx)], (mask)))
268#define RROP_UNDECLARE (void)piQxelAnd; (void)piQxelXor; \
269 (void)spiQxelAnd; (void)spiQxelXor;
270#else
271#define RROP_DECLARE register CfbBits rrop_and, rrop_xor;
272#define RROP_FETCH_GCPRIV(devPriv) rrop_and = (devPriv)->and; \
273 rrop_xor = (devPriv)->xor;
274#define RROP_SOLID(dst) (*(dst) = DoRRop (*(dst), rrop_and, rrop_xor))
275#define RROP_SOLID_MASK(dst,mask) (*(dst) = DoMaskRRop (*(dst), rrop_and, rrop_xor, (mask)))
276#define RROP_UNDECLARE
277#endif
278#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,General)
279#endif /* GXset */
280
281#define RROP_UNROLL_CASE1(p,i) case (i): RROP_SOLID((p) - (i));
282#define RROP_UNROLL_CASE2(p,i) RROP_UNROLL_CASE1(p,(i)+1) RROP_UNROLL_CASE1(p,i)
283#define RROP_UNROLL_CASE4(p,i) RROP_UNROLL_CASE2(p,(i)+2) RROP_UNROLL_CASE2(p,i)
284#define RROP_UNROLL_CASE8(p,i) RROP_UNROLL_CASE4(p,(i)+4) RROP_UNROLL_CASE4(p,i)
285#define RROP_UNROLL_CASE16(p,i) RROP_UNROLL_CASE8(p,(i)+8) RROP_UNROLL_CASE8(p,i)
286#define RROP_UNROLL_CASE32(p,i) RROP_UNROLL_CASE16(p,(i)+16) RROP_UNROLL_CASE16(p,i)
287#define RROP_UNROLL_CASE3(p) RROP_UNROLL_CASE2(p,2) RROP_UNROLL_CASE1(p,1)
288#define RROP_UNROLL_CASE7(p) RROP_UNROLL_CASE4(p,4) RROP_UNROLL_CASE3(p)
289#define RROP_UNROLL_CASE15(p) RROP_UNROLL_CASE8(p,8) RROP_UNROLL_CASE7(p)
290#define RROP_UNROLL_CASE31(p) RROP_UNROLL_CASE16(p,16) RROP_UNROLL_CASE15(p)
291#ifdef LONG64
292#define RROP_UNROLL_CASE63(p) RROP_UNROLL_CASE32(p,32) RROP_UNROLL_CASE31(p)
293#endif /* LONG64 */
294
295#define RROP_UNROLL_LOOP1(p,i) RROP_SOLID((p) + (i));
296#define RROP_UNROLL_LOOP2(p,i) RROP_UNROLL_LOOP1(p,(i)) RROP_UNROLL_LOOP1(p,(i)+1)
297#define RROP_UNROLL_LOOP4(p,i) RROP_UNROLL_LOOP2(p,(i)) RROP_UNROLL_LOOP2(p,(i)+2)
298#define RROP_UNROLL_LOOP8(p,i) RROP_UNROLL_LOOP4(p,(i)) RROP_UNROLL_LOOP4(p,(i)+4)
299#define RROP_UNROLL_LOOP16(p,i) RROP_UNROLL_LOOP8(p,(i)) RROP_UNROLL_LOOP8(p,(i)+8)
300#define RROP_UNROLL_LOOP32(p,i) RROP_UNROLL_LOOP16(p,(i)) RROP_UNROLL_LOOP16(p,(i)+16)
301#ifdef LONG64
302#define RROP_UNROLL_LOOP64(p,i) RROP_UNROLL_LOOP32(p,(i)) RROP_UNROLL_LOOP32(p,(i)+32)
303#endif /* LONG64 */
304
305#if defined (FAST_CONSTANT_OFFSET_MODE) && defined (SHARED_IDCACHE) && (RROP == GXcopy)
306
307#ifdef LONG64
308#define RROP_UNROLL_SHIFT 6
309#define RROP_UNROLL_CASE(p) RROP_UNROLL_CASE63(p)
310#define RROP_UNROLL_LOOP(p) RROP_UNROLL_LOOP64(p,-64)
311#else /* not LONG64 */
312#define RROP_UNROLL_SHIFT 5
313#define RROP_UNROLL_CASE(p) RROP_UNROLL_CASE31(p)
314#define RROP_UNROLL_LOOP(p) RROP_UNROLL_LOOP32(p,-32)
315#endif /* LONG64 */
316#define RROP_UNROLL (1<<RROP_UNROLL_SHIFT)
317#define RROP_UNROLL_MASK (RROP_UNROLL-1)
318
319#define RROP_SPAN(pdst,nmiddle) {\
320 int part = (nmiddle) & RROP_UNROLL_MASK; \
321 (nmiddle) >>= RROP_UNROLL_SHIFT; \
322 (pdst) += part * (sizeof (CfbBits) / sizeof (*pdst)); \
323 switch (part) {\
324 RROP_UNROLL_CASE((CfbBits *) (pdst)) \
325 } \
326 while (--(nmiddle) >= 0) { \
327 (pdst) += RROP_UNROLL * (sizeof (CfbBits) / sizeof (*pdst)); \
328 RROP_UNROLL_LOOP((CfbBits *) (pdst)) \
329 } \
330}
331#else
332#define RROP_SPAN(pdst,nmiddle) \
333 while (--(nmiddle) >= 0) { \
334 RROP_SOLID((CfbBits *) (pdst)); \
335 (pdst) += sizeof (CfbBits) / sizeof (*pdst); \
336 }
337#endif
338
339#if !defined(UNIXCPP) || defined(ANSICPP)
340#define RROP_NAME_CAT(prefix,suffix) prefix##suffix
341#else
342#define RROP_NAME_CAT(prefix,suffix) prefix/**/suffix
343#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