VirtualBox

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

Last change on this file since 32915 was 25078, checked in by vboxsync, 15 years ago

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

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