VirtualBox

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

最後變更 在這個檔案從25078是 25078,由 vboxsync 提交於 15 年 前

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

  • 屬性 svn:eol-style 設為 native
檔案大小: 13.6 KB
 
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#ifdef HAVE_DIX_CONFIG_H
29#include <dix-config.h>
30#endif
31
32#ifndef _MERGEROP_H_
33#define _MERGEROP_H_
34
35#ifndef GXcopy
36#include <X11/X.h>
37#endif
38
39typedef struct _mergeRopBits {
40 MfbBits ca1, cx1, ca2, cx2;
41} mergeRopRec, *mergeRopPtr;
42
43extern mergeRopRec mergeRopBits[16];
44extern mergeRopPtr mergeGetRopBits(int i);
45
46#if defined(PPW) && defined(PGSZ) && (PPW != PGSZ) /* cfb */
47#define DeclareMergeRop() MfbBits _ca1 = 0, _cx1 = 0, _ca2 = 0, _cx2 = 0;
48#define DeclarePrebuiltMergeRop() MfbBits _cca, _ccx;
49#if PSZ == 24 /* both for PGSZ == 32 and 64 */
50#define DeclareMergeRop24() \
51 MfbBits _ca1u[4], _cx1u[4], _ca2u[4], _cx2u[4];
52 /* int _unrollidx[3]={0,0,1,2};*/
53#define DeclarePrebuiltMergeRop24() MfbBits _ccau[4], _ccxu[4];
54#endif /* PSZ == 24 */
55#else /* mfb */
56#define DeclareMergeRop() MfbBits _ca1 = 0, _cx1 = 0, _ca2 = 0, _cx2 = 0;
57#define DeclarePrebuiltMergeRop() MfbBits _cca, _ccx;
58#endif
59
60#if defined(PPW) && defined(PGSZ) && (PPW != PGSZ) /* cfb */
61#define InitializeMergeRop(alu,pm) {\
62 MfbBits _pm; \
63 mergeRopPtr _bits; \
64 _pm = PFILL(pm); \
65 _bits = mergeGetRopBits(alu); \
66 _ca1 = _bits->ca1 & _pm; \
67 _cx1 = _bits->cx1 | ~_pm; \
68 _ca2 = _bits->ca2 & _pm; \
69 _cx2 = _bits->cx2 & _pm; \
70}
71#if PSZ == 24
72#if (BITMAP_BIT_ORDER == MSBFirst)
73#define InitializeMergeRop24(alu,pm) {\
74 register int i; \
75 register MfbBits _pm = (pm) & 0xFFFFFF; \
76 mergeRopPtr _bits = mergeGetRopBits(alu); \
77 MfbBits _bits_ca1 = _bits->ca1; \
78 MfbBits _bits_cx1 = _bits->cx1; \
79 MfbBits _bits_ca2 = _bits->ca2; \
80 MfbBits _bits_cx2 = _bits->cx2; \
81 _pm = (_pm << 8) | (_pm >> 16); \
82 for(i = 0; i < 4; i++){ \
83 _ca1u[i] = _bits_ca1 & _pm; \
84 _cx1u[i] = _bits_cx1 | ~_pm; \
85 _ca2u[i] = _bits_ca2 & _pm; \
86 _cx2u[i] = _bits_cx2 & _pm; \
87 _pm = (_pm << 16)|(_pm >> 8); \
88 } \
89}
90#else /*(BITMAP_BIT_ORDER == LSBFirst)*/
91#define InitializeMergeRop24(alu,pm) {\
92 register int i; \
93 register MfbBits _pm = (pm) & cfbmask[0]; \
94 mergeRopPtr _bits = mergeGetRopBits(alu); \
95 MfbBits _bits_ca1 = _bits->ca1 & cfbmask[0]; \
96 MfbBits _bits_cx1 = _bits->cx1 & cfbmask[0]; \
97 MfbBits _bits_ca2 = _bits->ca2 & cfbmask[0]; \
98 MfbBits _bits_cx2 = _bits->cx2 & cfbmask[0]; \
99 _pm |= (_pm << 24); \
100 _bits_ca1 |= (_bits->ca1 << 24); \
101 _bits_cx1 |= (_bits->cx1 << 24); \
102 _bits_ca2 |= (_bits->ca2 << 24); \
103 _bits_cx2 |= (_bits->cx2 << 24); \
104 for(i = 0; i < 4; i++){ \
105 _ca1u[i] = _bits_ca1 & _pm; \
106 _cx1u[i] = _bits_cx1 | ~_pm; \
107 _ca2u[i] = _bits_ca2 & _pm; \
108 _cx2u[i] = _bits_cx2 & _pm; \
109 _pm = (_pm << 16)|(_pm >> 8); \
110 } \
111}
112#endif /*(BITMAP_BIT_ORDER == MSBFirst)*/
113#endif /* PSZ == 24 */
114#else /* mfb */
115#define InitializeMergeRop(alu,pm) {\
116 mergeRopPtr _bits; \
117 _bits = mergeGetRopBits(alu); \
118 _ca1 = _bits->ca1; \
119 _cx1 = _bits->cx1; \
120 _ca2 = _bits->ca2; \
121 _cx2 = _bits->cx2; \
122}
123#endif
124
125/* AND has higher precedence than XOR */
126
127#define DoMergeRop(src, dst) \
128 (((dst) & (((src) & _ca1) ^ _cx1)) ^ (((src) & _ca2) ^ _cx2))
129
130#define DoMergeRop24u(src, dst, i) \
131(((dst) & (((src) & _ca1u[i]) ^ _cx1u[i])) ^ (((src) & _ca2u[i]) ^ _cx2u[i]))
132
133#define DoMaskMergeRop24(src, dst, mask, index) {\
134 register int idx = ((index) & 3)<< 1; \
135 MfbBits _src0 = (src);\
136 MfbBits _src1 = (_src0 & _ca1) ^ _cx1; \
137 MfbBits _src2 = (_src0 & _ca2) ^ _cx2; \
138 *(dst) = (((*(dst)) & cfbrmask[idx]) | (((*(dst)) & cfbmask[idx]) & \
139 (((( _src1 |(~mask))<<cfb24Shift[idx])&cfbmask[idx]) ^ \
140 ((( _src2&(mask))<<cfb24Shift[idx])&cfbmask[idx])))); \
141 idx++; \
142 (dst)++; \
143 *(dst) = (((*(dst)) & cfbrmask[idx]) | (((*(dst)) & cfbmask[idx]) & \
144 ((((_src1 |(~mask))>>cfb24Shift[idx])&cfbmask[idx]) ^ \
145 (((_src2 &(mask))>>cfb24Shift[idx])&cfbmask[idx])))); \
146 (dst)--; \
147 }
148
149#define DoMaskMergeRop(src, dst, mask) \
150 (((dst) & ((((src) & _ca1) ^ _cx1) | ~(mask))) ^ ((((src) & _ca2) ^ _cx2) & (mask)))
151
152#define DoMaskMergeRop24u(src, dst, mask, i) \
153(((dst) & ((((src) & _ca1u[(i)]) ^ _cx1u[(i)]) | ~(mask))) ^ ((((src) & _ca2u[(i)]) ^ _cx2u[(i)]) & (mask)))
154
155#define DoMergeRop24(src,dst,index) {\
156 register int idx = ((index) & 3)<< 1; \
157 MfbBits _src0 = (src);\
158 MfbBits _src1 = (_src0 & _ca1) ^ _cx1; \
159 MfbBits _src2 = (_src0 & _ca2) ^ _cx2; \
160 *(dst) = (((*(dst)) & cfbrmask[idx]) | ((((*(dst)) & cfbmask[idx]) & \
161 ((_src1 << cfb24Shift[idx])&cfbmask[idx])) ^ \
162 ((_src2 << cfb24Shift[idx])&cfbmask[idx]))); \
163 idx++; \
164 (dst)++; \
165 *(dst) = (((*(dst)) & cfbrmask[idx]) | ((((*(dst)) & cfbmask[idx]) & \
166 ((_src1 >> cfb24Shift[idx])&cfbmask[idx])) ^ \
167 ((_src2 >> cfb24Shift[idx])&cfbmask[idx]))); \
168 (dst)--; \
169 }
170
171#define DoPrebuiltMergeRop(dst) (((dst) & _cca) ^ _ccx)
172
173#define DoPrebuiltMergeRop24(dst,index) { \
174 register int idx = ((index) & 3)<< 1; \
175 *(dst) = (((*(dst)) & cfbrmask[idx]) | ((((*(dst)) & cfbmask[idx]) &\
176 (( _cca <<cfb24Shift[idx])&cfbmask[idx])) ^ \
177 (( _ccx <<cfb24Shift[idx])&cfbmask[idx]))); \
178 idx++; \
179 (dst)++; \
180 *(dst) = (((*(dst)) & cfbrmask[idx]) | ((((*(dst)) & cfbmask[idx]) &\
181 (( _cca >>cfb24Shift[idx])&cfbmask[idx])) ^ \
182 (( _ccx >>cfb24Shift[idx])&cfbmask[idx]))); \
183 (dst)--; \
184 }
185
186#define DoMaskPrebuiltMergeRop(dst,mask) \
187 (((dst) & (_cca | ~(mask))) ^ (_ccx & (mask)))
188
189#define PrebuildMergeRop(src) ((_cca = ((src) & _ca1) ^ _cx1), \
190 (_ccx = ((src) & _ca2) ^ _cx2))
191
192#ifndef MROP
193#define MROP 0
194#endif
195
196#define Mclear (1<<GXclear)
197#define Mand (1<<GXand)
198#define MandReverse (1<<GXandReverse)
199#define Mcopy (1<<GXcopy)
200#define MandInverted (1<<GXandInverted)
201#define Mnoop (1<<GXnoop)
202#define Mxor (1<<GXxor)
203#define Mor (1<<GXor)
204#define Mnor (1<<GXnor)
205#define Mequiv (1<<GXequiv)
206#define Minvert (1<<GXinvert)
207#define MorReverse (1<<GXorReverse)
208#define McopyInverted (1<<GXcopyInverted)
209#define MorInverted (1<<GXorInverted)
210#define Mnand (1<<GXnand)
211#define Mset (1<<GXset)
212
213#define MROP_PIXEL24(pix, idx) \
214 (((*(pix) & cfbmask[(idx)<<1]) >> cfb24Shift[(idx)<<1])| \
215 ((*((pix)+1) & cfbmask[((idx)<<1)+1]) << cfb24Shift[((idx)<<1)+1]))
216
217#define MROP_SOLID24P(src,dst,sindex, index) \
218 MROP_SOLID24(MROP_PIXEL24(src,sindex),dst,index)
219
220#define MROP_MASK24P(src,dst,mask,sindex,index) \
221 MROP_MASK24(MROP_PIXEL24(src,sindex),dst,mask,index)
222
223#if (MROP) == Mcopy
224#define MROP_DECLARE()
225#define MROP_DECLARE_REG()
226#define MROP_INITIALIZE(alu,pm)
227#define MROP_SOLID(src,dst) (src)
228#define MROP_SOLID24(src,dst,index) {\
229 register int idx = ((index) & 3)<< 1; \
230 MfbBits _src = (src); \
231 *(dst) = (*(dst) & cfbrmask[idx])|((_src<<cfb24Shift[idx])&cfbmask[idx]); \
232 idx++; \
233 *((dst)+1) = (*((dst)+1) & cfbrmask[idx])|((_src>>cfb24Shift[idx])&cfbmask[idx]); \
234 }
235#define MROP_MASK(src,dst,mask) (((dst) & ~(mask)) | ((src) & (mask)))
236#define MROP_MASK24(src,dst,mask,index) {\
237 register int idx = ((index) & 3)<< 1; \
238 MfbBits _src = (src); \
239 *(dst) = (*(dst) & cfbrmask[idx] &(~(((mask)<< cfb24Shift[idx])&cfbmask[idx])) | \
240 (((_src &(mask))<<cfb24Shift[idx])&cfbmask[idx])); \
241 idx++; \
242 *((dst)+1) = (*((dst)+1) & cfbrmask[idx] &(~(((mask)>>cfb24Shift[idx])&cfbmask[idx])) | \
243 (((_src&(mask))>>cfb24Shift[idx])&cfbmask[idx])); \
244 }
245#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,Copy)
246#endif
247
248#if (MROP) == McopyInverted
249#define MROP_DECLARE()
250#define MROP_DECLARE_REG()
251#define MROP_INITIALIZE(alu,pm)
252#define MROP_SOLID(src,dst) (~(src))
253#define MROP_SOLID24(src,dst,index) {\
254 register int idx = ((index) & 3)<< 1; \
255 MfbBits _src = ~(src); \
256 *(dst) = (*(dst) & cfbrmask[idx])|((_src << cfb24Shift[idx])&cfbmask[idx]); \
257 idx++; \
258 (dst)++; \
259 *(dst) = (*(dst) & cfbrmask[idx])|((_src >>cfb24Shift[idx])&cfbmask[idx]); \
260 (dst)--; \
261 }
262#define MROP_MASK(src,dst,mask) (((dst) & ~(mask)) | ((~(src)) & (mask)))
263#define MROP_MASK24(src,dst,mask,index) {\
264 register int idx = ((index) & 3)<< 1; \
265 MfbBits _src = ~(src); \
266 *(dst) = (*(dst) & cfbrmask[idx] &(~(((mask)<< cfb24Shift[idx])&cfbmask[idx])) | \
267 (((_src &(mask))<<cfb24Shift[idx])&cfbmask[idx])); \
268 idx++; \
269 (dst)++; \
270 *(dst) = (*(dst) & cfbrmask[idx] &(~(((mask)>>cfb24Shift[idx])&cfbmask[idx])) | \
271 ((((_src & (mask))>>cfb24Shift[idx])&cfbmask[idx])); \
272 (dst)--; \
273 }
274#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,CopyInverted)
275#endif
276
277#if (MROP) == Mxor
278#define MROP_DECLARE()
279#define MROP_DECLARE_REG()
280#define MROP_INITIALIZE(alu,pm)
281#define MROP_SOLID(src,dst) ((src) ^ (dst))
282#define MROP_SOLID24(src,dst,index) {\
283 register int idx = ((index) & 3)<< 1; \
284 MfbBits _src = (src); \
285 *(dst) ^= ((_src << cfb24Shift[idx])&cfbmask[idx]); \
286 idx++; \
287 (dst)++; \
288 *(dst) ^= ((_src >>cfb24Shift[idx])&cfbmask[idx]); \
289 (dst)--; \
290 }
291#define MROP_MASK(src,dst,mask) (((src) & (mask)) ^ (dst))
292#define MROP_MASK24(src,dst,mask,index) {\
293 register int idx = ((index) & 3)<< 1; \
294 *(dst) ^= ((((src)&(mask))<<cfb24Shift[idx])&cfbmask[idx]); \
295 idx++; \
296 (dst)++; \
297 *(dst) ^= ((((src)&(mask))>>cfb24Shift[idx])&cfbmask[idx]); \
298 (dst)--; \
299 }
300#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,Xor)
301#endif
302
303#if (MROP) == Mor
304#define MROP_DECLARE()
305#define MROP_DECLARE_REG()
306#define MROP_INITIALIZE(alu,pm)
307#define MROP_SOLID(src,dst) ((src) | (dst))
308#define MROP_SOLID24(src,dst,index) {\
309 register int idx = ((index) & 3)<< 1; \
310 *(dst) |= (((src)<<cfb24Shift[idx])&cfbmask[idx]); \
311 idx++; \
312 (dst)++; \
313 *(dst) |= (((src)>>cfb24Shift[idx])&cfbmask[idx]); \
314 (dst)--; \
315 }
316#define MROP_MASK(src,dst,mask) (((src) & (mask)) | (dst))
317#define MROP_MASK24(src,dst,mask,index) {\
318 register int idx = ((index) & 3)<< 1; \
319 MfbBits _src = (src); \
320 *(dst) |= (((_src &(mask))<<cfb24Shift[idx])&cfbmask[idx]); \
321 idx++; \
322 (dst)++; \
323 *(dst) |= (((_src &(mask))>>cfb24Shift[idx])&cfbmask[idx]); \
324 (dst)--; \
325 }
326#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,Or)
327#endif
328
329#if (MROP) == (Mcopy|Mxor|MandReverse|Mor)
330#define MROP_DECLARE() MfbBits _ca1 = 0, _cx1 = 0;
331#define MROP_DECLARE_REG() register MROP_DECLARE()
332#define MROP_INITIALIZE(alu,pm) { \
333 mergeRopPtr _bits; \
334 _bits = mergeGetRopBits(alu); \
335 _ca1 = _bits->ca1; \
336 _cx1 = _bits->cx1; \
337}
338#define MROP_SOLID(src,dst) \
339 (((dst) & (((src) & _ca1) ^ _cx1)) ^ (src))
340#define MROP_MASK(src,dst,mask) \
341 (((dst) & ((((src) & _ca1) ^ _cx1)) | (~(mask)) ^ ((src) & (mask))))
342#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,CopyXorAndReverseOr)
343#define MROP_PREBUILD(src) PrebuildMergeRop(src)
344#define MROP_PREBUILT_DECLARE() DeclarePrebuiltMergeRop()
345#define MROP_PREBUILT_SOLID(src,dst) DoPrebuiltMergeRop(dst)
346#define MROP_PREBUILT_SOLID24(src,dst,index) DoPrebuiltMergeRop24(dst,index)
347#define MROP_PREBUILT_MASK(src,dst,mask) DoMaskPrebuiltMergeRop(dst,mask)
348#define MROP_PREBUILT_MASK24(src,dst,mask,index) DoMaskPrebuiltMergeRop24(dst,mask,index)
349#endif
350
351#if (MROP) == 0
352#if !defined(PSZ) || (PSZ != 24)
353#define MROP_DECLARE() DeclareMergeRop()
354#define MROP_DECLARE_REG() register DeclareMergeRop()
355#define MROP_INITIALIZE(alu,pm) InitializeMergeRop(alu,pm)
356#define MROP_SOLID(src,dst) DoMergeRop(src,dst)
357#define MROP_MASK(src,dst,mask) DoMaskMergeRop(src, dst, mask)
358#else
359#define MROP_DECLARE() \
360 DeclareMergeRop() \
361 DeclareMergeRop24()
362#define MROP_DECLARE_REG() \
363 register DeclareMergeRop()\
364 DeclareMergeRop24()
365#define MROP_INITIALIZE(alu,pm) \
366 InitializeMergeRop(alu,pm)\
367 InitializeMergeRop24(alu,pm)
368#define MROP_SOLID(src,dst) DoMergeRop24u(src,dst,((int)(&(dst)-pdstBase) % 3))
369#define MROP_MASK(src,dst,mask) DoMaskMergeRop24u(src, dst, mask,((int)(&(dst) - pdstBase)%3))
370#endif
371#define MROP_SOLID24(src,dst,index) DoMergeRop24(src,dst,index)
372#define MROP_MASK24(src,dst,mask,index) DoMaskMergeRop24(src, dst, mask,index)
373#define MROP_NAME(prefix) MROP_NAME_CAT(prefix,General)
374#define MROP_PREBUILD(src) PrebuildMergeRop(src)
375#define MROP_PREBUILT_DECLARE() DeclarePrebuiltMergeRop()
376#define MROP_PREBUILT_SOLID(src,dst) DoPrebuiltMergeRop(dst)
377#define MROP_PREBUILT_SOLID24(src,dst,index) DoPrebuiltMergeRop24(dst,index)
378#define MROP_PREBUILT_MASK(src,dst,mask) DoMaskPrebuiltMergeRop(dst,mask)
379#define MROP_PREBUILT_MASK24(src,dst,mask,index) \
380 DoMaskPrebuiltMergeRop24(dst,mask,index)
381#endif
382
383#ifndef MROP_PREBUILD
384#define MROP_PREBUILD(src)
385#define MROP_PREBUILT_DECLARE()
386#define MROP_PREBUILT_SOLID(src,dst) MROP_SOLID(src,dst)
387#define MROP_PREBUILT_SOLID24(src,dst,index) MROP_SOLID24(src,dst,index)
388#define MROP_PREBUILT_MASK(src,dst,mask) MROP_MASK(src,dst,mask)
389#define MROP_PREBUILT_MASK24(src,dst,mask,index) MROP_MASK24(src,dst,mask,index)
390#endif
391
392#if !defined(UNIXCPP) || defined(ANSICPP)
393#define MROP_NAME_CAT(prefix,suffix) prefix##suffix
394#else
395#define MROP_NAME_CAT(prefix,suffix) prefix/**/suffix
396#endif
397
398#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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