VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.0.1/mergerop.h@ 67129

最後變更 在這個檔案從67129是 51223,由 vboxsync 提交於 11 年 前

Additions/x11/x11include: added header files for X.Org Server 1.0 and 1.1.

  • 屬性 svn:eol-style 設為 native
檔案大小: 13.7 KB
 
1/*
2 * $Xorg: mergerop.h,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $
3 *
4Copyright 1989, 1998 The Open Group
5
6Permission to use, copy, modify, distribute, and sell this software and its
7documentation for any purpose is hereby granted without fee, provided that
8the above copyright notice appear in all copies and that both that
9copyright notice and this permission notice appear in supporting
10documentation.
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of The Open Group shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from The Open Group.
25 *
26 * Author: Keith Packard, MIT X Consortium
27 */
28/* $XFree86: xc/programs/Xserver/mfb/mergerop.h,v 3.13 2001/10/28 03:34:13 tsi Exp $ */
29
30#ifdef HAVE_DIX_CONFIG_H
31#include <dix-config.h>
32#endif
33
34#ifndef _MERGEROP_H_
35#define _MERGEROP_H_
36
37#ifndef GXcopy
38#include <X11/X.h>
39#endif
40
41typedef struct _mergeRopBits {
42 MfbBits ca1, cx1, ca2, cx2;
43} mergeRopRec, *mergeRopPtr;
44
45extern mergeRopRec mergeRopBits[16];
46extern mergeRopPtr mergeGetRopBits(int i);
47
48#if defined(PPW) && defined(PGSZ) && (PPW != PGSZ) /* cfb */
49#define DeclareMergeRop() MfbBits _ca1 = 0, _cx1 = 0, _ca2 = 0, _cx2 = 0;
50#define DeclarePrebuiltMergeRop() MfbBits _cca, _ccx;
51#if PSZ == 24 /* both for PGSZ == 32 and 64 */
52#define DeclareMergeRop24() \
53 MfbBits _ca1u[4], _cx1u[4], _ca2u[4], _cx2u[4];
54 /* int _unrollidx[3]={0,0,1,2};*/
55#define DeclarePrebuiltMergeRop24() MfbBits _ccau[4], _ccxu[4];
56#endif /* PSZ == 24 */
57#else /* mfb */
58#define DeclareMergeRop() MfbBits _ca1 = 0, _cx1 = 0, _ca2 = 0, _cx2 = 0;
59#define DeclarePrebuiltMergeRop() MfbBits _cca, _ccx;
60#endif
61
62#if defined(PPW) && defined(PGSZ) && (PPW != PGSZ) /* cfb */
63#define InitializeMergeRop(alu,pm) {\
64 MfbBits _pm; \
65 mergeRopPtr _bits; \
66 _pm = PFILL(pm); \
67 _bits = mergeGetRopBits(alu); \
68 _ca1 = _bits->ca1 & _pm; \
69 _cx1 = _bits->cx1 | ~_pm; \
70 _ca2 = _bits->ca2 & _pm; \
71 _cx2 = _bits->cx2 & _pm; \
72}
73#if PSZ == 24
74#if (BITMAP_BIT_ORDER == MSBFirst)
75#define InitializeMergeRop24(alu,pm) {\
76 register int i; \
77 register MfbBits _pm = (pm) & 0xFFFFFF; \
78 mergeRopPtr _bits = mergeGetRopBits(alu); \
79 MfbBits _bits_ca1 = _bits->ca1; \
80 MfbBits _bits_cx1 = _bits->cx1; \
81 MfbBits _bits_ca2 = _bits->ca2; \
82 MfbBits _bits_cx2 = _bits->cx2; \
83 _pm = (_pm << 8) | (_pm >> 16); \
84 for(i = 0; i < 4; i++){ \
85 _ca1u[i] = _bits_ca1 & _pm; \
86 _cx1u[i] = _bits_cx1 | ~_pm; \
87 _ca2u[i] = _bits_ca2 & _pm; \
88 _cx2u[i] = _bits_cx2 & _pm; \
89 _pm = (_pm << 16)|(_pm >> 8); \
90 } \
91}
92#else /*(BITMAP_BIT_ORDER == LSBFirst)*/
93#define InitializeMergeRop24(alu,pm) {\
94 register int i; \
95 register MfbBits _pm = (pm) & cfbmask[0]; \
96 mergeRopPtr _bits = mergeGetRopBits(alu); \
97 MfbBits _bits_ca1 = _bits->ca1 & cfbmask[0]; \
98 MfbBits _bits_cx1 = _bits->cx1 & cfbmask[0]; \
99 MfbBits _bits_ca2 = _bits->ca2 & cfbmask[0]; \
100 MfbBits _bits_cx2 = _bits->cx2 & cfbmask[0]; \
101 _pm |= (_pm << 24); \
102 _bits_ca1 |= (_bits->ca1 << 24); \
103 _bits_cx1 |= (_bits->cx1 << 24); \
104 _bits_ca2 |= (_bits->ca2 << 24); \
105 _bits_cx2 |= (_bits->cx2 << 24); \
106 for(i = 0; i < 4; i++){ \
107 _ca1u[i] = _bits_ca1 & _pm; \
108 _cx1u[i] = _bits_cx1 | ~_pm; \
109 _ca2u[i] = _bits_ca2 & _pm; \
110 _cx2u[i] = _bits_cx2 & _pm; \
111 _pm = (_pm << 16)|(_pm >> 8); \
112 } \
113}
114#endif /*(BITMAP_BIT_ORDER == MSBFirst)*/
115#endif /* PSZ == 24 */
116#else /* mfb */
117#define InitializeMergeRop(alu,pm) {\
118 mergeRopPtr _bits; \
119 _bits = mergeGetRopBits(alu); \
120 _ca1 = _bits->ca1; \
121 _cx1 = _bits->cx1; \
122 _ca2 = _bits->ca2; \
123 _cx2 = _bits->cx2; \
124}
125#endif
126
127/* AND has higher precedence than XOR */
128
129#define DoMergeRop(src, dst) \
130 (((dst) & (((src) & _ca1) ^ _cx1)) ^ (((src) & _ca2) ^ _cx2))
131
132#define DoMergeRop24u(src, dst, i) \
133(((dst) & (((src) & _ca1u[i]) ^ _cx1u[i])) ^ (((src) & _ca2u[i]) ^ _cx2u[i]))
134
135#define DoMaskMergeRop24(src, dst, mask, index) {\
136 register int idx = ((index) & 3)<< 1; \
137 MfbBits _src0 = (src);\
138 MfbBits _src1 = (_src0 & _ca1) ^ _cx1; \
139 MfbBits _src2 = (_src0 & _ca2) ^ _cx2; \
140 *(dst) = (((*(dst)) & cfbrmask[idx]) | (((*(dst)) & cfbmask[idx]) & \
141 (((( _src1 |(~mask))<<cfb24Shift[idx])&cfbmask[idx]) ^ \
142 ((( _src2&(mask))<<cfb24Shift[idx])&cfbmask[idx])))); \
143 idx++; \
144 (dst)++; \
145 *(dst) = (((*(dst)) & cfbrmask[idx]) | (((*(dst)) & cfbmask[idx]) & \
146 ((((_src1 |(~mask))>>cfb24Shift[idx])&cfbmask[idx]) ^ \
147 (((_src2 &(mask))>>cfb24Shift[idx])&cfbmask[idx])))); \
148 (dst)--; \
149 }
150
151#define DoMaskMergeRop(src, dst, mask) \
152 (((dst) & ((((src) & _ca1) ^ _cx1) | ~(mask))) ^ ((((src) & _ca2) ^ _cx2) & (mask)))
153
154#define DoMaskMergeRop24u(src, dst, mask, i) \
155(((dst) & ((((src) & _ca1u[(i)]) ^ _cx1u[(i)]) | ~(mask))) ^ ((((src) & _ca2u[(i)]) ^ _cx2u[(i)]) & (mask)))
156
157#define DoMergeRop24(src,dst,index) {\
158 register int idx = ((index) & 3)<< 1; \
159 MfbBits _src0 = (src);\
160 MfbBits _src1 = (_src0 & _ca1) ^ _cx1; \
161 MfbBits _src2 = (_src0 & _ca2) ^ _cx2; \
162 *(dst) = (((*(dst)) & cfbrmask[idx]) | ((((*(dst)) & cfbmask[idx]) & \
163 ((_src1 << cfb24Shift[idx])&cfbmask[idx])) ^ \
164 ((_src2 << cfb24Shift[idx])&cfbmask[idx]))); \
165 idx++; \
166 (dst)++; \
167 *(dst) = (((*(dst)) & cfbrmask[idx]) | ((((*(dst)) & cfbmask[idx]) & \
168 ((_src1 >> cfb24Shift[idx])&cfbmask[idx])) ^ \
169 ((_src2 >> cfb24Shift[idx])&cfbmask[idx]))); \
170 (dst)--; \
171 }
172
173#define DoPrebuiltMergeRop(dst) (((dst) & _cca) ^ _ccx)
174
175#define DoPrebuiltMergeRop24(dst,index) { \
176 register int idx = ((index) & 3)<< 1; \
177 *(dst) = (((*(dst)) & cfbrmask[idx]) | ((((*(dst)) & cfbmask[idx]) &\
178 (( _cca <<cfb24Shift[idx])&cfbmask[idx])) ^ \
179 (( _ccx <<cfb24Shift[idx])&cfbmask[idx]))); \
180 idx++; \
181 (dst)++; \
182 *(dst) = (((*(dst)) & cfbrmask[idx]) | ((((*(dst)) & cfbmask[idx]) &\
183 (( _cca >>cfb24Shift[idx])&cfbmask[idx])) ^ \
184 (( _ccx >>cfb24Shift[idx])&cfbmask[idx]))); \
185 (dst)--; \
186 }
187
188#define DoMaskPrebuiltMergeRop(dst,mask) \
189 (((dst) & (_cca | ~(mask))) ^ (_ccx & (mask)))
190
191#define PrebuildMergeRop(src) ((_cca = ((src) & _ca1) ^ _cx1), \
192 (_ccx = ((src) & _ca2) ^ _cx2))
193
194#ifndef MROP
195#define MROP 0
196#endif
197
198#define Mclear (1<<GXclear)
199#define Mand (1<<GXand)
200#define MandReverse (1<<GXandReverse)
201#define Mcopy (1<<GXcopy)
202#define MandInverted (1<<GXandInverted)
203#define Mnoop (1<<GXnoop)
204#define Mxor (1<<GXxor)
205#define Mor (1<<GXor)
206#define Mnor (1<<GXnor)
207#define Mequiv (1<<GXequiv)
208#define Minvert (1<<GXinvert)
209#define MorReverse (1<<GXorReverse)
210#define McopyInverted (1<<GXcopyInverted)
211#define MorInverted (1<<GXorInverted)
212#define Mnand (1<<GXnand)
213#define Mset (1<<GXset)
214
215#define MROP_PIXEL24(pix, idx) \
216 (((*(pix) & cfbmask[(idx)<<1]) >> cfb24Shift[(idx)<<1])| \
217 ((*((pix)+1) & cfbmask[((idx)<<1)+1]) << cfb24Shift[((idx)<<1)+1]))
218
219#define MROP_SOLID24P(src,dst,sindex, index) \
220 MROP_SOLID24(MROP_PIXEL24(src,sindex),dst,index)
221
222#define MROP_MASK24P(src,dst,mask,sindex,index) \
223 MROP_MASK24(MROP_PIXEL24(src,sindex),dst,mask,index)
224
225#if (MROP) == Mcopy
226#define MROP_DECLARE()
227#define MROP_DECLARE_REG()
228#define MROP_INITIALIZE(alu,pm)
229#define MROP_SOLID(src,dst) (src)
230#define MROP_SOLID24(src,dst,index) {\
231 register int idx = ((index) & 3)<< 1; \
232 MfbBits _src = (src); \
233 *(dst) = (*(dst) & cfbrmask[idx])|((_src<<cfb24Shift[idx])&cfbmask[idx]); \
234 idx++; \
235 *((dst)+1) = (*((dst)+1) & cfbrmask[idx])|((_src>>cfb24Shift[idx])&cfbmask[idx]); \
236 }
237#define MROP_MASK(src,dst,mask) (((dst) & ~(mask)) | ((src) & (mask)))
238#define MROP_MASK24(src,dst,mask,index) {\
239 register int idx = ((index) & 3)<< 1; \
240 MfbBits _src = (src); \
241 *(dst) = (*(dst) & cfbrmask[idx] &(~(((mask)<< cfb24Shift[idx])&cfbmask[idx])) | \
242 (((_src &(mask))<<cfb24Shift[idx])&cfbmask[idx])); \
243 idx++; \
244 *((dst)+1) = (*((dst)+1) & cfbrmask[idx] &(~(((mask)>>cfb24Shift[idx])&cfbmask[idx])) | \
245 (((_src&(mask))>>cfb24Shift[idx])&cfbmask[idx])); \
246 }
247#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,Copy)
248#endif
249
250#if (MROP) == McopyInverted
251#define MROP_DECLARE()
252#define MROP_DECLARE_REG()
253#define MROP_INITIALIZE(alu,pm)
254#define MROP_SOLID(src,dst) (~(src))
255#define MROP_SOLID24(src,dst,index) {\
256 register int idx = ((index) & 3)<< 1; \
257 MfbBits _src = ~(src); \
258 *(dst) = (*(dst) & cfbrmask[idx])|((_src << cfb24Shift[idx])&cfbmask[idx]); \
259 idx++; \
260 (dst)++; \
261 *(dst) = (*(dst) & cfbrmask[idx])|((_src >>cfb24Shift[idx])&cfbmask[idx]); \
262 (dst)--; \
263 }
264#define MROP_MASK(src,dst,mask) (((dst) & ~(mask)) | ((~(src)) & (mask)))
265#define MROP_MASK24(src,dst,mask,index) {\
266 register int idx = ((index) & 3)<< 1; \
267 MfbBits _src = ~(src); \
268 *(dst) = (*(dst) & cfbrmask[idx] &(~(((mask)<< cfb24Shift[idx])&cfbmask[idx])) | \
269 (((_src &(mask))<<cfb24Shift[idx])&cfbmask[idx])); \
270 idx++; \
271 (dst)++; \
272 *(dst) = (*(dst) & cfbrmask[idx] &(~(((mask)>>cfb24Shift[idx])&cfbmask[idx])) | \
273 ((((_src & (mask))>>cfb24Shift[idx])&cfbmask[idx])); \
274 (dst)--; \
275 }
276#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,CopyInverted)
277#endif
278
279#if (MROP) == Mxor
280#define MROP_DECLARE()
281#define MROP_DECLARE_REG()
282#define MROP_INITIALIZE(alu,pm)
283#define MROP_SOLID(src,dst) ((src) ^ (dst))
284#define MROP_SOLID24(src,dst,index) {\
285 register int idx = ((index) & 3)<< 1; \
286 MfbBits _src = (src); \
287 *(dst) ^= ((_src << cfb24Shift[idx])&cfbmask[idx]); \
288 idx++; \
289 (dst)++; \
290 *(dst) ^= ((_src >>cfb24Shift[idx])&cfbmask[idx]); \
291 (dst)--; \
292 }
293#define MROP_MASK(src,dst,mask) (((src) & (mask)) ^ (dst))
294#define MROP_MASK24(src,dst,mask,index) {\
295 register int idx = ((index) & 3)<< 1; \
296 *(dst) ^= ((((src)&(mask))<<cfb24Shift[idx])&cfbmask[idx]); \
297 idx++; \
298 (dst)++; \
299 *(dst) ^= ((((src)&(mask))>>cfb24Shift[idx])&cfbmask[idx]); \
300 (dst)--; \
301 }
302#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,Xor)
303#endif
304
305#if (MROP) == Mor
306#define MROP_DECLARE()
307#define MROP_DECLARE_REG()
308#define MROP_INITIALIZE(alu,pm)
309#define MROP_SOLID(src,dst) ((src) | (dst))
310#define MROP_SOLID24(src,dst,index) {\
311 register int idx = ((index) & 3)<< 1; \
312 *(dst) |= (((src)<<cfb24Shift[idx])&cfbmask[idx]); \
313 idx++; \
314 (dst)++; \
315 *(dst) |= (((src)>>cfb24Shift[idx])&cfbmask[idx]); \
316 (dst)--; \
317 }
318#define MROP_MASK(src,dst,mask) (((src) & (mask)) | (dst))
319#define MROP_MASK24(src,dst,mask,index) {\
320 register int idx = ((index) & 3)<< 1; \
321 MfbBits _src = (src); \
322 *(dst) |= (((_src &(mask))<<cfb24Shift[idx])&cfbmask[idx]); \
323 idx++; \
324 (dst)++; \
325 *(dst) |= (((_src &(mask))>>cfb24Shift[idx])&cfbmask[idx]); \
326 (dst)--; \
327 }
328#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,Or)
329#endif
330
331#if (MROP) == (Mcopy|Mxor|MandReverse|Mor)
332#define MROP_DECLARE() MfbBits _ca1 = 0, _cx1 = 0;
333#define MROP_DECLARE_REG() register MROP_DECLARE()
334#define MROP_INITIALIZE(alu,pm) { \
335 mergeRopPtr _bits; \
336 _bits = mergeGetRopBits(alu); \
337 _ca1 = _bits->ca1; \
338 _cx1 = _bits->cx1; \
339}
340#define MROP_SOLID(src,dst) \
341 (((dst) & (((src) & _ca1) ^ _cx1)) ^ (src))
342#define MROP_MASK(src,dst,mask) \
343 (((dst) & ((((src) & _ca1) ^ _cx1)) | (~(mask)) ^ ((src) & (mask))))
344#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,CopyXorAndReverseOr)
345#define MROP_PREBUILD(src) PrebuildMergeRop(src)
346#define MROP_PREBUILT_DECLARE() DeclarePrebuiltMergeRop()
347#define MROP_PREBUILT_SOLID(src,dst) DoPrebuiltMergeRop(dst)
348#define MROP_PREBUILT_SOLID24(src,dst,index) DoPrebuiltMergeRop24(dst,index)
349#define MROP_PREBUILT_MASK(src,dst,mask) DoMaskPrebuiltMergeRop(dst,mask)
350#define MROP_PREBUILT_MASK24(src,dst,mask,index) DoMaskPrebuiltMergeRop24(dst,mask,index)
351#endif
352
353#if (MROP) == 0
354#if !defined(PSZ) || (PSZ != 24)
355#define MROP_DECLARE() DeclareMergeRop()
356#define MROP_DECLARE_REG() register DeclareMergeRop()
357#define MROP_INITIALIZE(alu,pm) InitializeMergeRop(alu,pm)
358#define MROP_SOLID(src,dst) DoMergeRop(src,dst)
359#define MROP_MASK(src,dst,mask) DoMaskMergeRop(src, dst, mask)
360#else
361#define MROP_DECLARE() \
362 DeclareMergeRop() \
363 DeclareMergeRop24()
364#define MROP_DECLARE_REG() \
365 register DeclareMergeRop()\
366 DeclareMergeRop24()
367#define MROP_INITIALIZE(alu,pm) \
368 InitializeMergeRop(alu,pm)\
369 InitializeMergeRop24(alu,pm)
370#define MROP_SOLID(src,dst) DoMergeRop24u(src,dst,((int)(&(dst)-pdstBase) % 3))
371#define MROP_MASK(src,dst,mask) DoMaskMergeRop24u(src, dst, mask,((int)(&(dst) - pdstBase)%3))
372#endif
373#define MROP_SOLID24(src,dst,index) DoMergeRop24(src,dst,index)
374#define MROP_MASK24(src,dst,mask,index) DoMaskMergeRop24(src, dst, mask,index)
375#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,General)
376#define MROP_PREBUILD(src) PrebuildMergeRop(src)
377#define MROP_PREBUILT_DECLARE() DeclarePrebuiltMergeRop()
378#define MROP_PREBUILT_SOLID(src,dst) DoPrebuiltMergeRop(dst)
379#define MROP_PREBUILT_SOLID24(src,dst,index) DoPrebuiltMergeRop24(dst,index)
380#define MROP_PREBUILT_MASK(src,dst,mask) DoMaskPrebuiltMergeRop(dst,mask)
381#define MROP_PREBUILT_MASK24(src,dst,mask,index) \
382 DoMaskPrebuiltMergeRop24(dst,mask,index)
383#endif
384
385#ifndef MROP_PREBUILD
386#define MROP_PREBUILD(src)
387#define MROP_PREBUILT_DECLARE()
388#define MROP_PREBUILT_SOLID(src,dst) MROP_SOLID(src,dst)
389#define MROP_PREBUILT_SOLID24(src,dst,index) MROP_SOLID24(src,dst,index)
390#define MROP_PREBUILT_MASK(src,dst,mask) MROP_MASK(src,dst,mask)
391#define MROP_PREBUILT_MASK24(src,dst,mask,index) MROP_MASK24(src,dst,mask,index)
392#endif
393
394#if !defined(UNIXCPP) || defined(ANSICPP)
395#define MROP_NAME_CAT(prefix,suffix) prefix##suffix
396#else
397#define MROP_NAME_CAT(prefix,suffix) prefix/**/suffix
398#endif
399
400#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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