VirtualBox

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

Last change on this file since 69348 was 51223, checked in by vboxsync, 11 years ago

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

  • Property svn:eol-style set to native
File size: 20.8 KB
Line 
1/*
2 * $XFree86: xc/programs/Xserver/fb/fbpict.h,v 1.7 2001/07/18 10:15:02 keithp Exp $
3 *
4 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
5 *
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of Keith Packard not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. Keith Packard makes no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
15 *
16 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
23 */
24
25#ifdef HAVE_DIX_CONFIG_H
26#include <dix-config.h>
27#endif
28
29#ifndef _FBPICT_H_
30#define _FBPICT_H_
31
32#include "renderedge.h"
33
34#define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
35#define FbIntDiv(a,b) (((CARD16) (a) * 255) / (b))
36
37#define FbGet8(v,i) ((CARD16) (CARD8) ((v) >> i))
38
39/*
40 * There are two ways of handling alpha -- either as a single unified value or
41 * a separate value for each component, hence each macro must have two
42 * versions. The unified alpha version has a 'U' at the end of the name,
43 * the component version has a 'C'. Similarly, functions which deal with
44 * this difference will have two versions using the same convention.
45 */
46
47#define FbOverU(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),(a),(t)) + FbGet8(x,i),\
48 (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
49
50#define FbOverC(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),FbGet8(a,i),(t)) + FbGet8(x,i),\
51 (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
52
53#define FbInU(x,i,a,t) ((CARD32) FbIntMult(FbGet8(x,i),(a),(t)) << (i))
54
55#define FbInC(x,i,a,t) ((CARD32) FbIntMult(FbGet8(x,i),FbGet8(a,i),(t)) << (i))
56
57#define FbGen(x,y,i,ax,ay,t,u,v) ((t) = (FbIntMult(FbGet8(y,i),ay,(u)) + \
58 FbIntMult(FbGet8(x,i),ax,(v))),\
59 (CARD32) ((CARD8) ((t) | \
60 (0 - ((t) >> 8)))) << (i))
61
62#define FbAdd(x,y,i,t) ((t) = FbGet8(x,i) + FbGet8(y,i), \
63 (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
64
65
66#define Alpha(x) ((x) >> 24)
67#define Red(x) (((x) >> 16) & 0xff)
68#define Green(x) (((x) >> 8) & 0xff)
69#define Blue(x) ((x) & 0xff)
70
71#define fbComposeGetSolid(pict, bits, fmt) { \
72 FbBits *__bits__; \
73 FbStride __stride__; \
74 int __bpp__; \
75 int __xoff__,__yoff__; \
76\
77 fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
78 switch (__bpp__) { \
79 case 32: \
80 (bits) = *(CARD32 *) __bits__; \
81 break; \
82 case 24: \
83 (bits) = Fetch24 ((CARD8 *) __bits__); \
84 break; \
85 case 16: \
86 (bits) = *(CARD16 *) __bits__; \
87 (bits) = cvt0565to8888(bits); \
88 break; \
89 default: \
90 return; \
91 } \
92 /* If necessary, convert RGB <--> BGR. */ \
93 if (PICT_FORMAT_TYPE((pict)->format) != PICT_FORMAT_TYPE(fmt)) \
94 { \
95 (bits) = (((bits) & 0xff000000) | \
96 (((bits) & 0x00ff0000) >> 16) | \
97 (((bits) & 0x0000ff00) >> 0) | \
98 (((bits) & 0x000000ff) << 16)); \
99 } \
100 /* manage missing src alpha */ \
101 if ((pict)->pFormat->direct.alphaMask == 0) \
102 (bits) |= 0xff000000; \
103}
104
105#define fbComposeGetStart(pict,x,y,type,stride,line,mul) {\
106 FbBits *__bits__; \
107 FbStride __stride__; \
108 int __bpp__; \
109 int __xoff__,__yoff__; \
110\
111 fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
112 (stride) = __stride__ * sizeof (FbBits) / sizeof (type); \
113 (line) = ((type *) __bits__) + (stride) * ((y) + __yoff__) + (mul) * ((x) + __xoff__); \
114}
115#define cvt8888to0565(s) ((((s) >> 3) & 0x001f) | \
116 (((s) >> 5) & 0x07e0) | \
117 (((s) >> 8) & 0xf800))
118#define cvt0565to8888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
119 ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \
120 ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
121
122#if IMAGE_BYTE_ORDER == MSBFirst
123#define Fetch24(a) ((unsigned long) (a) & 1 ? \
124 ((*(a) << 16) | *((CARD16 *) ((a)+1))) : \
125 ((*((CARD16 *) (a)) << 8) | *((a)+2)))
126#define Store24(a,v) ((unsigned long) (a) & 1 ? \
127 ((*(a) = (CARD8) ((v) >> 16)), \
128 (*((CARD16 *) ((a)+1)) = (CARD16) (v))) : \
129 ((*((CARD16 *) (a)) = (CARD16) ((v) >> 8)), \
130 (*((a)+2) = (CARD8) (v))))
131#else
132#define Fetch24(a) ((unsigned long) (a) & 1 ? \
133 ((*(a)) | (*((CARD16 *) ((a)+1)) << 8)) : \
134 ((*((CARD16 *) (a))) | (*((a)+2) << 16)))
135#define Store24(a,v) ((unsigned long) (a) & 1 ? \
136 ((*(a) = (CARD8) (v)), \
137 (*((CARD16 *) ((a)+1)) = (CARD16) ((v) >> 8))) : \
138 ((*((CARD16 *) (a)) = (CARD16) (v)),\
139 (*((a)+2) = (CARD8) ((v) >> 16))))
140#endif
141
142/*
143 The methods below use some tricks to be able to do two color
144 components at the same time.
145*/
146
147/*
148 x_c = (x_c * a) / 255
149*/
150#define FbByteMul(x, a) do { \
151 CARD32 t = ((x & 0xff00ff) * a) + 0x800080; \
152 t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
153 t &= 0xff00ff; \
154 \
155 x = (((x >> 8) & 0xff00ff) * a) + 0x800080; \
156 x = (x + ((x >> 8) & 0xff00ff)); \
157 x &= 0xff00ff00; \
158 x += t; \
159 } while (0)
160
161/*
162 x_c = (x_c * a) / 255 + y
163*/
164#define FbByteMulAdd(x, a, y) do { \
165 CARD32 t = ((x & 0xff00ff) * a) + 0x800080; \
166 t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
167 t &= 0xff00ff; \
168 t += y & 0xff00ff; \
169 t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
170 t &= 0xff00ff; \
171 \
172 x = (((x >> 8) & 0xff00ff) * a) + 0x800080; \
173 x = (x + ((x >> 8) & 0xff00ff)) >> 8; \
174 x &= 0xff00ff; \
175 x += (y >> 8) & 0xff00ff; \
176 x |= 0x1000100 - ((t >> 8) & 0xff00ff); \
177 x &= 0xff00ff; \
178 x <<= 8; \
179 x += t; \
180 } while (0)
181
182/*
183 x_c = (x_c * a + y_c * b) / 255
184*/
185#define FbByteAddMul(x, a, y, b) do { \
186 CARD32 t; \
187 CARD32 r = (x >> 24) * a + (y >> 24) * b + 0x80; \
188 r += (r >> 8); \
189 r >>= 8; \
190 \
191 t = (x & 0xff00) * a + (y & 0xff00) * b; \
192 t += (t >> 8) + 0x8000; \
193 t >>= 16; \
194 \
195 t |= r << 16; \
196 t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
197 t &= 0xff00ff; \
198 t <<= 8; \
199 \
200 r = ((x >> 16) & 0xff) * a + ((y >> 16) & 0xff) * b + 0x80; \
201 r += (r >> 8); \
202 r >>= 8; \
203 \
204 x = (x & 0xff) * a + (y & 0xff) * b + 0x80; \
205 x += (x >> 8); \
206 x >>= 8; \
207 x |= r << 16; \
208 x |= 0x1000100 - ((x >> 8) & 0xff00ff); \
209 x &= 0xff00ff; \
210 x |= t; \
211} while (0)
212
213/*
214 x_c = (x_c * a + y_c *b) / 256
215*/
216#define FbByteAddMul_256(x, a, y, b) do { \
217 CARD32 t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; \
218 t >>= 8; \
219 t &= 0xff00ff; \
220 \
221 x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b; \
222 x &= 0xff00ff00; \
223 x += t; \
224} while (0)
225/*
226 x_c = (x_c * a_c) / 255
227*/
228#define FbByteMulC(x, a) do { \
229 CARD32 t; \
230 CARD32 r = (x & 0xff) * (a & 0xff); \
231 r |= (x & 0xff0000) * ((a >> 16) & 0xff); \
232 r += 0x800080; \
233 r = (r + ((r >> 8) & 0xff00ff)) >> 8; \
234 r &= 0xff00ff; \
235 \
236 x >>= 8; \
237 t = (x & 0xff) * ((a >> 8) & 0xff); \
238 t |= (x & 0xff0000) * (a >> 24); \
239 t += 0x800080; \
240 t = t + ((t >> 8) & 0xff00ff); \
241 x = r | (t & 0xff00ff00); \
242 \
243 } while (0)
244
245/*
246 x_c = (x_c * a) / 255 + y
247*/
248#define FbByteMulAddC(x, a, y) do { \
249 CARD32 t; \
250 CARD32 r = (x & 0xff) * (a & 0xff); \
251 r |= (x & 0xff0000) * ((a >> 16) & 0xff); \
252 r += 0x800080; \
253 r = (r + ((r >> 8) & 0xff00ff)) >> 8; \
254 r &= 0xff00ff; \
255 r += y & 0xff00ff; \
256 r |= 0x1000100 - ((r >> 8) & 0xff00ff); \
257 r &= 0xff00ff; \
258 \
259 x >>= 8; \
260 t = (x & 0xff) * ((a >> 8) & 0xff); \
261 t |= (x & 0xff0000) * (a >> 24); \
262 t += 0x800080; \
263 t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
264 t &= 0xff00ff; \
265 t += (y >> 8) & 0xff00ff; \
266 t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
267 t &= 0xff00ff; \
268 x = r | (t << 8); \
269 } while (0)
270
271/*
272 x_c = (x_c * a_c + y_c * b) / 255
273*/
274#define FbByteAddMulC(x, a, y, b) do { \
275 CARD32 t; \
276 CARD32 r = (x >> 24) * (a >> 24) + (y >> 24) * b; \
277 r += (r >> 8) + 0x80; \
278 r >>= 8; \
279 \
280 t = (x & 0xff00) * ((a >> 8) & 0xff) + (y & 0xff00) * b; \
281 t += (t >> 8) + 0x8000; \
282 t >>= 16; \
283 \
284 t |= r << 16; \
285 t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
286 t &= 0xff00ff; \
287 t <<= 8; \
288 \
289 r = ((x >> 16) & 0xff) * ((a >> 16) & 0xff) + ((y >> 16) & 0xff) * b + 0x80; \
290 r += (r >> 8); \
291 r >>= 8; \
292 \
293 x = (x & 0xff) * (a & 0xff) + (y & 0xff) * b + 0x80; \
294 x += (x >> 8); \
295 x >>= 8; \
296 x |= r << 16; \
297 x |= 0x1000100 - ((x >> 8) & 0xff00ff); \
298 x &= 0xff00ff; \
299 x |= t; \
300 } while (0)
301
302/*
303 x_c = min(x_c + y_c, 255)
304*/
305#define FbByteAdd(x, y) do { \
306 CARD32 t; \
307 CARD32 r = (x & 0xff00ff) + (y & 0xff00ff); \
308 r |= 0x1000100 - ((r >> 8) & 0xff00ff); \
309 r &= 0xff00ff; \
310 \
311 t = ((x >> 8) & 0xff00ff) + ((y >> 8) & 0xff00ff); \
312 t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
313 r |= (t & 0xff00ff) << 8; \
314 x = r; \
315 } while (0)
316
317#define div_255(x) (((x) + 0x80 + (((x) + 0x80) >> 8)) >> 8)
318
319#if defined(__i386__) && defined(__GNUC__)
320#define FASTCALL __attribute__((regparm(3)))
321#else
322#define FASTCALL
323#endif
324
325#if defined(__GNUC__)
326#define INLINE __inline__
327#else
328#define INLINE
329#endif
330
331typedef struct _FbComposeData {
332 CARD8 op;
333 PicturePtr src;
334 PicturePtr mask;
335 PicturePtr dest;
336 INT16 xSrc;
337 INT16 ySrc;
338 INT16 xMask;
339 INT16 yMask;
340 INT16 xDest;
341 INT16 yDest;
342 CARD16 width;
343 CARD16 height;
344} FbComposeData;
345
346typedef FASTCALL void (*CombineMaskU) (CARD32 *src, const CARD32 *mask, int width);
347typedef FASTCALL void (*CombineFuncU) (CARD32 *dest, const CARD32 *src, int width);
348typedef FASTCALL void (*CombineFuncC) (CARD32 *dest, CARD32 *src, CARD32 *mask, int width);
349
350typedef struct _FbComposeFunctions {
351 CombineFuncU *combineU;
352 CombineFuncC *combineC;
353 CombineMaskU combineMaskU;
354} FbComposeFunctions;
355
356/* fbcompose.c */
357
358void
359fbCompositeGeneral (CARD8 op,
360 PicturePtr pSrc,
361 PicturePtr pMask,
362 PicturePtr pDst,
363 INT16 xSrc,
364 INT16 ySrc,
365 INT16 xMask,
366 INT16 yMask,
367 INT16 xDst,
368 INT16 yDst,
369 CARD16 width,
370 CARD16 height);
371
372
373/* fbedge.c */
374void
375fbRasterizeEdges (FbBits *buf,
376 int bpp,
377 int width,
378 int stride,
379 RenderEdge *l,
380 RenderEdge *r,
381 xFixed t,
382 xFixed b);
383
384/* fbpict.c */
385CARD32
386fbOver (CARD32 x, CARD32 y);
387
388CARD32
389fbOver24 (CARD32 x, CARD32 y);
390
391CARD32
392fbIn (CARD32 x, CARD8 y);
393
394void
395fbCompositeSolidMask_nx8x8888 (CARD8 op,
396 PicturePtr pSrc,
397 PicturePtr pMask,
398 PicturePtr pDst,
399 INT16 xSrc,
400 INT16 ySrc,
401 INT16 xMask,
402 INT16 yMask,
403 INT16 xDst,
404 INT16 yDst,
405 CARD16 width,
406 CARD16 height);
407
408void
409fbCompositeSolidMask_nx8x0888 (CARD8 op,
410 PicturePtr pSrc,
411 PicturePtr pMask,
412 PicturePtr pDst,
413 INT16 xSrc,
414 INT16 ySrc,
415 INT16 xMask,
416 INT16 yMask,
417 INT16 xDst,
418 INT16 yDst,
419 CARD16 width,
420 CARD16 height);
421
422void
423fbCompositeSolidMask_nx8888x8888C (CARD8 op,
424 PicturePtr pSrc,
425 PicturePtr pMask,
426 PicturePtr pDst,
427 INT16 xSrc,
428 INT16 ySrc,
429 INT16 xMask,
430 INT16 yMask,
431 INT16 xDst,
432 INT16 yDst,
433 CARD16 width,
434 CARD16 height);
435
436void
437fbCompositeSolidMask_nx8x0565 (CARD8 op,
438 PicturePtr pSrc,
439 PicturePtr pMask,
440 PicturePtr pDst,
441 INT16 xSrc,
442 INT16 ySrc,
443 INT16 xMask,
444 INT16 yMask,
445 INT16 xDst,
446 INT16 yDst,
447 CARD16 width,
448 CARD16 height);
449
450void
451fbCompositeSolidMask_nx8888x0565C (CARD8 op,
452 PicturePtr pSrc,
453 PicturePtr pMask,
454 PicturePtr pDst,
455 INT16 xSrc,
456 INT16 ySrc,
457 INT16 xMask,
458 INT16 yMask,
459 INT16 xDst,
460 INT16 yDst,
461 CARD16 width,
462 CARD16 height);
463
464void
465fbCompositeSrc_8888x8888 (CARD8 op,
466 PicturePtr pSrc,
467 PicturePtr pMask,
468 PicturePtr pDst,
469 INT16 xSrc,
470 INT16 ySrc,
471 INT16 xMask,
472 INT16 yMask,
473 INT16 xDst,
474 INT16 yDst,
475 CARD16 width,
476 CARD16 height);
477
478void
479fbCompositeSrc_8888x0888 (CARD8 op,
480 PicturePtr pSrc,
481 PicturePtr pMask,
482 PicturePtr pDst,
483 INT16 xSrc,
484 INT16 ySrc,
485 INT16 xMask,
486 INT16 yMask,
487 INT16 xDst,
488 INT16 yDst,
489 CARD16 width,
490 CARD16 height);
491
492void
493fbCompositeSrc_8888x0565 (CARD8 op,
494 PicturePtr pSrc,
495 PicturePtr pMask,
496 PicturePtr pDst,
497 INT16 xSrc,
498 INT16 ySrc,
499 INT16 xMask,
500 INT16 yMask,
501 INT16 xDst,
502 INT16 yDst,
503 CARD16 width,
504 CARD16 height);
505
506void
507fbCompositeSrc_0565x0565 (CARD8 op,
508 PicturePtr pSrc,
509 PicturePtr pMask,
510 PicturePtr pDst,
511 INT16 xSrc,
512 INT16 ySrc,
513 INT16 xMask,
514 INT16 yMask,
515 INT16 xDst,
516 INT16 yDst,
517 CARD16 width,
518 CARD16 height);
519
520void
521fbCompositeSrcAdd_8000x8000 (CARD8 op,
522 PicturePtr pSrc,
523 PicturePtr pMask,
524 PicturePtr pDst,
525 INT16 xSrc,
526 INT16 ySrc,
527 INT16 xMask,
528 INT16 yMask,
529 INT16 xDst,
530 INT16 yDst,
531 CARD16 width,
532 CARD16 height);
533
534void
535fbCompositeSrcAdd_8888x8888 (CARD8 op,
536 PicturePtr pSrc,
537 PicturePtr pMask,
538 PicturePtr pDst,
539 INT16 xSrc,
540 INT16 ySrc,
541 INT16 xMask,
542 INT16 yMask,
543 INT16 xDst,
544 INT16 yDst,
545 CARD16 width,
546 CARD16 height);
547
548void
549fbCompositeSrcAdd_1000x1000 (CARD8 op,
550 PicturePtr pSrc,
551 PicturePtr pMask,
552 PicturePtr pDst,
553 INT16 xSrc,
554 INT16 ySrc,
555 INT16 xMask,
556 INT16 yMask,
557 INT16 xDst,
558 INT16 yDst,
559 CARD16 width,
560 CARD16 height);
561
562void
563fbCompositeSolidMask_nx1xn (CARD8 op,
564 PicturePtr pSrc,
565 PicturePtr pMask,
566 PicturePtr pDst,
567 INT16 xSrc,
568 INT16 ySrc,
569 INT16 xMask,
570 INT16 yMask,
571 INT16 xDst,
572 INT16 yDst,
573 CARD16 width,
574 CARD16 height);
575
576void
577fbComposite (CARD8 op,
578 PicturePtr pSrc,
579 PicturePtr pMask,
580 PicturePtr pDst,
581 INT16 xSrc,
582 INT16 ySrc,
583 INT16 xMask,
584 INT16 yMask,
585 INT16 xDst,
586 INT16 yDst,
587 CARD16 width,
588 CARD16 height);
589
590/* fbtrap.c */
591
592void
593fbAddTraps (PicturePtr pPicture,
594 INT16 xOff,
595 INT16 yOff,
596 int ntrap,
597 xTrap *traps);
598
599void
600fbRasterizeTrapezoid (PicturePtr alpha,
601 xTrapezoid *trap,
602 int x_off,
603 int y_off);
604
605void
606fbAddTriangles (PicturePtr pPicture,
607 INT16 xOff,
608 INT16 yOff,
609 int ntri,
610 xTriangle *tris);
611
612#endif /* _FBPICT_H_ */
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