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