xref: /haiku/headers/os/interface/GraphicsDefs.h (revision 51978af14a173e7fae0563b562be5603bc652aeb)
1 //------------------------------------------------------------------------------
2 //	Copyright (c) 2001-2002, OpenBeOS
3 //
4 //	Permission is hereby granted, free of charge, to any person obtaining a
5 //	copy of this software and associated documentation files (the "Software"),
6 //	to deal in the Software without restriction, including without limitation
7 //	the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 //	and/or sell copies of the Software, and to permit persons to whom the
9 //	Software is furnished to do so, subject to the following conditions:
10 //
11 //	The above copyright notice and this permission notice shall be included in
12 //	all copies or substantial portions of the Software.
13 //
14 //	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 //	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 //	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 //	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 //	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 //	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 //	DEALINGS IN THE SOFTWARE.
21 //
22 //	File Name:		GraphicsDefs.h
23 //	Author:			Frans van Nispen
24 //	Description:	BMessageFilter class creates objects that filter
25 //					in-coming BMessages.
26 //------------------------------------------------------------------------------
27 
28 #ifndef _GRAPHICS_DEFS_H
29 #define _GRAPHICS_DEFS_H
30 
31 // Standard Includes -----------------------------------------------------------
32 
33 // System Includes -------------------------------------------------------------
34 #include <BeBuild.h>
35 #include <SupportDefs.h>
36 
37 // Project Includes ------------------------------------------------------------
38 
39 // Local Includes --------------------------------------------------------------
40 
41 // Local Defines ---------------------------------------------------------------
42 
43 // Globals ---------------------------------------------------------------------
44 
45 
46 //------------------------------------------------------------------------------
47 
48 typedef struct pattern {
49 		uint8		data[8];
50 } pattern;
51 
52 extern _IMPEXP_BE const pattern B_SOLID_HIGH;
53 extern _IMPEXP_BE const pattern B_MIXED_COLORS;
54 extern _IMPEXP_BE const pattern B_SOLID_LOW;
55 
56 //------------------------------------------------------------------------------
57 
58 typedef struct rgb_color {
59 	uint8		red;
60 	uint8		green;
61 	uint8		blue;
62 	uint8		alpha;
63 } rgb_color;
64 
65 //------------------------------------------------------------------------------
66 
67 extern _IMPEXP_BE const rgb_color 	B_TRANSPARENT_COLOR;
68 extern _IMPEXP_BE const uint8		B_TRANSPARENT_MAGIC_CMAP8;
69 extern _IMPEXP_BE const uint16		B_TRANSPARENT_MAGIC_RGBA15;
70 extern _IMPEXP_BE const uint16		B_TRANSPARENT_MAGIC_RGBA15_BIG;
71 extern _IMPEXP_BE const uint32		B_TRANSPARENT_MAGIC_RGBA32;
72 extern _IMPEXP_BE const uint32		B_TRANSPARENT_MAGIC_RGBA32_BIG;
73 
74 extern _IMPEXP_BE const uint8 		B_TRANSPARENT_8_BIT;
75 extern _IMPEXP_BE const rgb_color	B_TRANSPARENT_32_BIT;
76 
77 //------------------------------------------------------------------------------
78 
79 typedef struct color_map {
80 	int32				id;
81 	rgb_color			color_list[256];
82 	uint8				inversion_map[256];
83 	uint8				index_map[32768];
84 } color_map;
85 
86 typedef struct overlay_rect_limits {
87 	uint16				horizontal_alignment;
88 	uint16				vertical_alignment;
89 	uint16				width_alignment;
90 	uint16				height_alignment;
91 	uint16				min_width;
92 	uint16				max_width;
93 	uint16				min_height;
94 	uint16				max_height;
95 	uint32				reserved[8];
96 } overlay_rect_limits;
97 
98 typedef struct overlay_restrictions {
99 	overlay_rect_limits	source;
100 	overlay_rect_limits	destination;
101 	float				min_width_scale;
102 	float				max_width_scale;
103 	float				min_height_scale;
104 	float				max_height_scale;
105 	uint32				reserved[8];
106 } overlay_restrictions;
107 
108 //------------------------------------------------------------------------------
109 
110 struct screen_id { int32 id; };
111 
112 extern _IMPEXP_BE const struct screen_id B_MAIN_SCREEN_ID;
113 
114 //------------------------------------------------------------------------------
115 
116 typedef enum
117 {
118 	B_NO_COLOR_SPACE =	0x0000,	//* byte in memory order, high bit first
119 
120 	// linear color space (little endian is the default)
121 	B_RGB32 = 			0x0008,	//* B[7:0]  G[7:0]  R[7:0]  -[7:0]
122 	B_RGBA32 = 			0x2008,	// B[7:0]  G[7:0]  R[7:0]  A[7:0]
123 	B_RGB24 = 			0x0003,	// B[7:0]  G[7:0]  R[7:0]
124 	B_RGB16 = 			0x0005,	// G[2:0],B[4:0]  R[4:0],G[5:3]
125 	B_RGB15 = 			0x0010,	// G[2:0],B[4:0]  	   -[0],R[4:0],G[4:3]
126 	B_RGBA15 = 			0x2010,	// G[2:0],B[4:0]  	   A[0],R[4:0],G[4:3]
127 	B_CMAP8 = 			0x0004,	// D[7:0]
128 	B_GRAY8 = 			0x0002,	// Y[7:0]
129 	B_GRAY1 = 			0x0001,	// Y0[0],Y1[0],Y2[0],Y3[0],Y4[0],Y5[0],Y6[0],Y7[0]
130 
131 	// big endian version, when the encoding is not endianess independant
132 	B_RGB32_BIG =		0x1008,	// -[7:0]  R[7:0]  G[7:0]  B[7:0]
133 	B_RGBA32_BIG = 		0x3008,	// A[7:0]  R[7:0]  G[7:0]  B[7:0]
134 	B_RGB24_BIG = 		0x1003,	// R[7:0]  G[7:0]  B[7:0]
135 	B_RGB16_BIG = 		0x1005,	// R[4:0],G[5:3]  G[2:0],B[4:0]
136 	B_RGB15_BIG = 		0x1010,	// -[0],R[4:0],G[4:3]  G[2:0],B[4:0]
137 	B_RGBA15_BIG = 		0x3010,	// A[0],R[4:0],G[4:3]  G[2:0],B[4:0]
138 
139 	// little-endian declarations, for completness
140 	B_RGB32_LITTLE = 	B_RGB32,
141 	B_RGBA32_LITTLE =	B_RGBA32,
142 	B_RGB24_LITTLE =	B_RGB24,
143 	B_RGB16_LITTLE =	B_RGB16,
144 	B_RGB15_LITTLE =	B_RGB15,
145 	B_RGBA15_LITTLE =	B_RGBA15,
146 
147 	// non linear color space -- note that these are here for exchange purposes;
148 	// a BBitmap or BView may not necessarily support all these color spaces.
149 
150 	// Loss/Saturation points are Y 16-235 (absoulte); Cb/Cr 16-240 (center 128)
151 
152 	B_YCbCr422 = 		0x4000,	// Y0[7:0]  Cb0[7:0]  Y1[7:0]  Cr0[7:0]  Y2[7:0]...
153 								// Cb2[7:0]  Y3[7:0]  Cr2[7:0]
154 	B_YCbCr411 = 		0x4001,	// Cb0[7:0]  Y0[7:0]  Cr0[7:0]  Y1[7:0]  Cb4[7:0]...
155 								// Y2[7:0]  Cr4[7:0]  Y3[7:0]  Y4[7:0]  Y5[7:0]...
156 								// Y6[7:0]  Y7[7:0]
157 	B_YCbCr444 = 		0x4003,	// Y0[7:0]  Cb0[7:0]  Cr0[7:0]
158 	B_YCbCr420 = 		0x4004,	// Non-interlaced only, Cb0  Y0  Y1  Cb2 Y2  Y3
159 								// on even scan lines,  Cr0  Y0  Y1  Cr2 Y2  Y3
160 								// on odd scan lines
161 
162 	// Extrema points are
163 	//		Y 0 - 207 (absolute)
164 	//		U -91 - 91 (offset 128)
165 	//		V -127 - 127 (offset 128)
166 	// note that YUV byte order is different from YCbCr
167 	// USE YCbCr, not YUV, when that's what you mean!
168 	B_YUV422 =			0x4020, // U0[7:0]  Y0[7:0]   V0[7:0]  Y1[7:0] ...
169 								// U2[7:0]  Y2[7:0]   V2[7:0]  Y3[7:0]
170 	B_YUV411 =			0x4021, // U0[7:0]  Y0[7:0]  Y1[7:0]  V0[7:0]  Y2[7:0]  Y3[7:0]
171 								// U4[7:0]  Y4[7:0]  Y5[7:0]  V4[7:0]  Y6[7:0]  Y7[7:0]
172 	B_YUV444 =			0x4023,	// U0[7:0]  Y0[7:0]  V0[7:0]  U1[7:0]  Y1[7:0]  V1[7:0]
173 	B_YUV420 = 			0x4024,	// Non-interlaced only, U0  Y0  Y1  U2 Y2  Y3
174 								// on even scan lines,  V0  Y0  Y1  V2 Y2  Y3
175 								// on odd scan lines
176 	B_YUV9 = 			0x402C,	// planar?	410?
177 	B_YUV12 = 			0x402D,	// planar?	420?
178 
179 	B_UVL24 =			0x4030,	// U0[7:0] V0[7:0] L0[7:0] ...
180 	B_UVL32 =			0x4031,	// U0[7:0] V0[7:0] L0[7:0] X0[7:0]...
181 	B_UVLA32 =			0x6031,	// U0[7:0] V0[7:0] L0[7:0] A0[7:0]...
182 
183 	B_LAB24 =			0x4032,	// L0[7:0] a0[7:0] b0[7:0] ...  (a is not alpha!)
184 	B_LAB32 =			0x4033,	// L0[7:0] a0[7:0] b0[7:0] X0[7:0] ... (b is not alpha!)
185 	B_LABA32 =			0x6033,	// L0[7:0] a0[7:0] b0[7:0] A0[7:0] ... (A is alpha)
186 
187 	// red is at hue = 0
188 
189 	B_HSI24 =			0x4040,	// H[7:0]  S[7:0]  I[7:0]
190 	B_HSI32 =			0x4041,	// H[7:0]  S[7:0]  I[7:0]  X[7:0]
191 	B_HSIA32 =			0x6041,	// H[7:0]  S[7:0]  I[7:0]  A[7:0]
192 
193 	B_HSV24 =			0x4042,	// H[7:0]  S[7:0]  V[7:0]
194 	B_HSV32 =			0x4043,	// H[7:0]  S[7:0]  V[7:0]  X[7:0]
195 	B_HSVA32 =			0x6043,	// H[7:0]  S[7:0]  V[7:0]  A[7:0]
196 
197 	B_HLS24 =			0x4044,	// H[7:0]  L[7:0]  S[7:0]
198 	B_HLS32 =			0x4045,	// H[7:0]  L[7:0]  S[7:0]  X[7:0]
199 	B_HLSA32 =			0x6045,	// H[7:0]  L[7:0]  S[7:0]  A[7:0]
200 
201 	B_CMY24 =			0xC001,	// C[7:0]  M[7:0]  Y[7:0]  			No gray removal done
202 	B_CMY32 =			0xC002,	// C[7:0]  M[7:0]  Y[7:0]  X[7:0]	No gray removal done
203 	B_CMYA32 =			0xE002,	// C[7:0]  M[7:0]  Y[7:0]  A[7:0]	No gray removal done
204 	B_CMYK32 =			0xC003,	// C[7:0]  M[7:0]  Y[7:0]  K[7:0]
205 
206 	// compatibility declarations
207 	B_MONOCHROME_1_BIT = 	B_GRAY1,
208 	B_GRAYSCALE_8_BIT =		B_GRAY8,
209 	B_COLOR_8_BIT =			B_CMAP8,
210 	B_RGB_32_BIT =			B_RGB32,
211 	B_RGB_16_BIT =			B_RGB15,
212 	B_BIG_RGB_32_BIT =		B_RGB32_BIG,
213 	B_BIG_RGB_16_BIT =		B_RGB15_BIG
214 } color_space;
215 
216 
217 // Find out whether a specific color space is supported by BBitmaps.
218 // Support_flags will be set to what kinds of support are available.
219 // If support_flags is set to 0, false will be returned.
220 enum {
221 	B_VIEWS_SUPPORT_DRAW_BITMAP = 0x1,
222 	B_BITMAPS_SUPPORT_ATTACHED_VIEWS = 0x2
223 };
224 _IMPEXP_BE bool bitmaps_support_space(color_space space, uint32 * support_flags);
225 
226 //------------------------------------------------------------------------------
227 // "pixel_chunk" is the native increment from one pixel starting on an integral byte
228 // to the next. "row_alignment" is the native alignment for pixel scanline starts.
229 // "pixels_per_chunk" is the number of pixels in a pixel_chunk. For instance, B_GRAY1
230 // sets pixel_chunk to 1, row_alignment to 4 and pixels_per_chunk to 8, whereas
231 // B_RGB24 sets pixel_chunk to 3, row_alignment to 4 and pixels_per_chunk to 1.
232 //------------------------------------------------------------------------------
233 _IMPEXP_BE status_t get_pixel_size_for(color_space space, size_t * pixel_chunk,
234 	size_t * row_alignment, size_t * pixels_per_chunk);
235 
236 
237 enum buffer_orientation {
238 	B_BUFFER_TOP_TO_BOTTOM,
239 	B_BUFFER_BOTTOM_TO_TOP
240 };
241 
242 enum buffer_layout {
243 	B_BUFFER_NONINTERLEAVED = 1
244 };
245 
246 //------------------------------------------------------------------------------
247 
248 enum drawing_mode {
249 	B_OP_COPY,
250 	B_OP_OVER,
251 	B_OP_ERASE,
252 	B_OP_INVERT,
253 	B_OP_ADD,
254 	B_OP_SUBTRACT,
255 	B_OP_BLEND,
256 	B_OP_MIN,
257 	B_OP_MAX,
258 	B_OP_SELECT,
259 	B_OP_ALPHA
260 };
261 
262 enum source_alpha {
263 	B_PIXEL_ALPHA=0,
264 	B_CONSTANT_ALPHA
265 };
266 
267 enum alpha_function {
268 	B_ALPHA_OVERLAY=0,
269 	B_ALPHA_COMPOSITE
270 };
271 
272 enum {
273 	B_8_BIT_640x480    = 0x00000001,
274 	B_8_BIT_800x600    = 0x00000002,
275 	B_8_BIT_1024x768   = 0x00000004,
276 	B_8_BIT_1280x1024  = 0x00000008,
277 	B_8_BIT_1600x1200  = 0x00000010,
278 	B_16_BIT_640x480   = 0x00000020,
279 	B_16_BIT_800x600   = 0x00000040,
280 	B_16_BIT_1024x768  = 0x00000080,
281 	B_16_BIT_1280x1024 = 0x00000100,
282 	B_16_BIT_1600x1200 = 0x00000200,
283 	B_32_BIT_640x480   = 0x00000400,
284 	B_32_BIT_800x600   = 0x00000800,
285 	B_32_BIT_1024x768  = 0x00001000,
286 	B_32_BIT_1280x1024 = 0x00002000,
287 	B_32_BIT_1600x1200 = 0x00004000,
288     B_8_BIT_1152x900   = 0x00008000,
289     B_16_BIT_1152x900  = 0x00010000,
290     B_32_BIT_1152x900  = 0x00020000,
291 	B_15_BIT_640x480   = 0x00040000,
292 	B_15_BIT_800x600   = 0x00080000,
293 	B_15_BIT_1024x768  = 0x00100000,
294 	B_15_BIT_1280x1024 = 0x00200000,
295 	B_15_BIT_1600x1200 = 0x00400000,
296     B_15_BIT_1152x900  = 0x00800000,
297 
298 	// do not use B_FAKE_DEVICE--it will go away!
299 	B_FAKE_DEVICE	   = 0x40000000,
300 	B_8_BIT_640x400	   = (int)0x80000000
301 };
302 
303 #endif	// _GRAPHICSDEFS_H
304 
305 /*
306  * $Log $
307  *
308  * $Id  $
309  *
310  */
311 
312