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