VirtualBox

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

Last change on this file since 68495 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: 8.7 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#define PICT_x4a4 PICT_FORMAT(8,PICT_TYPE_A,4,0,0,0)
104#define PICT_x4r1g2b1 PICT_FORMAT(8,PICT_TYPE_ARGB,0,1,2,1)
105#define PICT_x4b1g2r1 PICT_FORMAT(8,PICT_TYPE_ABGR,0,1,2,1)
106#define PICT_x4a1r1g1b1 PICT_FORMAT(8,PICT_TYPE_ARGB,1,1,1,1)
107#define PICT_x4a1b1g1r1 PICT_FORMAT(8,PICT_TYPE_ABGR,1,1,1,1)
108
109#define PICT_x4c4 PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0)
110#define PICT_x4g4 PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0)
111
112/* 4bpp formats */
113#define PICT_a4 PICT_FORMAT(4,PICT_TYPE_A,4,0,0,0)
114#define PICT_r1g2b1 PICT_FORMAT(4,PICT_TYPE_ARGB,0,1,2,1)
115#define PICT_b1g2r1 PICT_FORMAT(4,PICT_TYPE_ABGR,0,1,2,1)
116#define PICT_a1r1g1b1 PICT_FORMAT(4,PICT_TYPE_ARGB,1,1,1,1)
117#define PICT_a1b1g1r1 PICT_FORMAT(4,PICT_TYPE_ABGR,1,1,1,1)
118
119#define PICT_c4 PICT_FORMAT(4,PICT_TYPE_COLOR,0,0,0,0)
120#define PICT_g4 PICT_FORMAT(4,PICT_TYPE_GRAY,0,0,0,0)
121
122/* 1bpp formats */
123#define PICT_a1 PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0)
124
125#define PICT_g1 PICT_FORMAT(1,PICT_TYPE_GRAY,0,0,0,0)
126
127/*
128 * For dynamic indexed visuals (GrayScale and PseudoColor), these control the
129 * selection of colors allocated for drawing to Pictures. The default
130 * policy depends on the size of the colormap:
131 *
132 * Size Default Policy
133 * ----------------------------
134 * < 64 PolicyMono
135 * < 256 PolicyGray
136 * 256 PolicyColor (only on PseudoColor)
137 *
138 * The actual allocation code lives in miindex.c, and so is
139 * austensibly server dependent, but that code does:
140 *
141 * PolicyMono Allocate no additional colors, use black and white
142 * PolicyGray Allocate 13 gray levels (11 cells used)
143 * PolicyColor Allocate a 4x4x4 cube and 13 gray levels (71 cells used)
144 * PolicyAll Allocate as big a cube as possible, fill with gray (all)
145 *
146 * Here's a picture to help understand how many colors are
147 * actually allocated (this is just the gray ramp):
148 *
149 * gray level
150 * all 0000 1555 2aaa 4000 5555 6aaa 8000 9555 aaaa bfff d555 eaaa ffff
151 * b/w 0000 ffff
152 * 4x4x4 5555 aaaa
153 * extra 1555 2aaa 4000 6aaa 8000 9555 bfff d555 eaaa
154 *
155 * The default colormap supplies two gray levels (black/white), the
156 * 4x4x4 cube allocates another two and nine more are allocated to fill
157 * in the 13 levels. When the 4x4x4 cube is not allocated, a total of
158 * 11 cells are allocated.
159 */
160
161#define PictureCmapPolicyInvalid -1
162#define PictureCmapPolicyDefault 0
163#define PictureCmapPolicyMono 1
164#define PictureCmapPolicyGray 2
165#define PictureCmapPolicyColor 3
166#define PictureCmapPolicyAll 4
167
168extern int PictureCmapPolicy;
169
170int PictureParseCmapPolicy (const char *name);
171
172extern int RenderErrBase;
173extern int RenderClientPrivateIndex;
174
175/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
176
177#if defined(WIN32) && !defined(__GNUC__)
178typedef __int64 xFixed_32_32;
179#else
180# if defined (_LP64) || \
181 defined(__alpha__) || defined(__alpha) || \
182 defined(ia64) || defined(__ia64__) || \
183 defined(__sparc64__) || \
184 defined(__s390x__) || \
185 defined(amd64) || defined (__amd64__) || \
186 (defined(sgi) && (_MIPS_SZLONG == 64))
187typedef long xFixed_32_32;
188# else
189# if defined(__GNUC__) && \
190 ((__GNUC__ > 2) || \
191 ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 7)))
192__extension__
193# endif
194typedef long long int xFixed_32_32;
195# endif
196#endif
197
198typedef xFixed_32_32 xFixed_48_16;
199
200#define MAX_FIXED_48_16 ((xFixed_48_16) 0x7fffffff)
201#define MIN_FIXED_48_16 (-((xFixed_48_16) 1 << 31))
202
203typedef CARD32 xFixed_1_31;
204typedef CARD32 xFixed_1_16;
205typedef INT32 xFixed_16_16;
206
207/*
208 * An unadorned "xFixed" is the same as xFixed_16_16,
209 * (since it's quite common in the code)
210 */
211typedef xFixed_16_16 xFixed;
212#define XFIXED_BITS 16
213
214#define xFixedToInt(f) (int) ((f) >> XFIXED_BITS)
215#define IntToxFixed(i) ((xFixed) (i) << XFIXED_BITS)
216#define xFixedE ((xFixed) 1)
217#define xFixed1 (IntToxFixed(1))
218#define xFixed1MinusE (xFixed1 - xFixedE)
219#define xFixedFrac(f) ((f) & xFixed1MinusE)
220#define xFixedFloor(f) ((f) & ~xFixed1MinusE)
221#define xFixedCeil(f) xFixedFloor((f) + xFixed1MinusE)
222
223#define xFixedFraction(f) ((f) & xFixed1MinusE)
224#define xFixedMod2(f) ((f) & (xFixed1 | xFixed1MinusE))
225
226/* whether 't' is a well defined not obviously empty trapezoid */
227#define xTrapezoidValid(t) ((t)->left.p1.y != (t)->left.p2.y && \
228 (t)->right.p1.y != (t)->right.p2.y && \
229 (int) ((t)->bottom - (t)->top) > 0)
230
231/*
232 * Standard NTSC luminance conversions:
233 *
234 * y = r * 0.299 + g * 0.587 + b * 0.114
235 *
236 * Approximate this for a bit more speed:
237 *
238 * y = (r * 153 + g * 301 + b * 58) / 512
239 *
240 * This gives 17 bits of luminance; to get 15 bits, lop the low two
241 */
242
243#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \
244 (((s) >> 8) & 0xff) * 301 + \
245 (((s) ) & 0xff) * 58) >> 2)
246
247#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