VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/XFree86-4.3/Xserver/picture.h@ 78293

Last change on this file since 78293 was 69098, checked in by vboxsync, 7 years ago

Clean up XFree86 driver header files.
bugref:3810: X11 Guest Additions maintenance
Over the years we have cleaned up the layout in the tree of the X.Org
header files we use to build drivers. The XFree86 ones were still in their
original, rather sub-optimal layout. This change fixes that.

  • Property svn:eol-style set to native
File size: 8.0 KB
Line 
1/*
2 * $XFree86: xc/programs/Xserver/render/picture.h,v 1.18 2002/11/06 22:45:36 keithp 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,4,4,4,4)
90#define PICT_a4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
91#define PICT_x4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,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
163/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
164
165#ifdef WIN32
166typedef __int64 xFixed_32_32;
167#else
168# if defined(__alpha__) || defined(__alpha) || \
169 defined(ia64) || defined(__ia64__) || \
170 defined(__sparc64__) || \
171 defined(__s390x__) || \
172 defined(x86_64) || defined (__x86_64__)
173typedef long xFixed_32_32;
174# else
175# if defined(__GNUC__) && \
176 ((__GNUC__ > 2) || \
177 ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 7)))
178__extension__
179# endif
180typedef long long int xFixed_32_32;
181# endif
182#endif
183
184typedef CARD32 xFixed_1_31;
185typedef CARD32 xFixed_1_16;
186typedef INT32 xFixed_16_16;
187
188/*
189 * An unadorned "xFixed" is the same as xFixed_16_16,
190 * (since it's quite common in the code)
191 */
192typedef xFixed_16_16 xFixed;
193#define XFIXED_BITS 16
194
195#define xFixedToInt(f) (int) ((f) >> XFIXED_BITS)
196#define IntToxFixed(i) ((xFixed) (i) << XFIXED_BITS)
197#define xFixedE ((xFixed) 1)
198#define xFixed1 (IntToxFixed(1))
199#define xFixed1MinusE (xFixed1 - xFixedE)
200#define xFixedFrac(f) ((f) & xFixed1MinusE)
201#define xFixedFloor(f) ((f) & ~xFixed1MinusE)
202#define xFixedCeil(f) xFixedFloor((f) + xFixed1MinusE)
203
204#define xFixedFraction(f) ((f) & xFixed1MinusE)
205#define xFixedMod2(f) ((f) & (xFixed1 | xFixed1MinusE))
206
207/* whether 't' is a well defined not obviously empty trapezoid */
208#define xTrapezoidValid(t) ((t)->left.p1.y != (t)->left.p2.y && \
209 (t)->right.p1.y != (t)->right.p2.y && \
210 (int) ((t)->bottom - (t)->top) > 0)
211
212/*
213 * Standard NTSC luminance conversions:
214 *
215 * y = r * 0.299 + g * 0.587 + b * 0.114
216 *
217 * Approximate this for a bit more speed:
218 *
219 * y = (r * 153 + g * 301 + b * 58) / 512
220 *
221 * This gives 17 bits of luminance; to get 15 bits, lop the low two
222 */
223
224#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \
225 (((s) >> 8) & 0xff) * 301 + \
226 (((s) ) & 0xff) * 58) >> 2)
227
228#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