VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/7.0/xorg/picture.h@ 18709

Last change on this file since 18709 was 17236, checked in by vboxsync, 16 years ago

Additions/x11/x11include: blast! Reverted r43555 and r43556

  • Property svn:eol-style set to native
File size: 8.2 KB
Line 
1/*
2 * $XFree86: xc/programs/Xserver/render/picture.h,v 1.20tsi Exp $
3 *
4 * Copyright © 2000 SuSE, 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 SuSE not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. SuSE makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
15 *
16 * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Author: Keith Packard, SuSE, Inc.
24 */
25
26#ifndef _PICTURE_H_
27#define _PICTURE_H_
28
29typedef struct _DirectFormat *DirectFormatPtr;
30typedef struct _PictFormat *PictFormatPtr;
31typedef struct _Picture *PicturePtr;
32
33/*
34 * While the protocol is generous in format support, the
35 * sample implementation allows only packed RGB and GBR
36 * representations for data to simplify software rendering,
37 */
38#define PICT_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \
39 ((type) << 16) | \
40 ((a) << 12) | \
41 ((r) << 8) | \
42 ((g) << 4) | \
43 ((b)))
44
45/*
46 * gray/color formats use a visual index instead of argb
47 */
48#define PICT_VISFORMAT(bpp,type,vi) (((bpp) << 24) | \
49 ((type) << 16) | \
50 ((vi)))
51
52#define PICT_FORMAT_BPP(f) (((f) >> 24) )
53#define PICT_FORMAT_TYPE(f) (((f) >> 16) & 0xff)
54#define PICT_FORMAT_A(f) (((f) >> 12) & 0x0f)
55#define PICT_FORMAT_R(f) (((f) >> 8) & 0x0f)
56#define PICT_FORMAT_G(f) (((f) >> 4) & 0x0f)
57#define PICT_FORMAT_B(f) (((f) ) & 0x0f)
58#define PICT_FORMAT_RGB(f) (((f) ) & 0xfff)
59#define PICT_FORMAT_VIS(f) (((f) ) & 0xffff)
60
61#define PICT_TYPE_OTHER 0
62#define PICT_TYPE_A 1
63#define PICT_TYPE_ARGB 2
64#define PICT_TYPE_ABGR 3
65#define PICT_TYPE_COLOR 4
66#define PICT_TYPE_GRAY 5
67
68#define PICT_FORMAT_COLOR(f) (PICT_FORMAT_TYPE(f) & 2)
69
70/* 32bpp formats */
71#define PICT_a8r8g8b8 PICT_FORMAT(32,PICT_TYPE_ARGB,8,8,8,8)
72#define PICT_x8r8g8b8 PICT_FORMAT(32,PICT_TYPE_ARGB,0,8,8,8)
73#define PICT_a8b8g8r8 PICT_FORMAT(32,PICT_TYPE_ABGR,8,8,8,8)
74#define PICT_x8b8g8r8 PICT_FORMAT(32,PICT_TYPE_ABGR,0,8,8,8)
75
76/* 24bpp formats */
77#define PICT_r8g8b8 PICT_FORMAT(24,PICT_TYPE_ARGB,0,8,8,8)
78#define PICT_b8g8r8 PICT_FORMAT(24,PICT_TYPE_ABGR,0,8,8,8)
79
80/* 16bpp formats */
81#define PICT_r5g6b5 PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,6,5)
82#define PICT_b5g6r5 PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,6,5)
83
84#define PICT_a1r5g5b5 PICT_FORMAT(16,PICT_TYPE_ARGB,1,5,5,5)
85#define PICT_x1r5g5b5 PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,5,5)
86#define PICT_a1b5g5r5 PICT_FORMAT(16,PICT_TYPE_ABGR,1,5,5,5)
87#define PICT_x1b5g5r5 PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,5,5)
88#define PICT_a4r4g4b4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
89#define PICT_x4r4g4b4 PICT_FORMAT(16,PICT_TYPE_ARGB,0,4,4,4)
90#define PICT_a4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ABGR,4,4,4,4)
91#define PICT_x4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ABGR,0,4,4,4)
92
93/* 8bpp formats */
94#define PICT_a8 PICT_FORMAT(8,PICT_TYPE_A,8,0,0,0)
95#define PICT_r3g3b2 PICT_FORMAT(8,PICT_TYPE_ARGB,0,3,3,2)
96#define PICT_b2g3r3 PICT_FORMAT(8,PICT_TYPE_ABGR,0,3,3,2)
97#define PICT_a2r2g2b2 PICT_FORMAT(8,PICT_TYPE_ARGB,2,2,2,2)
98#define PICT_a2b2g2r2 PICT_FORMAT(8,PICT_TYPE_ABGR,2,2,2,2)
99
100#define PICT_c8 PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0)
101#define PICT_g8 PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0)
102
103/* 4bpp formats */
104#define PICT_a4 PICT_FORMAT(4,PICT_TYPE_A,4,0,0,0)
105#define PICT_r1g2b1 PICT_FORMAT(4,PICT_TYPE_ARGB,0,1,2,1)
106#define PICT_b1g2r1 PICT_FORMAT(4,PICT_TYPE_ABGR,0,1,2,1)
107#define PICT_a1r1g1b1 PICT_FORMAT(4,PICT_TYPE_ARGB,1,1,1,1)
108#define PICT_a1b1g1r1 PICT_FORMAT(4,PICT_TYPE_ABGR,1,1,1,1)
109
110#define PICT_c4 PICT_FORMAT(4,PICT_TYPE_COLOR,0,0,0,0)
111#define PICT_g4 PICT_FORMAT(4,PICT_TYPE_GRAY,0,0,0,0)
112
113/* 1bpp formats */
114#define PICT_a1 PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0)
115
116#define PICT_g1 PICT_FORMAT(1,PICT_TYPE_GRAY,0,0,0,0)
117
118/*
119 * For dynamic indexed visuals (GrayScale and PseudoColor), these control the
120 * selection of colors allocated for drawing to Pictures. The default
121 * policy depends on the size of the colormap:
122 *
123 * Size Default Policy
124 * ----------------------------
125 * < 64 PolicyMono
126 * < 256 PolicyGray
127 * 256 PolicyColor (only on PseudoColor)
128 *
129 * The actual allocation code lives in miindex.c, and so is
130 * austensibly server dependent, but that code does:
131 *
132 * PolicyMono Allocate no additional colors, use black and white
133 * PolicyGray Allocate 13 gray levels (11 cells used)
134 * PolicyColor Allocate a 4x4x4 cube and 13 gray levels (71 cells used)
135 * PolicyAll Allocate as big a cube as possible, fill with gray (all)
136 *
137 * Here's a picture to help understand how many colors are
138 * actually allocated (this is just the gray ramp):
139 *
140 * gray level
141 * all 0000 1555 2aaa 4000 5555 6aaa 8000 9555 aaaa bfff d555 eaaa ffff
142 * b/w 0000 ffff
143 * 4x4x4 5555 aaaa
144 * extra 1555 2aaa 4000 6aaa 8000 9555 bfff d555 eaaa
145 *
146 * The default colormap supplies two gray levels (black/white), the
147 * 4x4x4 cube allocates another two and nine more are allocated to fill
148 * in the 13 levels. When the 4x4x4 cube is not allocated, a total of
149 * 11 cells are allocated.
150 */
151
152#define PictureCmapPolicyInvalid -1
153#define PictureCmapPolicyDefault 0
154#define PictureCmapPolicyMono 1
155#define PictureCmapPolicyGray 2
156#define PictureCmapPolicyColor 3
157#define PictureCmapPolicyAll 4
158
159extern int PictureCmapPolicy;
160
161int PictureParseCmapPolicy (const char *name);
162
163extern int RenderErrBase;
164extern int RenderClientPrivateIndex;
165
166/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
167
168#if defined(WIN32) && !defined(__GNUC__)
169typedef __int64 xFixed_32_32;
170#else
171# if defined (_LP64) || \
172 defined(__alpha__) || defined(__alpha) || \
173 defined(ia64) || defined(__ia64__) || \
174 defined(__sparc64__) || \
175 defined(__s390x__) || \
176 defined(amd64) || defined (__amd64__) || \
177 (defined(sgi) && (_MIPS_SZLONG == 64))
178typedef long xFixed_32_32;
179# else
180# if defined(__GNUC__) && \
181 ((__GNUC__ > 2) || \
182 ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 7)))
183__extension__
184# endif
185typedef long long int xFixed_32_32;
186# endif
187#endif
188
189typedef xFixed_32_32 xFixed_48_16;
190
191#define MAX_FIXED_48_16 ((xFixed_48_16) 0x7fffffff)
192#define MIN_FIXED_48_16 (-((xFixed_48_16) 1 << 31))
193
194typedef CARD32 xFixed_1_31;
195typedef CARD32 xFixed_1_16;
196typedef INT32 xFixed_16_16;
197
198/*
199 * An unadorned "xFixed" is the same as xFixed_16_16,
200 * (since it's quite common in the code)
201 */
202typedef xFixed_16_16 xFixed;
203#define XFIXED_BITS 16
204
205#define xFixedToInt(f) (int) ((f) >> XFIXED_BITS)
206#define IntToxFixed(i) ((xFixed) (i) << XFIXED_BITS)
207#define xFixedE ((xFixed) 1)
208#define xFixed1 (IntToxFixed(1))
209#define xFixed1MinusE (xFixed1 - xFixedE)
210#define xFixedFrac(f) ((f) & xFixed1MinusE)
211#define xFixedFloor(f) ((f) & ~xFixed1MinusE)
212#define xFixedCeil(f) xFixedFloor((f) + xFixed1MinusE)
213
214#define xFixedFraction(f) ((f) & xFixed1MinusE)
215#define xFixedMod2(f) ((f) & (xFixed1 | xFixed1MinusE))
216
217/* whether 't' is a well defined not obviously empty trapezoid */
218#define xTrapezoidValid(t) ((t)->left.p1.y != (t)->left.p2.y && \
219 (t)->right.p1.y != (t)->right.p2.y && \
220 (int) ((t)->bottom - (t)->top) > 0)
221
222/*
223 * Standard NTSC luminance conversions:
224 *
225 * y = r * 0.299 + g * 0.587 + b * 0.114
226 *
227 * Approximate this for a bit more speed:
228 *
229 * y = (r * 153 + g * 301 + b * 58) / 512
230 *
231 * This gives 17 bits of luminance; to get 15 bits, lop the low two
232 */
233
234#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \
235 (((s) >> 8) & 0xff) * 301 + \
236 (((s) ) & 0xff) * 58) >> 2)
237
238#endif /* _PICTURE_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