16ec21b4aSAxel Dörfler /* 26ec21b4aSAxel Dörfler * Copyright 2008, Haiku Inc. All Rights Reserved. 36ec21b4aSAxel Dörfler * Distributed under the terms of the MIT License. 46ec21b4aSAxel Dörfler */ 552a38012Sejakowatz #ifndef _GRAPHICS_DEFS_H 652a38012Sejakowatz #define _GRAPHICS_DEFS_H 752a38012Sejakowatz 852a38012Sejakowatz 952a38012Sejakowatz #include <BeBuild.h> 1052a38012Sejakowatz #include <SupportDefs.h> 1152a38012Sejakowatz 1252a38012Sejakowatz 136ec21b4aSAxel Dörfler // Pattern 1452a38012Sejakowatz 1552a38012Sejakowatz typedef struct pattern { 1652a38012Sejakowatz uint8 data[8]; 1752a38012Sejakowatz } pattern; 1852a38012Sejakowatz 1909852109SStephan Aßmus #ifdef __cplusplus 2009852109SStephan Aßmus 2109852109SStephan Aßmus inline bool 2209852109SStephan Aßmus operator==(const pattern& a, const pattern& b) 2309852109SStephan Aßmus { 2409852109SStephan Aßmus return (*(uint64*)a.data == *(uint64*)b.data); 2509852109SStephan Aßmus } 2609852109SStephan Aßmus 27758b1d0eSIngo Weinhold inline bool 28758b1d0eSIngo Weinhold operator!=(const pattern& a, const pattern& b) 29758b1d0eSIngo Weinhold { 30758b1d0eSIngo Weinhold return !(a == b); 31758b1d0eSIngo Weinhold } 32758b1d0eSIngo Weinhold 3309852109SStephan Aßmus #endif // __cplusplus 3409852109SStephan Aßmus 35f6e4cbb9SAxel Dörfler extern const pattern B_SOLID_HIGH; 36f6e4cbb9SAxel Dörfler extern const pattern B_MIXED_COLORS; 37f6e4cbb9SAxel Dörfler extern const pattern B_SOLID_LOW; 3852a38012Sejakowatz 396ec21b4aSAxel Dörfler 406ec21b4aSAxel Dörfler // rgb_color 4152a38012Sejakowatz 4252a38012Sejakowatz typedef struct rgb_color { 4352a38012Sejakowatz uint8 red; 4452a38012Sejakowatz uint8 green; 4552a38012Sejakowatz uint8 blue; 4652a38012Sejakowatz uint8 alpha; 479551dd1cSAxel Dörfler 489551dd1cSAxel Dörfler #if defined(__cplusplus) 499551dd1cSAxel Dörfler // some convenient additions 509551dd1cSAxel Dörfler 51cd0ea6ffSAxel Dörfler inline rgb_color& 52cd0ea6ffSAxel Dörfler set_to(uint8 r, uint8 g, uint8 b, uint8 a = 255) 53cd0ea6ffSAxel Dörfler { 54cd0ea6ffSAxel Dörfler red = r; 55cd0ea6ffSAxel Dörfler green = g; 56cd0ea6ffSAxel Dörfler blue = b; 57cd0ea6ffSAxel Dörfler alpha = a; 58cd0ea6ffSAxel Dörfler return *this; 59cd0ea6ffSAxel Dörfler } 60cd0ea6ffSAxel Dörfler 619551dd1cSAxel Dörfler inline bool 629551dd1cSAxel Dörfler operator==(const rgb_color& other) const 639551dd1cSAxel Dörfler { 649551dd1cSAxel Dörfler return *(const uint32 *)this == *(const uint32 *)&other; 659551dd1cSAxel Dörfler } 669551dd1cSAxel Dörfler 679551dd1cSAxel Dörfler inline bool 689551dd1cSAxel Dörfler operator!=(const rgb_color& other) const 699551dd1cSAxel Dörfler { 709551dd1cSAxel Dörfler return *(const uint32 *)this != *(const uint32 *)&other; 719551dd1cSAxel Dörfler } 72f6d52cb7SRene Gollent 73f6d52cb7SRene Gollent inline rgb_color& 74f6d52cb7SRene Gollent operator=(const rgb_color& other) 75f6d52cb7SRene Gollent { 76f6d52cb7SRene Gollent return set_to(other.red, other.green, other.blue, other.alpha); 77f6d52cb7SRene Gollent } 789551dd1cSAxel Dörfler #endif 7952a38012Sejakowatz } rgb_color; 8052a38012Sejakowatz 81cd0ea6ffSAxel Dörfler #if defined(__cplusplus) 82cd0ea6ffSAxel Dörfler inline rgb_color 83cd0ea6ffSAxel Dörfler make_color(uint8 red, uint8 green, uint8 blue, uint8 alpha = 255) 84cd0ea6ffSAxel Dörfler { 85cd0ea6ffSAxel Dörfler rgb_color color = {red, green, blue, alpha}; 86cd0ea6ffSAxel Dörfler return color; 87cd0ea6ffSAxel Dörfler } 88cd0ea6ffSAxel Dörfler #endif 89cd0ea6ffSAxel Dörfler 90f6e4cbb9SAxel Dörfler extern const rgb_color B_TRANSPARENT_COLOR; 91f6e4cbb9SAxel Dörfler extern const uint8 B_TRANSPARENT_MAGIC_CMAP8; 92f6e4cbb9SAxel Dörfler extern const uint16 B_TRANSPARENT_MAGIC_RGBA15; 93f6e4cbb9SAxel Dörfler extern const uint16 B_TRANSPARENT_MAGIC_RGBA15_BIG; 94f6e4cbb9SAxel Dörfler extern const uint32 B_TRANSPARENT_MAGIC_RGBA32; 95f6e4cbb9SAxel Dörfler extern const uint32 B_TRANSPARENT_MAGIC_RGBA32_BIG; 9652a38012Sejakowatz 97f6e4cbb9SAxel Dörfler extern const uint8 B_TRANSPARENT_8_BIT; 98f6e4cbb9SAxel Dörfler extern const rgb_color B_TRANSPARENT_32_BIT; 9952a38012Sejakowatz 1006ec21b4aSAxel Dörfler 1016ec21b4aSAxel Dörfler // color map 10252a38012Sejakowatz 10352a38012Sejakowatz typedef struct color_map { 10452a38012Sejakowatz int32 id; 10552a38012Sejakowatz rgb_color color_list[256]; 10652a38012Sejakowatz uint8 inversion_map[256]; 10752a38012Sejakowatz uint8 index_map[32768]; 10852a38012Sejakowatz } color_map; 10952a38012Sejakowatz 1106ec21b4aSAxel Dörfler 1116ec21b4aSAxel Dörfler // overlay 1126ec21b4aSAxel Dörfler 11352a38012Sejakowatz typedef struct overlay_rect_limits { 11452a38012Sejakowatz uint16 horizontal_alignment; 11552a38012Sejakowatz uint16 vertical_alignment; 11652a38012Sejakowatz uint16 width_alignment; 11752a38012Sejakowatz uint16 height_alignment; 11852a38012Sejakowatz uint16 min_width; 11952a38012Sejakowatz uint16 max_width; 12052a38012Sejakowatz uint16 min_height; 12152a38012Sejakowatz uint16 max_height; 12252a38012Sejakowatz uint32 reserved[8]; 12352a38012Sejakowatz } overlay_rect_limits; 12452a38012Sejakowatz 12552a38012Sejakowatz typedef struct overlay_restrictions { 12652a38012Sejakowatz overlay_rect_limits source; 12752a38012Sejakowatz overlay_rect_limits destination; 12852a38012Sejakowatz float min_width_scale; 12952a38012Sejakowatz float max_width_scale; 13052a38012Sejakowatz float min_height_scale; 13152a38012Sejakowatz float max_height_scale; 13252a38012Sejakowatz uint32 reserved[8]; 13352a38012Sejakowatz } overlay_restrictions; 13452a38012Sejakowatz 1356ec21b4aSAxel Dörfler 1366ec21b4aSAxel Dörfler // screen ID 13752a38012Sejakowatz 13852a38012Sejakowatz struct screen_id { int32 id; }; 13952a38012Sejakowatz 140f6e4cbb9SAxel Dörfler extern const struct screen_id B_MAIN_SCREEN_ID; 14152a38012Sejakowatz 14252a38012Sejakowatz 1436ec21b4aSAxel Dörfler // color spaces 14452a38012Sejakowatz 1456ec21b4aSAxel Dörfler typedef enum { 1466ec21b4aSAxel Dörfler B_NO_COLOR_SPACE = 0x0000, 14752a38012Sejakowatz 1486ec21b4aSAxel Dörfler // linear color space (little endian) 1496ec21b4aSAxel Dörfler B_RGB32 = 0x0008, // BGR- 1506ec21b4aSAxel Dörfler B_RGBA32 = 0x2008, // BGRA 1516ec21b4aSAxel Dörfler B_RGB24 = 0x0003, // BGR 1526ec21b4aSAxel Dörfler B_RGB16 = 0x0005, 1536ec21b4aSAxel Dörfler B_RGB15 = 0x0010, 1546ec21b4aSAxel Dörfler B_RGBA15 = 0x2010, 1556ec21b4aSAxel Dörfler B_CMAP8 = 0x0004, 1566ec21b4aSAxel Dörfler B_GRAY8 = 0x0002, 1576ec21b4aSAxel Dörfler B_GRAY1 = 0x0001, 15852a38012Sejakowatz 1596ec21b4aSAxel Dörfler // big endian version 1606ec21b4aSAxel Dörfler B_RGB32_BIG = 0x1008, // -RGB 1616ec21b4aSAxel Dörfler B_RGBA32_BIG = 0x3008, // ARGB 1626ec21b4aSAxel Dörfler B_RGB24_BIG = 0x1003, // RGB 1636ec21b4aSAxel Dörfler B_RGB16_BIG = 0x1005, 1646ec21b4aSAxel Dörfler B_RGB15_BIG = 0x1010, 1656ec21b4aSAxel Dörfler B_RGBA15_BIG = 0x3010, 1666ec21b4aSAxel Dörfler 1676ec21b4aSAxel Dörfler // explicit little-endian for completeness 16852a38012Sejakowatz B_RGB32_LITTLE = B_RGB32, 16952a38012Sejakowatz B_RGBA32_LITTLE = B_RGBA32, 17052a38012Sejakowatz B_RGB24_LITTLE = B_RGB24, 17152a38012Sejakowatz B_RGB16_LITTLE = B_RGB16, 17252a38012Sejakowatz B_RGB15_LITTLE = B_RGB15, 17352a38012Sejakowatz B_RGBA15_LITTLE = B_RGBA15, 17452a38012Sejakowatz 1756ec21b4aSAxel Dörfler // non linear color space -- incidently, all with 8 bits per value 1766ec21b4aSAxel Dörfler // Note, BBitmap and BView do not support all of these! 17752a38012Sejakowatz 1786ec21b4aSAxel Dörfler // loss/saturation points are Y 16-235 (absolute), Cb/Cr 16-240 (center 128) 17952a38012Sejakowatz 1806ec21b4aSAxel Dörfler B_YCbCr422 = 0x4000, // Y0 Cb0 Y1 Cr0 Y2... 1816ec21b4aSAxel Dörfler // Cb2 Y3 Cr2... 1826ec21b4aSAxel Dörfler B_YCbCr411 = 0x4001, // Cb0 Y0 Cr0 Y1 Cb4... 1836ec21b4aSAxel Dörfler // Y2 Cr4 Y3 Y4 Y5... 1846ec21b4aSAxel Dörfler // Y6 Y7... 1856ec21b4aSAxel Dörfler B_YCbCr444 = 0x4003, // Y Cb Cr 1866ec21b4aSAxel Dörfler B_YCbCr420 = 0x4004, // Non-interlaced only 1876ec21b4aSAxel Dörfler // on even scan lines: Cb0 Y0 Y1 Cb2 Y2 Y3 1886ec21b4aSAxel Dörfler // on odd scan lines: Cr0 Y0 Y1 Cr2 Y2 Y3 18952a38012Sejakowatz 1906ec21b4aSAxel Dörfler // Extrema points are: 19152a38012Sejakowatz // Y 0 - 207 (absolute) 19252a38012Sejakowatz // U -91 - 91 (offset 128) 19352a38012Sejakowatz // V -127 - 127 (offset 128) 19452a38012Sejakowatz 1956ec21b4aSAxel Dörfler // Note that YUV byte order is different from YCbCr; use YCbCr, not YUV, 1966ec21b4aSAxel Dörfler // when that's what you mean! 1976ec21b4aSAxel Dörfler B_YUV422 = 0x4020, // U0 Y0 V0 Y1... 1986ec21b4aSAxel Dörfler // U2 Y2 V2 Y3... 1996ec21b4aSAxel Dörfler B_YUV411 = 0x4021, // U0 Y0 Y1 V0 Y2 Y3... 2006ec21b4aSAxel Dörfler // U4 Y4 Y5 V4 Y6 Y7... 2016ec21b4aSAxel Dörfler B_YUV444 = 0x4023, // U0 Y0 V0 U1 Y1 V1 2026ec21b4aSAxel Dörfler B_YUV420 = 0x4024, // Non-interlaced only 2036ec21b4aSAxel Dörfler // on even scan lines: U0 Y0 Y1 U2 Y2 Y3 2046ec21b4aSAxel Dörfler // on odd scan lines: V0 Y0 Y1 V2 Y2 Y3 2056ec21b4aSAxel Dörfler B_YUV9 = 0x402C, 2066ec21b4aSAxel Dörfler B_YUV12 = 0x402D, 20752a38012Sejakowatz 2086ec21b4aSAxel Dörfler B_UVL24 = 0x4030, // UVL 2096ec21b4aSAxel Dörfler B_UVL32 = 0x4031, // UVL- 2106ec21b4aSAxel Dörfler B_UVLA32 = 0x6031, // UVLA 21152a38012Sejakowatz 2126ec21b4aSAxel Dörfler // L lightness, a/b color-opponent dimensions 2136ec21b4aSAxel Dörfler B_LAB24 = 0x4032, // Lab 2146ec21b4aSAxel Dörfler B_LAB32 = 0x4033, // Lab- 2156ec21b4aSAxel Dörfler B_LABA32 = 0x6033, // LabA 21652a38012Sejakowatz 2176ec21b4aSAxel Dörfler // Red is at hue 0 2186ec21b4aSAxel Dörfler B_HSI24 = 0x4040, // HSI 2196ec21b4aSAxel Dörfler B_HSI32 = 0x4041, // HSI- 2206ec21b4aSAxel Dörfler B_HSIA32 = 0x6041, // HSIA 22152a38012Sejakowatz 2226ec21b4aSAxel Dörfler B_HSV24 = 0x4042, // HSV 2236ec21b4aSAxel Dörfler B_HSV32 = 0x4043, // HSV- 2246ec21b4aSAxel Dörfler B_HSVA32 = 0x6043, // HSVA 22552a38012Sejakowatz 2266ec21b4aSAxel Dörfler B_HLS24 = 0x4044, // HLS 2276ec21b4aSAxel Dörfler B_HLS32 = 0x4045, // HLS- 2286ec21b4aSAxel Dörfler B_HLSA32 = 0x6045, // HLSA 22952a38012Sejakowatz 2306ec21b4aSAxel Dörfler B_CMY24 = 0xC001, // CMY 2316ec21b4aSAxel Dörfler B_CMY32 = 0xC002, // CMY- 2326ec21b4aSAxel Dörfler B_CMYA32 = 0xE002, // CMYA 2336ec21b4aSAxel Dörfler B_CMYK32 = 0xC003, // CMYK 23452a38012Sejakowatz 23552a38012Sejakowatz // compatibility declarations 23652a38012Sejakowatz B_MONOCHROME_1_BIT = B_GRAY1, 23752a38012Sejakowatz B_GRAYSCALE_8_BIT = B_GRAY8, 23852a38012Sejakowatz B_COLOR_8_BIT = B_CMAP8, 23952a38012Sejakowatz B_RGB_32_BIT = B_RGB32, 24052a38012Sejakowatz B_RGB_16_BIT = B_RGB15, 24152a38012Sejakowatz B_BIG_RGB_32_BIT = B_RGB32_BIG, 24252a38012Sejakowatz B_BIG_RGB_16_BIT = B_RGB15_BIG 24352a38012Sejakowatz } color_space; 24452a38012Sejakowatz 24552a38012Sejakowatz 2466ec21b4aSAxel Dörfler // Bitmap Support Flags 2476ec21b4aSAxel Dörfler 24852a38012Sejakowatz enum { 24952a38012Sejakowatz B_VIEWS_SUPPORT_DRAW_BITMAP = 0x1, 2506ec21b4aSAxel Dörfler B_BITMAPS_SUPPORT_ATTACHED_VIEWS = 0x2, 251*6cd1b6f7SRene Gollent B_BITMAPS_SUPPORT_OVERLAY = 0x4 25252a38012Sejakowatz }; 2536ec21b4aSAxel Dörfler bool bitmaps_support_space(color_space space, uint32* _supportFlags); 25452a38012Sejakowatz 2556ec21b4aSAxel Dörfler status_t get_pixel_size_for(color_space space, size_t* _pixelChunk, 2566ec21b4aSAxel Dörfler size_t* _rowAlignment, size_t* _pixelsPerChunk); 25752a38012Sejakowatz 25852a38012Sejakowatz 25952a38012Sejakowatz enum buffer_orientation { 26052a38012Sejakowatz B_BUFFER_TOP_TO_BOTTOM, 26152a38012Sejakowatz B_BUFFER_BOTTOM_TO_TOP 26252a38012Sejakowatz }; 26352a38012Sejakowatz 26452a38012Sejakowatz enum buffer_layout { 26552a38012Sejakowatz B_BUFFER_NONINTERLEAVED = 1 26652a38012Sejakowatz }; 26752a38012Sejakowatz 2686ec21b4aSAxel Dörfler 2696ec21b4aSAxel Dörfler // Drawing Modes 27052a38012Sejakowatz 27152a38012Sejakowatz enum drawing_mode { 27252a38012Sejakowatz B_OP_COPY, 27352a38012Sejakowatz B_OP_OVER, 27452a38012Sejakowatz B_OP_ERASE, 27552a38012Sejakowatz B_OP_INVERT, 27652a38012Sejakowatz B_OP_ADD, 27752a38012Sejakowatz B_OP_SUBTRACT, 27852a38012Sejakowatz B_OP_BLEND, 27952a38012Sejakowatz B_OP_MIN, 28052a38012Sejakowatz B_OP_MAX, 28152a38012Sejakowatz B_OP_SELECT, 28252a38012Sejakowatz B_OP_ALPHA 28352a38012Sejakowatz }; 28452a38012Sejakowatz 28552a38012Sejakowatz enum source_alpha { 28652a38012Sejakowatz B_PIXEL_ALPHA = 0, 28752a38012Sejakowatz B_CONSTANT_ALPHA 28852a38012Sejakowatz }; 28952a38012Sejakowatz 29052a38012Sejakowatz enum alpha_function { 29152a38012Sejakowatz B_ALPHA_OVERLAY = 0, 29252a38012Sejakowatz B_ALPHA_COMPOSITE 29352a38012Sejakowatz }; 29452a38012Sejakowatz 2956ec21b4aSAxel Dörfler 2966ec21b4aSAxel Dörfler // Fixed Screen Modes 2976ec21b4aSAxel Dörfler 29852a38012Sejakowatz enum { 29952a38012Sejakowatz B_8_BIT_640x480 = 0x00000001, 30052a38012Sejakowatz B_8_BIT_800x600 = 0x00000002, 30152a38012Sejakowatz B_8_BIT_1024x768 = 0x00000004, 30252a38012Sejakowatz B_8_BIT_1280x1024 = 0x00000008, 30352a38012Sejakowatz B_8_BIT_1600x1200 = 0x00000010, 30452a38012Sejakowatz B_16_BIT_640x480 = 0x00000020, 30552a38012Sejakowatz B_16_BIT_800x600 = 0x00000040, 30652a38012Sejakowatz B_16_BIT_1024x768 = 0x00000080, 30752a38012Sejakowatz B_16_BIT_1280x1024 = 0x00000100, 30852a38012Sejakowatz B_16_BIT_1600x1200 = 0x00000200, 30952a38012Sejakowatz B_32_BIT_640x480 = 0x00000400, 31052a38012Sejakowatz B_32_BIT_800x600 = 0x00000800, 31152a38012Sejakowatz B_32_BIT_1024x768 = 0x00001000, 31252a38012Sejakowatz B_32_BIT_1280x1024 = 0x00002000, 31352a38012Sejakowatz B_32_BIT_1600x1200 = 0x00004000, 31452a38012Sejakowatz B_8_BIT_1152x900 = 0x00008000, 31552a38012Sejakowatz B_16_BIT_1152x900 = 0x00010000, 31652a38012Sejakowatz B_32_BIT_1152x900 = 0x00020000, 31752a38012Sejakowatz B_15_BIT_640x480 = 0x00040000, 31852a38012Sejakowatz B_15_BIT_800x600 = 0x00080000, 31952a38012Sejakowatz B_15_BIT_1024x768 = 0x00100000, 32052a38012Sejakowatz B_15_BIT_1280x1024 = 0x00200000, 32152a38012Sejakowatz B_15_BIT_1600x1200 = 0x00400000, 32252a38012Sejakowatz B_15_BIT_1152x900 = 0x00800000, 32352a38012Sejakowatz 3246ec21b4aSAxel Dörfler B_8_BIT_640x400 = 0x80000000 32552a38012Sejakowatz }; 32652a38012Sejakowatz 3276ec21b4aSAxel Dörfler #endif // _GRAPHICS_DEFS_H 328