VirtualBox

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

最後變更 在這個檔案從61386是 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/* $XFree86$ */
2/* Modified nov 94 by Martin Schaller ([email protected]) for use with
3interleaved planes */
4
5#define INTER_PIXGRP unsigned short
6
7#define INTER_PGSZ 16
8#define INTER_PGSZB 2
9#define INTER_PPG 16
10#define INTER_PPGMSK 0xffff
11#define INTER_PLST 15
12#define INTER_PIM 15
13#define INTER_PGSH 4
14#define INTER_PMSK ((1 << (INTER_PLANES)) - 1)
15
16extern INTER_PIXGRP iplmask[];
17extern INTER_PIXGRP iplstarttab[];
18extern INTER_PIXGRP iplendtab[];
19extern INTER_PIXGRP iplstartpartial[];
20extern INTER_PIXGRP iplendpartial[];
21
22#define MFB_PSZ 1
23
24#define INTER_NEXT(x) ((x) + INTER_PLANES)
25#define INTER_NEXT_GROUP(x) (x) += INTER_PLANES
26#define INTER_PREV_GROUP(x) (x) -= INTER_PLANES
27
28#define _I(x) (((unsigned long *) (x))[_INDEX])
29#define _IG(x) ((x)[_INDEX])
30
31#define INTER_DECLAREG(x) INTER_PIXGRP x
32#define INTER_DECLAREGP(x) INTER_PIXGRP x[INTER_PLANES]
33
34#define INTER_DECLARERRAX(x) INTER_PIXGRP *(x)
35#define INTER_DECLARERRAXP(x) INTER_PIXGRP x[INTER_PLANES]
36
37/* and |= PLANE_FILL(~fg), or &= PLANE_FILL(fg) */
38#define INTER_ANDXOR_PM(pm, and, xor) \
39 PLANE_TIMESG( \
40 if (!(pm & INTER_PLANE(_INDEX))) { \
41 _IG(and) = INTER_PPGMSK; \
42 _IG(xor) = 0; \
43 })
44
45#ifdef HAVE_DIX_CONFIG_H
46#include <dix-config.h>
47#endif
48
49#if INTER_PLANES == 2
50
51#define PLANE_TIMESCONDG(x) \
52 ({ int _INDEX; \
53 int _ret; \
54 _ret=(_INDEX=0, (x)) && \
55 (_INDEX=1, (x)) && \
56 _ret; \
57 })
58
59#define PLANE_TIMESCOND(x) \
60 ({ int _INDEX; \
61 (_INDEX=0, x) \
62 })
63
64#define PLANE_TIMESG(x) \
65 { int _INDEX; \
66 _INDEX=0; x; \
67 _INDEX=1; x; \
68 }
69
70#define PLANE_TIMES(x) \
71 { int _INDEX; \
72 _INDEX=0; x; \
73 }
74
75#elif INTER_PLANES == 4
76
77#define PLANE_TIMESCONDG(x) \
78 ({ int _INDEX; \
79 int _ret; \
80 _ret=(_INDEX=0, (x)) && \
81 (_INDEX=1, (x)) && \
82 (_INDEX=2, (x)) && \
83 (_INDEX=3, (x)); \
84 _ret; \
85 })
86
87#define PLANE_TIMESCOND(x) \
88 ({ int _INDEX; \
89 ((_INDEX=0, x) && \
90 (_INDEX=1, x)) \
91 })
92
93#define PLANE_TIMESG(x) \
94 { int _INDEX; \
95 _INDEX=0; x; \
96 _INDEX=1; x; \
97 _INDEX=2; x; \
98 _INDEX=3; x; \
99 }
100
101#define PLANE_TIMES(x) \
102 { int _INDEX; \
103 _INDEX=0; x; \
104 _INDEX=1; x; \
105 }
106
107#elif INTER_PLANES == 8
108
109#define PLANE_TIMESCONDG(x) \
110 ({ int _INDEX; \
111 int _ret; \
112 _ret=((_INDEX=0, (x)) && \
113 (_INDEX=1, (x)) && \
114 (_INDEX=2, (x)) && \
115 (_INDEX=3, (x)) && \
116 (_INDEX=4, (x)) && \
117 (_INDEX=5, (x)) && \
118 (_INDEX=6, (x)) && \
119 (_INDEX=7, (x))); \
120 _ret; \
121 })
122
123#define PLANE_TIMESCOND(x) \
124 ({ int _INDEX; \
125 ((_INDEX=0, x) && \
126 (_INDEX=1, x) && \
127 (_INDEX=2, x) && \
128 (_INDEX=3, x)) \
129 })
130
131#define PLANE_TIMESG(x) \
132 { int _INDEX; \
133 _INDEX=0; x; \
134 _INDEX=1; x; \
135 _INDEX=2; x; \
136 _INDEX=3; x; \
137 _INDEX=4; x; \
138 _INDEX=5; x; \
139 _INDEX=6; x; \
140 _INDEX=7; x; \
141 }
142
143#define PLANE_TIMES(x) \
144 { int _INDEX; \
145 _INDEX=0; x; \
146 _INDEX=1; x; \
147 _INDEX=2; x; \
148 _INDEX=3; x; \
149 }
150
151#endif
152
153/* src = 0 */
154#define INTER_IS_CLR(src) \
155 PLANE_TIMESCONDG(_IG(src) == 0)
156
157/* src = PPGMSK ? */
158#define INTER_IS_SET(src) \
159 PLANE_TIMESCONDG(_IG(src) == INTER_PPGMSK)
160
161/* (src1 ^ scr2) = PPGMSK ? */
162#define INTER_IS_XOR_SET(src1, src2) \
163 PLANE_TIMESCONDG((_IG(src1) ^ _IG(src2)) == INTER_PPGMSK)
164
165/* dst = ~src */
166#define INTER_NOT(src, dst) \
167 PLANE_TIMES(_I(dst) = ~_I(src))
168
169/* dst = 0 */
170#define INTER_CLR(dst) \
171 PLANE_TIMES(_I(dst) = 0)
172
173/* dst = PPGMSK */
174#define INTER_SET(dst) \
175 PLANE_TIMESG(_IG(dst) = INTER_PPGMSK)
176
177/* dst = src */
178#define INTER_COPY(src,dst) \
179 PLANE_TIMES(_I(dst) = _I(src))
180
181/* dst2 = (dst & ~mask) | (src & mask) */
182#define INTER_COPYM(src,dst,mask,dst2) \
183 PLANE_TIMESG( \
184 _IG(dst2) = (_IG(dst) & ~mask) | (_IG(src) & mask) \
185 )
186
187/* dst2 = dst ^ src */
188#define INTER_XOR(src,dst,dst2) \
189 PLANE_TIMES(_I(dst2) = _I(dst) ^ _I(src))
190
191/* dst2 = dst ^ (src & mask) */
192#define INTER_XORM(src,dst,mask,dst2) \
193 PLANE_TIMESG(_IG(dst2) = _IG(dst) ^ (_IG(src) & (mask)))
194
195/* dst2 = dst & src */
196#define INTER_AND(src,dst,dst2) \
197 PLANE_TIMES(_I(dst2) = _I(dst) & _I(src))
198
199/* dst2 = dst & (src | ~mask) */
200#define INTER_ANDM(mask,src,dst,dst2) \
201 PLANE_TIMESG(_IG(dst2) = _IG(dst) & (_IG(src) | ~(mask)))
202
203/* dst2 = dst | src */
204#define INTER_OR(src,dst,dst2) \
205 PLANE_TIMES(_I(dst2) = _I(dst) | _I(src))
206
207/* dst2 = dst | (src & mask) */
208#define INTER_ORM(src,dst,mask,dst2) \
209 PLANE_TIMESG(_IG(dst2) = _IG(dst) | (_IG(src) & (mask)))
210
211/* dst = src | msk */
212#define INTER_ORMSK(src,msk,dst) \
213 PLANE_TIMESG(_IG(dst) = _IG(src) | (msk))
214
215/* dst = src & msk */
216#define INTER_ANDMSK(src,msk,dst) \
217 PLANE_TIMESG(_IG(dst) = _IG(src) & (msk))
218
219/* dst = (src1 & msk1) | (src2 & msk2) */
220#define INTER_ANDMSK2(src1,msk1,src2,msk2,dst) \
221 PLANE_TIMESG(_IG(dst) = (_IG(src1) & (msk1)) | (_IG(src2) & (msk2)))
222
223#define INTER_PLANE(x) (1<<(x))
224
225#define INTER_PFILL(col, fill) \
226 PLANE_TIMESG(_IG(fill) = \
227 ((col) & INTER_PLANE(_INDEX)) ? INTER_PPGMSK : 0)
228
229/* dst = src >> cnt */
230#define INTER_SCRRIGHT(cnt, src, dst) \
231 PLANE_TIMESG(_IG(dst) = _IG(src) >> (cnt))
232
233/* dst = src << cnt */
234#define INTER_SCRLEFT(cnt, src, dst) \
235 PLANE_TIMESG(_IG(dst) = _IG(src) << (cnt))
236
237/* bits1=(bits >> right) | (bits=psrc) << left) */
238#define INTER_GETRLC(right, left, psrc, bits, bits1) \
239 PLANE_TIMESG( _IG(bits1)=(_IG(bits) >> (right)) | \
240 ((_IG(bits) = _IG(psrc)) << (left)))
241
242/* bits1=(bits << left) | (bits=psrc) >> right) */
243#define INTER_GETLRC(left, right, psrc, bits, bits1) \
244 PLANE_TIMESG( _IG(bits1)=(_IG(bits) << (left)) | \
245 ((_IG(bits) = _IG(psrc)) >> (right)))
246
247/* dst=src2 & (src1 & a1 ^ x1) ^ (src1 & a2 ^ x2) */
248#define INTER_CPLX(src1, src2, a1, x1, a2, x2, dst) \
249 PLANE_TIMES( _I(dst) = (_I(src2) \
250 & (_I(src1) & _I(a1) ^ _I(x1)) \
251 ^ (_I(src1) & _I(a2) ^ _I(x2)))) \
252
253/* dst=src2 & ((src1 & a1 ^ x1) | ~mask) ^ ((src1 & a2 ^ x2) & mask) */
254#define INTER_CPLXM(src1, src2, a1, x1, a2, x2, mask, dst) \
255 PLANE_TIMESG( _IG(dst) = (_IG(src2) \
256 & ((_IG(src1) & _IG(a1) ^ _IG(x1)) | ~mask) \
257 ^ ((_IG(src1) & _IG(a2) ^ _IG(x2)) & mask)))
258
259/* dst = (src & ~(bitmask | planemask)) | (insert | (bitmask | planemask)) */
260#define INTER_PMSKINS(bitmask, planemask, insert, src, dst) \
261 PLANE_TIMESG( \
262 if (planemask & INTER_PLANE(_INDEX)) \
263 _IG(dst) = (_IG(src) & ~bitmask) | (_IG(insert) & bitmask) \
264 )
265
266/* dst = (src & ~bitmask) | ((insert >> shift) & bitmask) */
267#define INTER_SCRRMSKINS(bitmask, planemask, insert, shift, src, dst) \
268 PLANE_TIMESG( \
269 if (planemask & INTER_PLANE(_INDEX)) \
270 _IG(dst) = (_IG(src) & ~(bitmask)) | \
271 ((_IG(insert) >> shift) & (bitmask)) \
272 )
273
274/* dst = (src & ~bitmask) | ((insert << shift) & bitmask) */
275#define INTER_SCRLMSKINS(bitmask, planemask, insert, shift, src, dst) \
276 PLANE_TIMESG( \
277 if (planemask & INTER_PLANE(_INDEX)) \
278 _IG(dst) = (_IG(src) & ~bitmask) | \
279 ((_IG(insert) << shift) & bitmask) \
280 )
281
282/* dst = ((src1 << sl1) & bitmask1) | ((src2 >> sr2) & bitmask2) */
283#define INTER_MSKINSM(bitmask1, sl1, src1, bitmask2, sr2, src2, dst) \
284 PLANE_TIMESG( \
285 _IG(dst) = ((_IG(src1) << sl1) & (bitmask1)) | \
286 ((_IG(src2) >> sr2) & (bitmask2)) \
287 )
288
289/* dst = src & and ^ xor */
290#define INTER_DoRRop(src, and, xor, dst) \
291 PLANE_TIMES(_I(dst) = (_I(src) & _I(and) ^ _I(xor))) \
292
293#define INTER_DoMaskRRop(src, and, xor, mask, dst) \
294 PLANE_TIMESG( \
295 _IG(dst) = (_IG(src) & ((_IG(and) | ~(mask))) \
296 ^ (_IG(xor) & mask)))
297
298#define INTER_DoRop(result, alu, src, dst) \
299{ \
300 if (alu == GXcopy) { \
301 PLANE_TIMES( \
302 _I(result) = fnCOPY (_I(src), _I(dst))); \
303 } else if (alu == GXxor) { \
304 PLANE_TIMES( \
305 _I(result) = fnXOR (_I(src), _I(dst))); \
306 } \
307 else { \
308 switch (alu) \
309 { \
310 case GXclear: \
311 PLANE_TIMES( \
312 _I(result) = fnCLEAR (_I(src), _I(dst))); \
313 break; \
314 case GXand: \
315 PLANE_TIMES( \
316 _I(result) = fnAND (_I(src), _I(dst))); \
317 break; \
318 case GXandReverse: \
319 PLANE_TIMES( \
320 _I(result) = fnANDREVERSE (_I(src), _I(dst))); \
321 break; \
322 case GXandInverted: \
323 PLANE_TIMES( \
324 _I(result) = fnANDINVERTED (_I(src), _I(dst))); \
325 break; \
326 case GXnoop: \
327 PLANE_TIMES( \
328 _I(result) = fnNOOP (_I(src), _I(dst))); \
329 break; \
330 case GXor: \
331 PLANE_TIMES( \
332 _I(result) = fnOR (_I(src), _I(dst))); \
333 break; \
334 case GXnor: \
335 PLANE_TIMES( \
336 _I(result) = fnNOR (_I(src), _I(dst))); \
337 break; \
338 case GXequiv: \
339 PLANE_TIMES( \
340 _I(result) = fnEQUIV (_I(src), _I(dst))); \
341 break; \
342 case GXinvert: \
343 PLANE_TIMES( \
344 _I(result) = fnINVERT (_I(src), _I(dst))); \
345 break; \
346 case GXorReverse: \
347 PLANE_TIMES( \
348 _I(result) = fnORREVERSE (_I(src), _I(dst))); \
349 break; \
350 case GXcopyInverted: \
351 PLANE_TIMES( \
352 _I(result) = fnCOPYINVERTED (_I(src), _I(dst))); \
353 break; \
354 case GXorInverted: \
355 PLANE_TIMES( \
356 _I(result) = fnORINVERTED (_I(src), _I(dst))); \
357 break; \
358 case GXnand: \
359 PLANE_TIMES( \
360 _I(result) = fnNAND (_I(src), _I(dst))); \
361 break; \
362 case GXset: \
363 PLANE_TIMES( \
364 _I(result) = fnSET (_I(src), _I(dst))); \
365 break; \
366 } \
367 } \
368}
369
370#define iplGetGroupWidthAndPointer(pDrawable, width, pointer) \
371 iplGetTypedWidthAndPointer(pDrawable, width, pointer, INTER_PIXGRP, INTER_PIXGRP)
372
373#define INTER_getstipplepixels(psrcstip, x, w, ones, psrcpix, pdstpix) \
374{ \
375 unsigned long q; \
376 int m; \
377 if (ones) { \
378 if ((m = ((x) - ((MFB_PPW*MFB_PSZ)-MFB_PPW))) > 0) { \
379 q = (*(psrcstip)) << m; \
380 if ( (x)+(w) > (MFB_PPW*MFB_PSZ) ) \
381 q |= *((psrcstip)+1) >> ((MFB_PPW*MFB_PSZ)-m); \
382 } \
383 else \
384 q = (*(psrcstip)) >> -m; \
385 } \
386 else { \
387 if ((m = ((x) - ((MFB_PPW*MFB_PSZ)-MFB_PPW))) > 0) { \
388 q = (~ *(psrcstip)) << m; \
389 if ( (x)+(w) > (MFB_PPW*MFB_PSZ) ) \
390 q |= (~*((psrcstip)+1)) >> ((MFB_PPW*MFB_PSZ)-m); \
391 } \
392 else \
393 q = (~ *(psrcstip)) >> -m; \
394 } \
395 q >>=16; \
396 INTER_ANDMSK(psrcpix,q,pdstpix); \
397}
398
399#define INTER_getstipplepixelsb(psrcstip, x, w, psrcpix0, psrcpix1, pdstpix) \
400{ \
401 unsigned long q,qn; \
402 int m; \
403 if ((m = ((x) - ((MFB_PPW*MFB_PSZ)-MFB_PPW))) > 0) { \
404 q = (*(psrcstip)) << m; \
405 qn = (~ *(psrcstip)) << m; \
406 if ( (x)+(w) > (MFB_PPW*MFB_PSZ) ) { \
407 q |= *((psrcstip)+1) >> ((MFB_PPW*MFB_PSZ)-m); \
408 qn |= (~ *((psrcstip)+1)) >> ((MFB_PPW*MFB_PSZ)-m); \
409 } \
410 } \
411 else { \
412 q = (*(psrcstip)) >> -m; \
413 qn = (~ *(psrcstip)) >> -m; \
414 } \
415 q >>=16; \
416 qn >>=16; \
417 INTER_ANDMSK2(psrcpix0,qn,psrcpix1,q,pdstpix); \
418}
419
420#define INTER_maskbits(x, w, startmask, endmask, nlg) \
421 startmask = iplstarttab[(x) & INTER_PIM]; \
422 endmask = iplendtab[((x)+(w)) & INTER_PIM]; \
423 if (startmask) \
424 nlg = (((w) - (INTER_PPG - ((x) & INTER_PIM))) >> INTER_PGSH); \
425 else \
426 nlg = (w) >> INTER_PGSH;
427
428#define INTER_maskpartialbits(x, w, mask) \
429 mask = iplstartpartial[(x) & INTER_PIM] & \
430 iplendpartial[((x) + (w)) & INTER_PIM];
431
432#define INTER_mask32bits(x, w, startmask, endmask, nlw) \
433 startmask = iplstarttab[(x) & INTER_PIM]; \
434 endmask = iplendtab[((x)+(w)) & INTER_PIM];
435
436#define INTER_getbits(psrc, x, w, pdst) \
437 if ( ((x) + (w)) <= INTER_PPG) \
438 { \
439 INTER_SCRLEFT((x), psrc, pdst); \
440 } \
441 else \
442 { \
443 int m; \
444 m = INTER_PPG-(x); \
445 INTER_MSKINSM(iplendtab[m], x, psrc, \
446 iplstarttab[m], m, INTER_NEXT(psrc), pdst); \
447 }
448
449#define INTER_putbits(psrc, x, w, pdst, planemask) \
450 if ( ((x)+(w)) <= INTER_PPG) \
451 { \
452 INTER_DECLAREG(tmpmask); \
453 INTER_maskpartialbits((x), (w), tmpmask); \
454 INTER_SCRRMSKINS(tmpmask, planemask, psrc, x, pdst, pdst); \
455 } \
456 else \
457 { \
458 unsigned long m; \
459 unsigned long n; \
460 m = INTER_PPG-(x); \
461 n = (w) - m; \
462 INTER_SCRRMSKINS(iplstarttab[x], planemask, psrc, x, \
463 pdst, pdst); \
464 INTER_SCRLMSKINS(iplendtab[n], planemask, psrc, m, \
465 INTER_NEXT(pdst), INTER_NEXT(pdst)); \
466 }
467
468#define INTER_putbitsrop(psrc, x, w, pdst, planemask, rop) \
469if ( ((x)+(w)) <= INTER_PPG) \
470{ \
471 INTER_DECLAREG(tmpmask); \
472 INTER_DECLAREGP(t1); INTER_DECLAREGP(t2); \
473 INTER_maskpartialbits((x), (w), tmpmask); \
474 INTER_SCRRIGHT((x), (psrc), (t1)); \
475 INTER_DoRop(t2, rop, t1, pdst); \
476 INTER_PMSKINS(tmpmask, planemask, t2, pdst, pdst); \
477} \
478else \
479{ \
480 unsigned long m; \
481 unsigned long n; \
482 INTER_DECLAREGP(t1); INTER_DECLAREGP(t2); \
483 m = INTER_PPG-(x); \
484 n = (w) - m; \
485 INTER_SCRRIGHT((x), (psrc), (t1)); \
486 INTER_DoRop(t2, rop, t1, pdst); \
487 INTER_PMSKINS(iplstarttab[x], planemask, t2, pdst, pdst); \
488 INTER_SCRLEFT(m, (psrc), (t1)); \
489 INTER_DoRop(t2, rop, t1, pdst+1); \
490 INTER_PMSKINS(iplendtab[n], planemask, t2, pdst, pdst); \
491}
492
493#define INTER_putbitsmropshort(src, x, w, pdst) { \
494 INTER_DECLAREG(_tmpmask); \
495 INTER_DECLAREGP(_t1); \
496 INTER_maskpartialbits((x), (w), _tmpmask); \
497 INTER_SCRRIGHT((x), (src), _t1); \
498 INTER_DoMaskMergeRop(_t1, pdst, _tmpmask, pdst); \
499}
500
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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