xref: /haiku/headers/build/os/interface/GraphicsDefs.h (revision 93aeb8c3bc3f13cb1f282e3e749258a23790d947)
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 #ifdef __cplusplus
53 
54 inline bool
55 operator==(const pattern& a, const pattern& b)
56 {
57 	return (*(uint64*)a.data == *(uint64*)b.data);
58 }
59 
60 #endif // __cplusplus
61 
62 extern _IMPEXP_BE const pattern B_SOLID_HIGH;
63 extern _IMPEXP_BE const pattern B_MIXED_COLORS;
64 extern _IMPEXP_BE const pattern B_SOLID_LOW;
65 
66 //------------------------------------------------------------------------------
67 
68 typedef struct rgb_color {
69 	uint8		red;
70 	uint8		green;
71 	uint8		blue;
72 	uint8		alpha;
73 
74 #if defined(__cplusplus)
75 	// some convenient additions
76 
77 	inline bool
78 	operator==(const rgb_color& other) const
79 	{
80 		return *(const uint32 *)this == *(const uint32 *)&other;
81 	}
82 
83 	inline bool
84 	operator!=(const rgb_color& other) const
85 	{
86 		return *(const uint32 *)this != *(const uint32 *)&other;
87 	}
88 #endif
89 } rgb_color;
90 
91 //------------------------------------------------------------------------------
92 
93 extern _IMPEXP_BE const rgb_color 	B_TRANSPARENT_COLOR;
94 extern _IMPEXP_BE const uint8		B_TRANSPARENT_MAGIC_CMAP8;
95 extern _IMPEXP_BE const uint16		B_TRANSPARENT_MAGIC_RGBA15;
96 extern _IMPEXP_BE const uint16		B_TRANSPARENT_MAGIC_RGBA15_BIG;
97 extern _IMPEXP_BE const uint32		B_TRANSPARENT_MAGIC_RGBA32;
98 extern _IMPEXP_BE const uint32		B_TRANSPARENT_MAGIC_RGBA32_BIG;
99 
100 extern _IMPEXP_BE const uint8 		B_TRANSPARENT_8_BIT;
101 extern _IMPEXP_BE const rgb_color	B_TRANSPARENT_32_BIT;
102 
103 //------------------------------------------------------------------------------
104 
105 typedef struct color_map {
106 	int32				id;
107 	rgb_color			color_list[256];
108 	uint8				inversion_map[256];
109 	uint8				index_map[32768];
110 } color_map;
111 
112 typedef struct overlay_rect_limits {
113 	uint16				horizontal_alignment;
114 	uint16				vertical_alignment;
115 	uint16				width_alignment;
116 	uint16				height_alignment;
117 	uint16				min_width;
118 	uint16				max_width;
119 	uint16				min_height;
120 	uint16				max_height;
121 	uint32				reserved[8];
122 } overlay_rect_limits;
123 
124 typedef struct overlay_restrictions {
125 	overlay_rect_limits	source;
126 	overlay_rect_limits	destination;
127 	float				min_width_scale;
128 	float				max_width_scale;
129 	float				min_height_scale;
130 	float				max_height_scale;
131 	uint32				reserved[8];
132 } overlay_restrictions;
133 
134 //------------------------------------------------------------------------------
135 
136 struct screen_id { int32 id; };
137 
138 extern _IMPEXP_BE const struct screen_id B_MAIN_SCREEN_ID;
139 
140 //------------------------------------------------------------------------------
141 
142 typedef enum
143 {
144 	B_NO_COLOR_SPACE =	0x0000,	//* byte in memory order, high bit first
145 
146 	// linear color space (little endian is the default)
147 	B_RGB32 = 			0x0008,	//* B[7:0]  G[7:0]  R[7:0]  -[7:0]
148 	B_RGBA32 = 			0x2008,	// B[7:0]  G[7:0]  R[7:0]  A[7:0]
149 	B_RGB24 = 			0x0003,	// B[7:0]  G[7:0]  R[7:0]
150 	B_RGB16 = 			0x0005,	// G[2:0],B[4:0]  R[4:0],G[5:3]
151 	B_RGB15 = 			0x0010,	// G[2:0],B[4:0]  	   -[0],R[4:0],G[4:3]
152 	B_RGBA15 = 			0x2010,	// G[2:0],B[4:0]  	   A[0],R[4:0],G[4:3]
153 	B_CMAP8 = 			0x0004,	// D[7:0]
154 	B_GRAY8 = 			0x0002,	// Y[7:0]
155 	B_GRAY1 = 			0x0001,	// Y0[0],Y1[0],Y2[0],Y3[0],Y4[0],Y5[0],Y6[0],Y7[0]
156 
157 	// big endian version, when the encoding is not endianess independant
158 	B_RGB32_BIG =		0x1008,	// -[7:0]  R[7:0]  G[7:0]  B[7:0]
159 	B_RGBA32_BIG = 		0x3008,	// A[7:0]  R[7:0]  G[7:0]  B[7:0]
160 	B_RGB24_BIG = 		0x1003,	// R[7:0]  G[7:0]  B[7:0]
161 	B_RGB16_BIG = 		0x1005,	// R[4:0],G[5:3]  G[2:0],B[4:0]
162 	B_RGB15_BIG = 		0x1010,	// -[0],R[4:0],G[4:3]  G[2:0],B[4:0]
163 	B_RGBA15_BIG = 		0x3010,	// A[0],R[4:0],G[4:3]  G[2:0],B[4:0]
164 
165 	// little-endian declarations, for completness
166 	B_RGB32_LITTLE = 	B_RGB32,
167 	B_RGBA32_LITTLE =	B_RGBA32,
168 	B_RGB24_LITTLE =	B_RGB24,
169 	B_RGB16_LITTLE =	B_RGB16,
170 	B_RGB15_LITTLE =	B_RGB15,
171 	B_RGBA15_LITTLE =	B_RGBA15,
172 
173 	// non linear color space -- note that these are here for exchange purposes;
174 	// a BBitmap or BView may not necessarily support all these color spaces.
175 
176 	// Loss/Saturation points are Y 16-235 (absoulte); Cb/Cr 16-240 (center 128)
177 
178 	B_YCbCr422 = 		0x4000,	// Y0[7:0]  Cb0[7:0]  Y1[7:0]  Cr0[7:0]  Y2[7:0]...
179 								// Cb2[7:0]  Y3[7:0]  Cr2[7:0]
180 	B_YCbCr411 = 		0x4001,	// Cb0[7:0]  Y0[7:0]  Cr0[7:0]  Y1[7:0]  Cb4[7:0]...
181 								// Y2[7:0]  Cr4[7:0]  Y3[7:0]  Y4[7:0]  Y5[7:0]...
182 								// Y6[7:0]  Y7[7:0]
183 	B_YCbCr444 = 		0x4003,	// Y0[7:0]  Cb0[7:0]  Cr0[7:0]
184 	B_YCbCr420 = 		0x4004,	// Non-interlaced only, Cb0  Y0  Y1  Cb2 Y2  Y3
185 								// on even scan lines,  Cr0  Y0  Y1  Cr2 Y2  Y3
186 								// on odd scan lines
187 
188 	// Extrema points are
189 	//		Y 0 - 207 (absolute)
190 	//		U -91 - 91 (offset 128)
191 	//		V -127 - 127 (offset 128)
192 	// note that YUV byte order is different from YCbCr
193 	// USE YCbCr, not YUV, when that's what you mean!
194 	B_YUV422 =			0x4020, // U0[7:0]  Y0[7:0]   V0[7:0]  Y1[7:0] ...
195 								// U2[7:0]  Y2[7:0]   V2[7:0]  Y3[7:0]
196 	B_YUV411 =			0x4021, // U0[7:0]  Y0[7:0]  Y1[7:0]  V0[7:0]  Y2[7:0]  Y3[7:0]
197 								// U4[7:0]  Y4[7:0]  Y5[7:0]  V4[7:0]  Y6[7:0]  Y7[7:0]
198 	B_YUV444 =			0x4023,	// U0[7:0]  Y0[7:0]  V0[7:0]  U1[7:0]  Y1[7:0]  V1[7:0]
199 	B_YUV420 = 			0x4024,	// Non-interlaced only, U0  Y0  Y1  U2 Y2  Y3
200 								// on even scan lines,  V0  Y0  Y1  V2 Y2  Y3
201 								// on odd scan lines
202 	B_YUV9 = 			0x402C,	// planar?	410?
203 	B_YUV12 = 			0x402D,	// planar?	420?
204 
205 	B_UVL24 =			0x4030,	// U0[7:0] V0[7:0] L0[7:0] ...
206 	B_UVL32 =			0x4031,	// U0[7:0] V0[7:0] L0[7:0] X0[7:0]...
207 	B_UVLA32 =			0x6031,	// U0[7:0] V0[7:0] L0[7:0] A0[7:0]...
208 
209 	B_LAB24 =			0x4032,	// L0[7:0] a0[7:0] b0[7:0] ...  (a is not alpha!)
210 	B_LAB32 =			0x4033,	// L0[7:0] a0[7:0] b0[7:0] X0[7:0] ... (b is not alpha!)
211 	B_LABA32 =			0x6033,	// L0[7:0] a0[7:0] b0[7:0] A0[7:0] ... (A is alpha)
212 
213 	// red is at hue = 0
214 
215 	B_HSI24 =			0x4040,	// H[7:0]  S[7:0]  I[7:0]
216 	B_HSI32 =			0x4041,	// H[7:0]  S[7:0]  I[7:0]  X[7:0]
217 	B_HSIA32 =			0x6041,	// H[7:0]  S[7:0]  I[7:0]  A[7:0]
218 
219 	B_HSV24 =			0x4042,	// H[7:0]  S[7:0]  V[7:0]
220 	B_HSV32 =			0x4043,	// H[7:0]  S[7:0]  V[7:0]  X[7:0]
221 	B_HSVA32 =			0x6043,	// H[7:0]  S[7:0]  V[7:0]  A[7:0]
222 
223 	B_HLS24 =			0x4044,	// H[7:0]  L[7:0]  S[7:0]
224 	B_HLS32 =			0x4045,	// H[7:0]  L[7:0]  S[7:0]  X[7:0]
225 	B_HLSA32 =			0x6045,	// H[7:0]  L[7:0]  S[7:0]  A[7:0]
226 
227 	B_CMY24 =			0xC001,	// C[7:0]  M[7:0]  Y[7:0]  			No gray removal done
228 	B_CMY32 =			0xC002,	// C[7:0]  M[7:0]  Y[7:0]  X[7:0]	No gray removal done
229 	B_CMYA32 =			0xE002,	// C[7:0]  M[7:0]  Y[7:0]  A[7:0]	No gray removal done
230 	B_CMYK32 =			0xC003,	// C[7:0]  M[7:0]  Y[7:0]  K[7:0]
231 
232 	// compatibility declarations
233 	B_MONOCHROME_1_BIT = 	B_GRAY1,
234 	B_GRAYSCALE_8_BIT =		B_GRAY8,
235 	B_COLOR_8_BIT =			B_CMAP8,
236 	B_RGB_32_BIT =			B_RGB32,
237 	B_RGB_16_BIT =			B_RGB15,
238 	B_BIG_RGB_32_BIT =		B_RGB32_BIG,
239 	B_BIG_RGB_16_BIT =		B_RGB15_BIG
240 } color_space;
241 
242 
243 // Find out whether a specific color space is supported by BBitmaps.
244 // Support_flags will be set to what kinds of support are available.
245 // If support_flags is set to 0, false will be returned.
246 enum {
247 	B_VIEWS_SUPPORT_DRAW_BITMAP = 0x1,
248 	B_BITMAPS_SUPPORT_ATTACHED_VIEWS = 0x2
249 };
250 _IMPEXP_BE bool bitmaps_support_space(color_space space, uint32 * support_flags);
251 
252 //------------------------------------------------------------------------------
253 // "pixel_chunk" is the native increment from one pixel starting on an integral byte
254 // to the next. "row_alignment" is the native alignment for pixel scanline starts.
255 // "pixels_per_chunk" is the number of pixels in a pixel_chunk. For instance, B_GRAY1
256 // sets pixel_chunk to 1, row_alignment to 4 and pixels_per_chunk to 8, whereas
257 // B_RGB24 sets pixel_chunk to 3, row_alignment to 4 and pixels_per_chunk to 1.
258 //------------------------------------------------------------------------------
259 _IMPEXP_BE status_t get_pixel_size_for(color_space space, size_t * pixel_chunk,
260 	size_t * row_alignment, size_t * pixels_per_chunk);
261 
262 
263 enum buffer_orientation {
264 	B_BUFFER_TOP_TO_BOTTOM,
265 	B_BUFFER_BOTTOM_TO_TOP
266 };
267 
268 enum buffer_layout {
269 	B_BUFFER_NONINTERLEAVED = 1
270 };
271 
272 //------------------------------------------------------------------------------
273 
274 enum drawing_mode {
275 	B_OP_COPY,
276 	B_OP_OVER,
277 	B_OP_ERASE,
278 	B_OP_INVERT,
279 	B_OP_ADD,
280 	B_OP_SUBTRACT,
281 	B_OP_BLEND,
282 	B_OP_MIN,
283 	B_OP_MAX,
284 	B_OP_SELECT,
285 	B_OP_ALPHA
286 };
287 
288 enum source_alpha {
289 	B_PIXEL_ALPHA=0,
290 	B_CONSTANT_ALPHA
291 };
292 
293 enum alpha_function {
294 	B_ALPHA_OVERLAY=0,
295 	B_ALPHA_COMPOSITE
296 };
297 
298 enum {
299 	B_8_BIT_640x480    = 0x00000001,
300 	B_8_BIT_800x600    = 0x00000002,
301 	B_8_BIT_1024x768   = 0x00000004,
302 	B_8_BIT_1280x1024  = 0x00000008,
303 	B_8_BIT_1600x1200  = 0x00000010,
304 	B_16_BIT_640x480   = 0x00000020,
305 	B_16_BIT_800x600   = 0x00000040,
306 	B_16_BIT_1024x768  = 0x00000080,
307 	B_16_BIT_1280x1024 = 0x00000100,
308 	B_16_BIT_1600x1200 = 0x00000200,
309 	B_32_BIT_640x480   = 0x00000400,
310 	B_32_BIT_800x600   = 0x00000800,
311 	B_32_BIT_1024x768  = 0x00001000,
312 	B_32_BIT_1280x1024 = 0x00002000,
313 	B_32_BIT_1600x1200 = 0x00004000,
314     B_8_BIT_1152x900   = 0x00008000,
315     B_16_BIT_1152x900  = 0x00010000,
316     B_32_BIT_1152x900  = 0x00020000,
317 	B_15_BIT_640x480   = 0x00040000,
318 	B_15_BIT_800x600   = 0x00080000,
319 	B_15_BIT_1024x768  = 0x00100000,
320 	B_15_BIT_1280x1024 = 0x00200000,
321 	B_15_BIT_1600x1200 = 0x00400000,
322     B_15_BIT_1152x900  = 0x00800000,
323 
324 	// do not use B_FAKE_DEVICE--it will go away!
325 	B_FAKE_DEVICE	   = 0x40000000,
326 	B_8_BIT_640x400	   = (int)0x80000000
327 };
328 
329 #endif	// _GRAPHICSDEFS_H
330 
331 /*
332  * $Log $
333  *
334  * $Id  $
335  *
336  */
337 
338