Make UEFI boot-platform build again
[haiku.git] / headers / os / interface / GraphicsDefs.h
blobe98d6deba00be0c53748d6fb08b634b28233f15b
1 /*
2 * Copyright 2008-2015 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _GRAPHICS_DEFS_H
6 #define _GRAPHICS_DEFS_H
9 #include <SupportDefs.h>
12 // Pattern
13 typedef struct pattern {
14 uint8 data[8];
15 } pattern;
18 #ifdef __cplusplus
19 inline bool
20 operator==(const pattern& a, const pattern& b)
22 uint64* pa = (uint64*)a.data;
23 uint64* pb = (uint64*)b.data;
24 return (*pa == *pb);
28 inline bool
29 operator!=(const pattern& a, const pattern& b)
31 return !(a == b);
33 #endif // __cplusplus
36 extern const pattern B_SOLID_HIGH;
37 extern const pattern B_MIXED_COLORS;
38 extern const pattern B_SOLID_LOW;
41 // rgb_color
42 typedef struct rgb_color {
43 uint8 red;
44 uint8 green;
45 uint8 blue;
46 uint8 alpha;
48 #if defined(__cplusplus)
49 // some convenient additions
50 inline rgb_color&
51 set_to(uint8 r, uint8 g, uint8 b, uint8 a = 255)
53 red = r;
54 green = g;
55 blue = b;
56 alpha = a;
57 return *this;
60 int32 Brightness() const;
62 inline bool
63 operator==(const rgb_color& other) const
65 return *(const uint32 *)this == *(const uint32 *)&other;
68 inline bool
69 operator!=(const rgb_color& other) const
71 return *(const uint32 *)this != *(const uint32 *)&other;
74 inline rgb_color&
75 operator=(const rgb_color& other)
77 return set_to(other.red, other.green, other.blue, other.alpha);
79 #endif
80 } rgb_color;
83 #if defined(__cplusplus)
84 inline rgb_color
85 make_color(uint8 red, uint8 green, uint8 blue, uint8 alpha = 255)
87 rgb_color color = {red, green, blue, alpha};
88 return color;
90 #endif
93 rgb_color mix_color(rgb_color color1, rgb_color color2, uint8 amount);
94 rgb_color blend_color(rgb_color color1, rgb_color color2, uint8 amount);
95 rgb_color disable_color(rgb_color color, rgb_color background);
98 extern const rgb_color B_TRANSPARENT_COLOR;
99 extern const uint8 B_TRANSPARENT_MAGIC_CMAP8;
100 extern const uint16 B_TRANSPARENT_MAGIC_RGBA15;
101 extern const uint16 B_TRANSPARENT_MAGIC_RGBA15_BIG;
102 extern const uint32 B_TRANSPARENT_MAGIC_RGBA32;
103 extern const uint32 B_TRANSPARENT_MAGIC_RGBA32_BIG;
104 extern const uint8 B_TRANSPARENT_8_BIT;
105 extern const rgb_color B_TRANSPARENT_32_BIT;
108 // color map
109 typedef struct color_map {
110 int32 id;
111 rgb_color color_list[256];
112 uint8 inversion_map[256];
113 uint8 index_map[32768];
114 } color_map;
117 // overlay
118 typedef struct overlay_rect_limits {
119 uint16 horizontal_alignment;
120 uint16 vertical_alignment;
121 uint16 width_alignment;
122 uint16 height_alignment;
123 uint16 min_width;
124 uint16 max_width;
125 uint16 min_height;
126 uint16 max_height;
127 uint32 reserved[8];
128 } overlay_rect_limits;
131 typedef struct overlay_restrictions {
132 overlay_rect_limits source;
133 overlay_rect_limits destination;
134 float min_width_scale;
135 float max_width_scale;
136 float min_height_scale;
137 float max_height_scale;
138 uint32 reserved[8];
139 } overlay_restrictions;
142 // Screen ID
143 struct screen_id { int32 id; };
144 extern const struct screen_id B_MAIN_SCREEN_ID;
147 // Color spaces
148 typedef enum {
149 B_NO_COLOR_SPACE = 0x0000,
151 // linear color space (little endian)
152 B_RGB32 = 0x0008, // BGR- -RGB 8:8:8:8
153 B_RGBA32 = 0x2008, // BGRA ARGB 8:8:8:8
154 B_RGB24 = 0x0003, // BGR RGB 8:8:8
155 B_RGB16 = 0x0005, // BGR RGB 5:6:5
156 B_RGB15 = 0x0010, // BGR- -RGB 1:5:5:5
157 B_RGBA15 = 0x2010, // BGRA ARGB 1:5:5:5
158 B_CMAP8 = 0x0004, // 256 color index table
159 B_GRAY8 = 0x0002, // 256 greyscale table
160 B_GRAY1 = 0x0001, // Each bit represents a single pixel
162 // linear color space (big endian)
163 B_RGB32_BIG = 0x1008, // -RGB BGR- 8:8:8:8
164 B_RGBA32_BIG = 0x3008, // ARGB BGRA 8:8:8:8
165 B_RGB24_BIG = 0x1003, // RGB BGR 8:8:8
166 B_RGB16_BIG = 0x1005, // RGB BGR 5:6:5
167 B_RGB15_BIG = 0x1010, // -RGB BGR- 5:5:5:1
168 B_RGBA15_BIG = 0x3010, // ARGB BGRA 5:5:5:1
170 // linear color space (little endian, for completeness)
171 B_RGB32_LITTLE = B_RGB32,
172 B_RGBA32_LITTLE = B_RGBA32,
173 B_RGB24_LITTLE = B_RGB24,
174 B_RGB16_LITTLE = B_RGB16,
175 B_RGB15_LITTLE = B_RGB15,
176 B_RGBA15_LITTLE = B_RGBA15,
178 // non linear color space -- incidently, all with 8 bits per value
179 // Note, BBitmap and BView do not support all of these!
181 // Loss / saturation points:
182 // Y 16 - 235 (absolute)
183 // Cb/Cr 16 - 240 (center 128)
185 B_YCbCr422 = 0x4000, // Y0 Cb0 Y1 Cr0
186 // Y2 Cb2 Y3 Cr4
187 B_YCbCr411 = 0x4001, // Cb0 Y0 Cr0 Y1
188 // Cb4 Y2 Cr4 Y3
189 // Y4 Y5 Y6 Y7
190 B_YCbCr444 = 0x4003, // Y Cb Cr
191 B_YCbCr420 = 0x4004, // Non-interlaced only
192 // on even scan lines: Cb0 Y0 Y1 Cb2 Y2 Y3
193 // on odd scan lines: Cr0 Y0 Y1 Cr2 Y2 Y3
195 // Extrema points are:
196 // Y 0 - 207 (absolute)
197 // U -91 - 91 (offset 128)
198 // V -127 - 127 (offset 128)
200 // Note that YUV byte order is different from YCbCr; use YCbCr, not YUV,
201 // when that's what you mean!
202 B_YUV422 = 0x4020, // U0 Y0 V0 Y1
203 // U2 Y2 V2 Y3
204 B_YUV411 = 0x4021, // U0 Y0 Y1 V0 Y2 Y3
205 // U4 Y4 Y5 V4 Y6 Y7
206 B_YUV444 = 0x4023, // U0 Y0 V0 U1 Y1 V1
207 B_YUV420 = 0x4024, // Non-interlaced only
208 // on even scan lines: U0 Y0 Y1 U2 Y2 Y3
209 // on odd scan lines: V0 Y0 Y1 V2 Y2 Y3
210 B_YUV9 = 0x402C,
211 B_YUV12 = 0x402D,
213 B_UVL24 = 0x4030, // UVL
214 B_UVL32 = 0x4031, // UVL-
215 B_UVLA32 = 0x6031, // UVLA
217 // L lightness, a/b color-opponent dimensions
218 B_LAB24 = 0x4032, // Lab
219 B_LAB32 = 0x4033, // Lab-
220 B_LABA32 = 0x6033, // LabA
222 // Red is at hue 0
223 B_HSI24 = 0x4040, // HSI
224 B_HSI32 = 0x4041, // HSI-
225 B_HSIA32 = 0x6041, // HSIA
227 B_HSV24 = 0x4042, // HSV
228 B_HSV32 = 0x4043, // HSV-
229 B_HSVA32 = 0x6043, // HSVA
231 B_HLS24 = 0x4044, // HLS
232 B_HLS32 = 0x4045, // HLS-
233 B_HLSA32 = 0x6045, // HLSA
235 B_CMY24 = 0xC001, // CMY
236 B_CMY32 = 0xC002, // CMY-
237 B_CMYA32 = 0xE002, // CMYA
238 B_CMYK32 = 0xC003, // CMYK
240 // Compatibility declarations
241 B_MONOCHROME_1_BIT = B_GRAY1,
242 B_GRAYSCALE_8_BIT = B_GRAY8,
243 B_COLOR_8_BIT = B_CMAP8,
244 B_RGB_32_BIT = B_RGB32,
245 B_RGB_16_BIT = B_RGB15,
246 B_BIG_RGB_32_BIT = B_RGB32_BIG,
247 B_BIG_RGB_16_BIT = B_RGB15_BIG
248 } color_space;
251 // Bitmap Support Flags
252 enum {
253 B_VIEWS_SUPPORT_DRAW_BITMAP = 0x1,
254 B_BITMAPS_SUPPORT_ATTACHED_VIEWS = 0x2,
255 B_BITMAPS_SUPPORT_OVERLAY = 0x4
259 bool bitmaps_support_space(color_space space, uint32* _supportFlags);
262 status_t get_pixel_size_for(color_space space, size_t* _pixelChunk,
263 size_t* _rowAlignment, size_t* _pixelsPerChunk);
266 enum buffer_orientation {
267 B_BUFFER_TOP_TO_BOTTOM,
268 B_BUFFER_BOTTOM_TO_TOP
272 enum buffer_layout {
273 B_BUFFER_NONINTERLEAVED = 1
277 // Drawing Modes
278 enum drawing_mode {
279 B_OP_COPY,
280 B_OP_OVER,
281 B_OP_ERASE,
282 B_OP_INVERT,
283 B_OP_ADD,
284 B_OP_SUBTRACT,
285 B_OP_BLEND,
286 B_OP_MIN,
287 B_OP_MAX,
288 B_OP_SELECT,
289 B_OP_ALPHA
293 enum source_alpha {
294 B_PIXEL_ALPHA = 0,
295 B_CONSTANT_ALPHA
299 enum alpha_function {
300 B_ALPHA_OVERLAY = 0,
301 B_ALPHA_COMPOSITE
305 // Fixed Screen Modes
306 enum {
307 B_8_BIT_640x480 = 0x00000001,
308 B_8_BIT_800x600 = 0x00000002,
309 B_8_BIT_1024x768 = 0x00000004,
310 B_8_BIT_1280x1024 = 0x00000008,
311 B_8_BIT_1600x1200 = 0x00000010,
312 B_16_BIT_640x480 = 0x00000020,
313 B_16_BIT_800x600 = 0x00000040,
314 B_16_BIT_1024x768 = 0x00000080,
315 B_16_BIT_1280x1024 = 0x00000100,
316 B_16_BIT_1600x1200 = 0x00000200,
317 B_32_BIT_640x480 = 0x00000400,
318 B_32_BIT_800x600 = 0x00000800,
319 B_32_BIT_1024x768 = 0x00001000,
320 B_32_BIT_1280x1024 = 0x00002000,
321 B_32_BIT_1600x1200 = 0x00004000,
322 B_8_BIT_1152x900 = 0x00008000,
323 B_16_BIT_1152x900 = 0x00010000,
324 B_32_BIT_1152x900 = 0x00020000,
325 B_15_BIT_640x480 = 0x00040000,
326 B_15_BIT_800x600 = 0x00080000,
327 B_15_BIT_1024x768 = 0x00100000,
328 B_15_BIT_1280x1024 = 0x00200000,
329 B_15_BIT_1600x1200 = 0x00400000,
330 B_15_BIT_1152x900 = 0x00800000,
331 B_8_BIT_640x400 = 0x80000000
335 #endif // _GRAPHICS_DEFS_H