VirtualBox

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

Last change on this file since 43272 was 43272, checked in by vboxsync, 12 years ago

Additions/x11: more original X server headers.

  • Property svn:eol-style set to native
File size: 13.0 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)(gc)->devPrivates[cfbGCPrivateIndex].ptr))
39
40#ifndef RROP
41#define RROP GXset
42#endif
43
44#if RROP == GXcopy
45#if PSZ == 24
46#define RROP_DECLARE register CfbBits rrop_xor; \
47 CfbBits piQxelXor[3], spiQxelXor[8];
48#define RROP_FETCH_GCPRIV(devPriv) rrop_xor = (devPriv)->xor; \
49 spiQxelXor[0] = rrop_xor & 0xFFFFFF; \
50 spiQxelXor[2] = rrop_xor << 24; \
51 spiQxelXor[3] = (rrop_xor & 0xFFFF00)>> 8; \
52 spiQxelXor[4] = rrop_xor << 16; \
53 spiQxelXor[5] = (rrop_xor & 0xFF0000)>> 16; \
54 spiQxelXor[6] = rrop_xor << 8; \
55 spiQxelXor[1] = spiQxelXor[7] = 0; \
56 piQxelXor[0] = (rrop_xor & 0xFFFFFF)|(rrop_xor << 24); \
57 piQxelXor[1] = (rrop_xor << 16)|((rrop_xor & 0xFFFF00)>> 8); \
58 piQxelXor[2] = (rrop_xor << 8)|((rrop_xor & 0xFF0000)>> 16);
59#define RROP_SOLID24(dst,index) {\
60 register int idx = ((index) & 3)<< 1; \
61 *(dst) = (*(dst) & cfbrmask[idx])|spiQxelXor[idx]; \
62 if (idx == 2 || idx == 4){ \
63 idx++; \
64 *((dst)+1) = (*((dst)+1) & cfbrmask[idx])|spiQxelXor[idx]; \
65 } \
66 }
67#define RROP_SOLID(dst, idx) \
68 (*(dst) = piQxelXor[(idx)])
69#define RROP_SOLID_MASK(dst,mask,idx) \
70 (*(dst) = (*(dst) & ~(mask))|(piQxelXor[(idx)] & (mask)))
71#define RROP_UNDECLARE (void)piQxelXor; (void)spiQxelXor;
72#else
73#define RROP_FETCH_GCPRIV(devPriv) rrop_xor = (devPriv)->xor;
74#define RROP_DECLARE register CfbBits rrop_xor;
75#define RROP_SOLID(dst) (*(dst) = (rrop_xor))
76#define RROP_SOLID_MASK(dst,mask) (*(dst) = (*(dst) & ~(mask)) | ((rrop_xor) & (mask)))
77#define RROP_UNDECLARE
78#endif
79#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,Copy)
80#endif /* GXcopy */
81
82#if RROP == GXxor
83#if PSZ == 24
84#define RROP_DECLARE register CfbBits rrop_xor; \
85 CfbBits piQxelXor[3], spiQxelXor[8];
86#define RROP_FETCH_GCPRIV(devPriv) rrop_xor = (devPriv)->xor; \
87 spiQxelXor[0] = rrop_xor & 0xFFFFFF; \
88 spiQxelXor[2] = rrop_xor << 24; \
89 spiQxelXor[3] = (rrop_xor & 0xFFFF00)>> 8; \
90 spiQxelXor[4] = rrop_xor << 16; \
91 spiQxelXor[5] = (rrop_xor & 0xFF0000)>> 16; \
92 spiQxelXor[6] = rrop_xor << 8; \
93 spiQxelXor[1] = spiQxelXor[7] = 0; \
94 piQxelXor[0] = (rrop_xor & 0xFFFFFF)|(rrop_xor << 24); \
95 piQxelXor[1] = (rrop_xor << 16)|((rrop_xor & 0xFFFF00)>> 8); \
96 piQxelXor[2] = (rrop_xor << 8)|((rrop_xor & 0xFF0000)>> 16);
97#define RROP_SOLID24(dst,index) {\
98 register int idx = ((index) & 3)<< 1; \
99 *(dst) ^= spiQxelXor[idx]; \
100 if (idx == 2 || idx == 4) \
101 *((dst)+1) ^= spiQxelXor[idx+1]; \
102 }
103#define RROP_SOLID(dst,idx) \
104 (*(dst) ^= piQxelXor[(idx)])
105#define RROP_SOLID_MASK(dst,mask,idx) \
106 (*(dst) ^= (piQxelXor[(idx)] & (mask)))
107#define RROP_UNDECLARE (void)piQxelXor; (void)spiQxelXor;
108#else
109#define RROP_DECLARE register CfbBits rrop_xor;
110#define RROP_FETCH_GCPRIV(devPriv) rrop_xor = (devPriv)->xor;
111#define RROP_SOLID(dst) (*(dst) ^= (rrop_xor))
112#define RROP_SOLID_MASK(dst,mask) (*(dst) ^= ((rrop_xor) & (mask)))
113#define RROP_UNDECLARE
114#endif
115#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,Xor)
116#endif /* GXxor */
117
118#if RROP == GXand
119#if PSZ == 24
120#define RROP_DECLARE register CfbBits rrop_and; \
121 CfbBits piQxelAnd[3], spiQxelAnd[6];
122#define RROP_FETCH_GCPRIV(devPriv) rrop_and = (devPriv)->and; \
123 spiQxelAnd[0] = (rrop_and & 0xFFFFFF) | 0xFF000000; \
124 spiQxelAnd[2] = (rrop_and << 24) | 0xFFFFFF; \
125 spiQxelAnd[3] = ((rrop_and & 0xFFFF00)>> 8) | 0xFFFF0000; \
126 spiQxelAnd[4] = (rrop_and << 16) | 0xFFFF; \
127 spiQxelAnd[5] = ((rrop_and & 0xFF0000)>> 16) | 0xFFFFFF00; \
128 spiQxelAnd[1] = (rrop_and << 8) | 0xFF; \
129 piQxelAnd[0] = (rrop_and & 0xFFFFFF)|(rrop_and << 24); \
130 piQxelAnd[1] = (rrop_and << 16)|((rrop_and & 0xFFFF00)>> 8); \
131 piQxelAnd[2] = (rrop_and << 8)|((rrop_and & 0xFF0000)>> 16);
132#define RROP_SOLID24(dst,index) {\
133 switch((index) & 3){ \
134 case 0: \
135 *(dst) &= spiQxelAnd[0]; \
136 break; \
137 case 3: \
138 *(dst) &= spiQxelAnd[1]; \
139 break; \
140 case 1: \
141 *(dst) &= spiQxelAnd[2]; \
142 *((dst)+1) &= spiQxelAnd[3]; \
143 break; \
144 case 2: \
145 *(dst) &= spiQxelAnd[4]; \
146 *((dst)+1) &= spiQxelAnd[5]; \
147 break; \
148 } \
149 }
150#define RROP_SOLID(dst,idx) \
151 (*(dst) &= piQxelAnd[(idx)])
152#define RROP_SOLID_MASK(dst,mask,idx) \
153 (*(dst) &= (piQxelAnd[(idx)] | ~(mask)))
154#define RROP_UNDECLARE (void)piQxelAnd; (void)spiQxelAnd;
155#else
156#define RROP_DECLARE register CfbBits rrop_and;
157#define RROP_FETCH_GCPRIV(devPriv) rrop_and = (devPriv)->and;
158#define RROP_SOLID(dst) (*(dst) &= (rrop_and))
159#define RROP_SOLID_MASK(dst,mask) (*(dst) &= ((rrop_and) | ~(mask)))
160#define RROP_UNDECLARE
161#endif
162#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,And)
163#endif /* GXand */
164
165#if RROP == GXor
166#if PSZ == 24
167#define RROP_DECLARE register CfbBits rrop_or; \
168 CfbBits piQxelOr[3], spiQxelOr[6];
169#define RROP_FETCH_GCPRIV(devPriv) rrop_or = (devPriv)->xor; \
170 spiQxelOr[0] = rrop_or & 0xFFFFFF; \
171 spiQxelOr[1] = rrop_or << 24; \
172 spiQxelOr[2] = rrop_or << 16; \
173 spiQxelOr[3] = rrop_or << 8; \
174 spiQxelOr[4] = (rrop_or & 0xFFFF00)>> 8; \
175 spiQxelOr[5] = (rrop_or & 0xFF0000)>> 16; \
176 piQxelOr[0] = (rrop_or & 0xFFFFFF)|(rrop_or << 24); \
177 piQxelOr[1] = (rrop_or << 16)|((rrop_or & 0xFFFF00)>> 8); \
178 piQxelOr[2] = (rrop_or << 8)|((rrop_or & 0xFF0000)>> 16);
179#define RROP_SOLID24(dst,index) {\
180 switch((index) & 3){ \
181 case 0: \
182 *(dst) |= spiQxelOr[0]; \
183 break; \
184 case 3: \
185 *(dst) |= spiQxelOr[3]; \
186 break; \
187 case 1: \
188 *(dst) |= spiQxelOr[1]; \
189 *((dst)+1) |= spiQxelOr[4]; \
190 break; \
191 case 2: \
192 *(dst) |= spiQxelOr[2]; \
193 *((dst)+1) |= spiQxelOr[5]; \
194 break; \
195 } \
196 }
197#define RROP_SOLID(dst,idx) \
198 (*(dst) |= piQxelOr[(idx)])
199#define RROP_SOLID_MASK(dst,mask,idx) \
200 (*(dst) |= (piQxelOr[(idx)] & (mask)))
201#define RROP_UNDECLARE (void)piQxelOr; (void)spiQxelOr;
202#else
203#define RROP_DECLARE register CfbBits rrop_or;
204#define RROP_FETCH_GCPRIV(devPriv) rrop_or = (devPriv)->xor;
205#define RROP_SOLID(dst) (*(dst) |= (rrop_or))
206#define RROP_SOLID_MASK(dst,mask) (*(dst) |= ((rrop_or) & (mask)))
207#define RROP_UNDECLARE
208#endif
209#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,Or)
210#endif /* GXor */
211
212#if RROP == GXnoop
213#define RROP_DECLARE
214#define RROP_FETCH_GCPRIV(devPriv)
215#define RROP_SOLID(dst)
216#define RROP_SOLID_MASK(dst,mask)
217#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,Noop)
218#define RROP_UNDECLARE
219#endif /* GXnoop */
220
221#if RROP == GXset
222#if PSZ == 24
223#define RROP_DECLARE register CfbBits rrop_and, rrop_xor; \
224 CfbBits piQxelAnd[3], piQxelXor[3], spiQxelAnd[6], spiQxelXor[6];
225#define RROP_FETCH_GCPRIV(devPriv) rrop_and = (devPriv)->and; \
226 rrop_xor = (devPriv)->xor; \
227 spiQxelXor[0] = rrop_xor & 0xFFFFFF; \
228 spiQxelXor[1] = rrop_xor << 24; \
229 spiQxelXor[2] = rrop_xor << 16; \
230 spiQxelXor[3] = rrop_xor << 8; \
231 spiQxelXor[4] = (rrop_xor & 0xFFFF00)>> 8; \
232 spiQxelXor[5] = (rrop_xor & 0xFF0000)>> 16; \
233 spiQxelAnd[0] = (rrop_and & 0xFFFFFF) | 0xFF000000; \
234 spiQxelAnd[1] = (rrop_and << 24) | 0xFFFFFF; \
235 spiQxelAnd[2] = (rrop_and << 16) | 0xFFFF; \
236 spiQxelAnd[3] = (rrop_and << 8) | 0xFF; \
237 spiQxelAnd[4] = ((rrop_and & 0xFFFF00)>> 8) | 0xFFFF0000; \
238 spiQxelAnd[5] = ((rrop_and & 0xFF0000)>> 16) | 0xFFFFFF00; \
239 piQxelAnd[0] = (rrop_and & 0xFFFFFF)|(rrop_and << 24); \
240 piQxelAnd[1] = (rrop_and << 16)|((rrop_and & 0xFFFF00)>> 8); \
241 piQxelAnd[2] = (rrop_and << 8)|((rrop_and & 0xFF0000)>> 16); \
242 piQxelXor[0] = (rrop_xor & 0xFFFFFF)|(rrop_xor << 24); \
243 piQxelXor[1] = (rrop_xor << 16)|((rrop_xor & 0xFFFF00)>> 8); \
244 piQxelXor[2] = (rrop_xor << 8)|((rrop_xor & 0xFF0000)>> 16);
245#define RROP_SOLID24(dst,index) {\
246 switch((index) & 3){ \
247 case 0: \
248 *(dst) = ((*(dst) & (piQxelAnd[0] |0xFF000000))^(piQxelXor[0] & 0xFFFFFF)); \
249 break; \
250 case 3: \
251 *(dst) = ((*(dst) & (piQxelAnd[2]|0xFF))^(piQxelXor[2] & 0xFFFFFF00)); \
252 break; \
253 case 1: \
254 *(dst) = ((*(dst) & (piQxelAnd[0]|0xFFFFFF))^(piQxelXor[0] & 0xFF000000)); \
255 *((dst)+1) = ((*((dst)+1) & (piQxelAnd[1]|0xFFFF0000))^(piQxelXor[1] & 0xFFFF)); \
256 break; \
257 case 2: \
258 *(dst) = ((*(dst) & (piQxelAnd[1]|0xFFFF))^(piQxelXor[1] & 0xFFFF0000)); \
259 *((dst)+1) = ((*((dst)+1) & (piQxelAnd[2]|0xFFFFFF00))^(piQxelXor[2] & 0xFF)); \
260 break; \
261 } \
262 }
263#define RROP_SOLID(dst,idx) \
264 (*(dst) = DoRRop (*(dst), piQxelAnd[(idx)], piQxelXor[(idx)]))
265#define RROP_SOLID_MASK(dst,mask,idx) \
266 (*(dst) = DoMaskRRop (*(dst), piQxelAnd[(idx)], piQxelXor[(idx)], (mask)))
267#define RROP_UNDECLARE (void)piQxelAnd; (void)piQxelXor; \
268 (void)spiQxelAnd; (void)spiQxelXor;
269#else
270#define RROP_DECLARE register CfbBits rrop_and, rrop_xor;
271#define RROP_FETCH_GCPRIV(devPriv) rrop_and = (devPriv)->and; \
272 rrop_xor = (devPriv)->xor;
273#define RROP_SOLID(dst) (*(dst) = DoRRop (*(dst), rrop_and, rrop_xor))
274#define RROP_SOLID_MASK(dst,mask) (*(dst) = DoMaskRRop (*(dst), rrop_and, rrop_xor, (mask)))
275#define RROP_UNDECLARE
276#endif
277#define RROP_NAME(prefix) RROP_NAME_CAT(prefix,General)
278#endif /* GXset */
279
280#define RROP_UNROLL_CASE1(p,i) case (i): RROP_SOLID((p) - (i));
281#define RROP_UNROLL_CASE2(p,i) RROP_UNROLL_CASE1(p,(i)+1) RROP_UNROLL_CASE1(p,i)
282#define RROP_UNROLL_CASE4(p,i) RROP_UNROLL_CASE2(p,(i)+2) RROP_UNROLL_CASE2(p,i)
283#define RROP_UNROLL_CASE8(p,i) RROP_UNROLL_CASE4(p,(i)+4) RROP_UNROLL_CASE4(p,i)
284#define RROP_UNROLL_CASE16(p,i) RROP_UNROLL_CASE8(p,(i)+8) RROP_UNROLL_CASE8(p,i)
285#define RROP_UNROLL_CASE32(p,i) RROP_UNROLL_CASE16(p,(i)+16) RROP_UNROLL_CASE16(p,i)
286#define RROP_UNROLL_CASE3(p) RROP_UNROLL_CASE2(p,2) RROP_UNROLL_CASE1(p,1)
287#define RROP_UNROLL_CASE7(p) RROP_UNROLL_CASE4(p,4) RROP_UNROLL_CASE3(p)
288#define RROP_UNROLL_CASE15(p) RROP_UNROLL_CASE8(p,8) RROP_UNROLL_CASE7(p)
289#define RROP_UNROLL_CASE31(p) RROP_UNROLL_CASE16(p,16) RROP_UNROLL_CASE15(p)
290#ifdef LONG64
291#define RROP_UNROLL_CASE63(p) RROP_UNROLL_CASE32(p,32) RROP_UNROLL_CASE31(p)
292#endif /* LONG64 */
293
294#define RROP_UNROLL_LOOP1(p,i) RROP_SOLID((p) + (i));
295#define RROP_UNROLL_LOOP2(p,i) RROP_UNROLL_LOOP1(p,(i)) RROP_UNROLL_LOOP1(p,(i)+1)
296#define RROP_UNROLL_LOOP4(p,i) RROP_UNROLL_LOOP2(p,(i)) RROP_UNROLL_LOOP2(p,(i)+2)
297#define RROP_UNROLL_LOOP8(p,i) RROP_UNROLL_LOOP4(p,(i)) RROP_UNROLL_LOOP4(p,(i)+4)
298#define RROP_UNROLL_LOOP16(p,i) RROP_UNROLL_LOOP8(p,(i)) RROP_UNROLL_LOOP8(p,(i)+8)
299#define RROP_UNROLL_LOOP32(p,i) RROP_UNROLL_LOOP16(p,(i)) RROP_UNROLL_LOOP16(p,(i)+16)
300#ifdef LONG64
301#define RROP_UNROLL_LOOP64(p,i) RROP_UNROLL_LOOP32(p,(i)) RROP_UNROLL_LOOP32(p,(i)+32)
302#endif /* LONG64 */
303
304#if defined (FAST_CONSTANT_OFFSET_MODE) && defined (SHARED_IDCACHE) && (RROP == GXcopy)
305
306#ifdef LONG64
307#define RROP_UNROLL_SHIFT 6
308#define RROP_UNROLL_CASE(p) RROP_UNROLL_CASE63(p)
309#define RROP_UNROLL_LOOP(p) RROP_UNROLL_LOOP64(p,-64)
310#else /* not LONG64 */
311#define RROP_UNROLL_SHIFT 5
312#define RROP_UNROLL_CASE(p) RROP_UNROLL_CASE31(p)
313#define RROP_UNROLL_LOOP(p) RROP_UNROLL_LOOP32(p,-32)
314#endif /* LONG64 */
315#define RROP_UNROLL (1<<RROP_UNROLL_SHIFT)
316#define RROP_UNROLL_MASK (RROP_UNROLL-1)
317
318#define RROP_SPAN(pdst,nmiddle) {\
319 int part = (nmiddle) & RROP_UNROLL_MASK; \
320 (nmiddle) >>= RROP_UNROLL_SHIFT; \
321 (pdst) += part * (sizeof (CfbBits) / sizeof (*pdst)); \
322 switch (part) {\
323 RROP_UNROLL_CASE((CfbBits *) (pdst)) \
324 } \
325 while (--(nmiddle) >= 0) { \
326 (pdst) += RROP_UNROLL * (sizeof (CfbBits) / sizeof (*pdst)); \
327 RROP_UNROLL_LOOP((CfbBits *) (pdst)) \
328 } \
329}
330#else
331#define RROP_SPAN(pdst,nmiddle) \
332 while (--(nmiddle) >= 0) { \
333 RROP_SOLID((CfbBits *) (pdst)); \
334 (pdst) += sizeof (CfbBits) / sizeof (*pdst); \
335 }
336#endif
337
338#if !defined(UNIXCPP) || defined(ANSICPP)
339#define RROP_NAME_CAT(prefix,suffix) prefix##suffix
340#else
341#define RROP_NAME_CAT(prefix,suffix) prefix/**/suffix
342#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