2
* $XFree86: xc/programs/Xserver/render/picture.h,v 1.18 2002/11/06 22:45:36 keithp Exp $
4
* Copyright � 2000 SuSE, Inc.
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.
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.
23
* Author: Keith Packard, SuSE, Inc.
29
typedef struct _DirectFormat *DirectFormatPtr;
30
typedef struct _PictFormat *PictFormatPtr;
31
typedef struct _Picture *PicturePtr;
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,
38
#define PICT_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \
46
* gray/color formats use a visual index instead of argb
48
#define PICT_VISFORMAT(bpp,type,vi) (((bpp) << 24) | \
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)
61
#define PICT_TYPE_OTHER 0
63
#define PICT_TYPE_ARGB 2
64
#define PICT_TYPE_ABGR 3
65
#define PICT_TYPE_COLOR 4
66
#define PICT_TYPE_GRAY 5
68
#define PICT_FORMAT_COLOR(f) (PICT_FORMAT_TYPE(f) & 2)
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)
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)
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)
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)
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)
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)
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)
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)
114
#define PICT_a1 PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0)
116
#define PICT_g1 PICT_FORMAT(1,PICT_TYPE_GRAY,0,0,0,0)
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:
123
* Size Default Policy
124
* ----------------------------
127
* 256 PolicyColor (only on PseudoColor)
129
* The actual allocation code lives in miindex.c, and so is
130
* austensibly server dependent, but that code does:
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)
137
* Here's a picture to help understand how many colors are
138
* actually allocated (this is just the gray ramp):
141
* all 0000 1555 2aaa 4000 5555 6aaa 8000 9555 aaaa bfff d555 eaaa ffff
144
* extra 1555 2aaa 4000 6aaa 8000 9555 bfff d555 eaaa
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.
152
#define PictureCmapPolicyInvalid -1
153
#define PictureCmapPolicyDefault 0
154
#define PictureCmapPolicyMono 1
155
#define PictureCmapPolicyGray 2
156
#define PictureCmapPolicyColor 3
157
#define PictureCmapPolicyAll 4
159
extern int PictureCmapPolicy;
161
int PictureParseCmapPolicy (const char *name);
163
/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
166
typedef __int64 xFixed_32_32;
168
# if defined(__alpha__) || defined(__alpha) || \
169
defined(ia64) || defined(__ia64__) || \
170
defined(__sparc64__) || \
171
defined(__s390x__) || \
172
defined(x86_64) || defined (__x86_64__)
173
typedef long xFixed_32_32;
175
# if defined(__GNUC__) && \
177
((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 7)))
180
typedef long long int xFixed_32_32;
184
typedef CARD32 xFixed_1_31;
185
typedef CARD32 xFixed_1_16;
186
typedef INT32 xFixed_16_16;
189
* An unadorned "xFixed" is the same as xFixed_16_16,
190
* (since it's quite common in the code)
192
typedef xFixed_16_16 xFixed;
193
#define XFIXED_BITS 16
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)
204
#define xFixedFraction(f) ((f) & xFixed1MinusE)
205
#define xFixedMod2(f) ((f) & (xFixed1 | xFixed1MinusE))
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)
213
* Standard NTSC luminance conversions:
215
* y = r * 0.299 + g * 0.587 + b * 0.114
217
* Approximate this for a bit more speed:
219
* y = (r * 153 + g * 301 + b * 58) / 512
221
* This gives 17 bits of luminance; to get 15 bits, lop the low two
224
#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \
225
(((s) >> 8) & 0xff) * 301 + \
226
(((s) ) & 0xff) * 58) >> 2)
228
#endif /* _PICTURE_H_ */