2 * Copyright 2008-2015 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 #ifndef _GRAPHICS_DEFS_H
6 #define _GRAPHICS_DEFS_H
9 #include <SupportDefs.h>
13 typedef struct pattern
{
20 operator==(const pattern
& a
, const pattern
& b
)
22 uint64
* pa
= (uint64
*)a
.data
;
23 uint64
* pb
= (uint64
*)b
.data
;
29 operator!=(const pattern
& a
, const pattern
& b
)
36 extern const pattern B_SOLID_HIGH
;
37 extern const pattern B_MIXED_COLORS
;
38 extern const pattern B_SOLID_LOW
;
42 typedef struct rgb_color
{
48 #if defined(__cplusplus)
49 // some convenient additions
51 set_to(uint8 r
, uint8 g
, uint8 b
, uint8 a
= 255)
60 int32
Brightness() const;
63 operator==(const rgb_color
& other
) const
65 return *(const uint32
*)this == *(const uint32
*)&other
;
69 operator!=(const rgb_color
& other
) const
71 return *(const uint32
*)this != *(const uint32
*)&other
;
75 operator=(const rgb_color
& other
)
77 return set_to(other
.red
, other
.green
, other
.blue
, other
.alpha
);
83 #if defined(__cplusplus)
85 make_color(uint8 red
, uint8 green
, uint8 blue
, uint8 alpha
= 255)
87 rgb_color color
= {red
, green
, blue
, alpha
};
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
;
109 typedef struct color_map
{
111 rgb_color color_list
[256];
112 uint8 inversion_map
[256];
113 uint8 index_map
[32768];
118 typedef struct overlay_rect_limits
{
119 uint16 horizontal_alignment
;
120 uint16 vertical_alignment
;
121 uint16 width_alignment
;
122 uint16 height_alignment
;
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
;
139 } overlay_restrictions
;
143 struct screen_id
{ int32 id
; };
144 extern const struct screen_id B_MAIN_SCREEN_ID
;
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
187 B_YCbCr411
= 0x4001, // Cb0 Y0 Cr0 Y1
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
204 B_YUV411
= 0x4021, // U0 Y0 Y1 V0 Y2 Y3
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
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
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
251 // Bitmap Support Flags
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
273 B_BUFFER_NONINTERLEAVED
= 1
299 enum alpha_function
{
305 // Fixed Screen Modes
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