2008-06-03 21:44:46 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2008, Haiku Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2002-07-09 16:24:59 +04:00
|
|
|
#ifndef _GRAPHICS_DEFS_H
|
|
|
|
#define _GRAPHICS_DEFS_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <BeBuild.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
|
2008-06-03 21:44:46 +04:00
|
|
|
// Pattern
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
typedef struct pattern {
|
2008-06-03 21:44:46 +04:00
|
|
|
uint8 data[8];
|
2002-07-09 16:24:59 +04:00
|
|
|
} pattern;
|
|
|
|
|
2005-03-29 20:30:46 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
operator==(const pattern& a, const pattern& b)
|
|
|
|
{
|
|
|
|
return (*(uint64*)a.data == *(uint64*)b.data);
|
|
|
|
}
|
|
|
|
|
2005-11-13 02:27:14 +03:00
|
|
|
inline bool
|
|
|
|
operator!=(const pattern& a, const pattern& b)
|
|
|
|
{
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
|
2005-03-29 20:30:46 +04:00
|
|
|
#endif // __cplusplus
|
|
|
|
|
2007-10-16 00:13:55 +04:00
|
|
|
extern const pattern B_SOLID_HIGH;
|
|
|
|
extern const pattern B_MIXED_COLORS;
|
|
|
|
extern const pattern B_SOLID_LOW;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2008-06-03 21:44:46 +04:00
|
|
|
|
|
|
|
// rgb_color
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
typedef struct rgb_color {
|
|
|
|
uint8 red;
|
|
|
|
uint8 green;
|
|
|
|
uint8 blue;
|
|
|
|
uint8 alpha;
|
2005-01-15 05:38:52 +03:00
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
// some convenient additions
|
|
|
|
|
2006-04-18 16:14:59 +04:00
|
|
|
inline rgb_color&
|
|
|
|
set_to(uint8 r, uint8 g, uint8 b, uint8 a = 255)
|
|
|
|
{
|
|
|
|
red = r;
|
|
|
|
green = g;
|
|
|
|
blue = b;
|
|
|
|
alpha = a;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2005-01-15 05:38:52 +03:00
|
|
|
inline bool
|
|
|
|
operator==(const rgb_color& other) const
|
|
|
|
{
|
|
|
|
return *(const uint32 *)this == *(const uint32 *)&other;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
operator!=(const rgb_color& other) const
|
|
|
|
{
|
|
|
|
return *(const uint32 *)this != *(const uint32 *)&other;
|
|
|
|
}
|
2008-03-01 03:57:18 +03:00
|
|
|
|
|
|
|
inline rgb_color&
|
|
|
|
operator=(const rgb_color& other)
|
|
|
|
{
|
|
|
|
return set_to(other.red, other.green, other.blue, other.alpha);
|
|
|
|
}
|
2005-01-15 05:38:52 +03:00
|
|
|
#endif
|
2002-07-09 16:24:59 +04:00
|
|
|
} rgb_color;
|
|
|
|
|
2006-04-18 16:14:59 +04:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
inline rgb_color
|
|
|
|
make_color(uint8 red, uint8 green, uint8 blue, uint8 alpha = 255)
|
|
|
|
{
|
|
|
|
rgb_color color = {red, green, blue, alpha};
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-10-16 00:13:55 +04:00
|
|
|
extern const rgb_color B_TRANSPARENT_COLOR;
|
|
|
|
extern const uint8 B_TRANSPARENT_MAGIC_CMAP8;
|
|
|
|
extern const uint16 B_TRANSPARENT_MAGIC_RGBA15;
|
|
|
|
extern const uint16 B_TRANSPARENT_MAGIC_RGBA15_BIG;
|
|
|
|
extern const uint32 B_TRANSPARENT_MAGIC_RGBA32;
|
|
|
|
extern const uint32 B_TRANSPARENT_MAGIC_RGBA32_BIG;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2007-10-16 00:13:55 +04:00
|
|
|
extern const uint8 B_TRANSPARENT_8_BIT;
|
|
|
|
extern const rgb_color B_TRANSPARENT_32_BIT;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2008-06-03 21:44:46 +04:00
|
|
|
|
|
|
|
// color map
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
typedef struct color_map {
|
|
|
|
int32 id;
|
|
|
|
rgb_color color_list[256];
|
|
|
|
uint8 inversion_map[256];
|
|
|
|
uint8 index_map[32768];
|
|
|
|
} color_map;
|
|
|
|
|
2008-06-03 21:44:46 +04:00
|
|
|
|
|
|
|
// overlay
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
typedef struct overlay_rect_limits {
|
|
|
|
uint16 horizontal_alignment;
|
|
|
|
uint16 vertical_alignment;
|
|
|
|
uint16 width_alignment;
|
|
|
|
uint16 height_alignment;
|
|
|
|
uint16 min_width;
|
|
|
|
uint16 max_width;
|
|
|
|
uint16 min_height;
|
|
|
|
uint16 max_height;
|
|
|
|
uint32 reserved[8];
|
|
|
|
} overlay_rect_limits;
|
|
|
|
|
|
|
|
typedef struct overlay_restrictions {
|
|
|
|
overlay_rect_limits source;
|
|
|
|
overlay_rect_limits destination;
|
|
|
|
float min_width_scale;
|
|
|
|
float max_width_scale;
|
|
|
|
float min_height_scale;
|
|
|
|
float max_height_scale;
|
|
|
|
uint32 reserved[8];
|
|
|
|
} overlay_restrictions;
|
|
|
|
|
2008-06-03 21:44:46 +04:00
|
|
|
|
|
|
|
// screen ID
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
struct screen_id { int32 id; };
|
|
|
|
|
2007-10-16 00:13:55 +04:00
|
|
|
extern const struct screen_id B_MAIN_SCREEN_ID;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
2008-06-03 21:44:46 +04:00
|
|
|
// color spaces
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
B_NO_COLOR_SPACE = 0x0000,
|
|
|
|
|
|
|
|
// linear color space (little endian)
|
|
|
|
B_RGB32 = 0x0008, // BGR-
|
|
|
|
B_RGBA32 = 0x2008, // BGRA
|
|
|
|
B_RGB24 = 0x0003, // BGR
|
|
|
|
B_RGB16 = 0x0005,
|
|
|
|
B_RGB15 = 0x0010,
|
|
|
|
B_RGBA15 = 0x2010,
|
|
|
|
B_CMAP8 = 0x0004,
|
|
|
|
B_GRAY8 = 0x0002,
|
|
|
|
B_GRAY1 = 0x0001,
|
|
|
|
|
|
|
|
// big endian version
|
|
|
|
B_RGB32_BIG = 0x1008, // -RGB
|
|
|
|
B_RGBA32_BIG = 0x3008, // ARGB
|
|
|
|
B_RGB24_BIG = 0x1003, // RGB
|
|
|
|
B_RGB16_BIG = 0x1005,
|
|
|
|
B_RGB15_BIG = 0x1010,
|
|
|
|
B_RGBA15_BIG = 0x3010,
|
|
|
|
|
|
|
|
// explicit little-endian for completeness
|
|
|
|
B_RGB32_LITTLE = B_RGB32,
|
|
|
|
B_RGBA32_LITTLE = B_RGBA32,
|
|
|
|
B_RGB24_LITTLE = B_RGB24,
|
|
|
|
B_RGB16_LITTLE = B_RGB16,
|
|
|
|
B_RGB15_LITTLE = B_RGB15,
|
|
|
|
B_RGBA15_LITTLE = B_RGBA15,
|
|
|
|
|
|
|
|
// non linear color space -- incidently, all with 8 bits per value
|
|
|
|
// Note, BBitmap and BView do not support all of these!
|
|
|
|
|
2009-08-26 15:19:20 +04:00
|
|
|
// loss/saturation points are Y 16-235 (absolute), Cb/Cr 16-240
|
|
|
|
// (center 128)
|
2008-06-03 21:44:46 +04:00
|
|
|
|
|
|
|
B_YCbCr422 = 0x4000, // Y0 Cb0 Y1 Cr0 Y2...
|
|
|
|
// Cb2 Y3 Cr2...
|
|
|
|
B_YCbCr411 = 0x4001, // Cb0 Y0 Cr0 Y1 Cb4...
|
|
|
|
// Y2 Cr4 Y3 Y4 Y5...
|
|
|
|
// Y6 Y7...
|
|
|
|
B_YCbCr444 = 0x4003, // Y Cb Cr
|
|
|
|
B_YCbCr420 = 0x4004, // Non-interlaced only
|
|
|
|
// on even scan lines: Cb0 Y0 Y1 Cb2 Y2 Y3
|
|
|
|
// on odd scan lines: Cr0 Y0 Y1 Cr2 Y2 Y3
|
|
|
|
|
|
|
|
// Extrema points are:
|
|
|
|
// Y 0 - 207 (absolute)
|
|
|
|
// U -91 - 91 (offset 128)
|
|
|
|
// V -127 - 127 (offset 128)
|
|
|
|
|
|
|
|
// Note that YUV byte order is different from YCbCr; use YCbCr, not YUV,
|
|
|
|
// when that's what you mean!
|
|
|
|
B_YUV422 = 0x4020, // U0 Y0 V0 Y1...
|
|
|
|
// U2 Y2 V2 Y3...
|
|
|
|
B_YUV411 = 0x4021, // U0 Y0 Y1 V0 Y2 Y3...
|
|
|
|
// U4 Y4 Y5 V4 Y6 Y7...
|
|
|
|
B_YUV444 = 0x4023, // U0 Y0 V0 U1 Y1 V1
|
|
|
|
B_YUV420 = 0x4024, // Non-interlaced only
|
|
|
|
// on even scan lines: U0 Y0 Y1 U2 Y2 Y3
|
|
|
|
// on odd scan lines: V0 Y0 Y1 V2 Y2 Y3
|
|
|
|
B_YUV9 = 0x402C,
|
|
|
|
B_YUV12 = 0x402D,
|
|
|
|
|
|
|
|
B_UVL24 = 0x4030, // UVL
|
|
|
|
B_UVL32 = 0x4031, // UVL-
|
|
|
|
B_UVLA32 = 0x6031, // UVLA
|
|
|
|
|
|
|
|
// L lightness, a/b color-opponent dimensions
|
|
|
|
B_LAB24 = 0x4032, // Lab
|
|
|
|
B_LAB32 = 0x4033, // Lab-
|
|
|
|
B_LABA32 = 0x6033, // LabA
|
|
|
|
|
|
|
|
// Red is at hue 0
|
|
|
|
B_HSI24 = 0x4040, // HSI
|
|
|
|
B_HSI32 = 0x4041, // HSI-
|
|
|
|
B_HSIA32 = 0x6041, // HSIA
|
|
|
|
|
|
|
|
B_HSV24 = 0x4042, // HSV
|
|
|
|
B_HSV32 = 0x4043, // HSV-
|
|
|
|
B_HSVA32 = 0x6043, // HSVA
|
|
|
|
|
|
|
|
B_HLS24 = 0x4044, // HLS
|
|
|
|
B_HLS32 = 0x4045, // HLS-
|
|
|
|
B_HLSA32 = 0x6045, // HLSA
|
|
|
|
|
|
|
|
B_CMY24 = 0xC001, // CMY
|
|
|
|
B_CMY32 = 0xC002, // CMY-
|
|
|
|
B_CMYA32 = 0xE002, // CMYA
|
|
|
|
B_CMYK32 = 0xC003, // CMYK
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// compatibility declarations
|
2008-06-03 21:44:46 +04:00
|
|
|
B_MONOCHROME_1_BIT = B_GRAY1,
|
|
|
|
B_GRAYSCALE_8_BIT = B_GRAY8,
|
|
|
|
B_COLOR_8_BIT = B_CMAP8,
|
|
|
|
B_RGB_32_BIT = B_RGB32,
|
|
|
|
B_RGB_16_BIT = B_RGB15,
|
|
|
|
B_BIG_RGB_32_BIT = B_RGB32_BIG,
|
|
|
|
B_BIG_RGB_16_BIT = B_RGB15_BIG
|
2002-07-09 16:24:59 +04:00
|
|
|
} color_space;
|
|
|
|
|
|
|
|
|
2008-06-03 21:44:46 +04:00
|
|
|
// Bitmap Support Flags
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
enum {
|
2008-06-03 21:44:46 +04:00
|
|
|
B_VIEWS_SUPPORT_DRAW_BITMAP = 0x1,
|
|
|
|
B_BITMAPS_SUPPORT_ATTACHED_VIEWS = 0x2,
|
2008-06-03 23:24:56 +04:00
|
|
|
B_BITMAPS_SUPPORT_OVERLAY = 0x4
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
2008-06-03 21:44:46 +04:00
|
|
|
bool bitmaps_support_space(color_space space, uint32* _supportFlags);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2008-06-03 21:44:46 +04:00
|
|
|
status_t get_pixel_size_for(color_space space, size_t* _pixelChunk,
|
|
|
|
size_t* _rowAlignment, size_t* _pixelsPerChunk);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
enum buffer_orientation {
|
|
|
|
B_BUFFER_TOP_TO_BOTTOM,
|
|
|
|
B_BUFFER_BOTTOM_TO_TOP
|
|
|
|
};
|
|
|
|
|
|
|
|
enum buffer_layout {
|
|
|
|
B_BUFFER_NONINTERLEAVED = 1
|
|
|
|
};
|
2008-06-03 21:44:46 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2008-06-03 21:44:46 +04:00
|
|
|
// Drawing Modes
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
enum drawing_mode {
|
|
|
|
B_OP_COPY,
|
|
|
|
B_OP_OVER,
|
|
|
|
B_OP_ERASE,
|
|
|
|
B_OP_INVERT,
|
|
|
|
B_OP_ADD,
|
|
|
|
B_OP_SUBTRACT,
|
|
|
|
B_OP_BLEND,
|
|
|
|
B_OP_MIN,
|
|
|
|
B_OP_MAX,
|
|
|
|
B_OP_SELECT,
|
|
|
|
B_OP_ALPHA
|
|
|
|
};
|
|
|
|
|
|
|
|
enum source_alpha {
|
2008-06-03 21:44:46 +04:00
|
|
|
B_PIXEL_ALPHA = 0,
|
2002-07-09 16:24:59 +04:00
|
|
|
B_CONSTANT_ALPHA
|
|
|
|
};
|
|
|
|
|
|
|
|
enum alpha_function {
|
2008-06-03 21:44:46 +04:00
|
|
|
B_ALPHA_OVERLAY = 0,
|
2002-07-09 16:24:59 +04:00
|
|
|
B_ALPHA_COMPOSITE
|
|
|
|
};
|
|
|
|
|
2008-06-03 21:44:46 +04:00
|
|
|
|
|
|
|
// Fixed Screen Modes
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
enum {
|
2008-06-03 21:44:46 +04:00
|
|
|
B_8_BIT_640x480 = 0x00000001,
|
|
|
|
B_8_BIT_800x600 = 0x00000002,
|
|
|
|
B_8_BIT_1024x768 = 0x00000004,
|
|
|
|
B_8_BIT_1280x1024 = 0x00000008,
|
|
|
|
B_8_BIT_1600x1200 = 0x00000010,
|
|
|
|
B_16_BIT_640x480 = 0x00000020,
|
|
|
|
B_16_BIT_800x600 = 0x00000040,
|
|
|
|
B_16_BIT_1024x768 = 0x00000080,
|
|
|
|
B_16_BIT_1280x1024 = 0x00000100,
|
|
|
|
B_16_BIT_1600x1200 = 0x00000200,
|
|
|
|
B_32_BIT_640x480 = 0x00000400,
|
|
|
|
B_32_BIT_800x600 = 0x00000800,
|
|
|
|
B_32_BIT_1024x768 = 0x00001000,
|
|
|
|
B_32_BIT_1280x1024 = 0x00002000,
|
|
|
|
B_32_BIT_1600x1200 = 0x00004000,
|
|
|
|
B_8_BIT_1152x900 = 0x00008000,
|
|
|
|
B_16_BIT_1152x900 = 0x00010000,
|
|
|
|
B_32_BIT_1152x900 = 0x00020000,
|
|
|
|
B_15_BIT_640x480 = 0x00040000,
|
|
|
|
B_15_BIT_800x600 = 0x00080000,
|
|
|
|
B_15_BIT_1024x768 = 0x00100000,
|
|
|
|
B_15_BIT_1280x1024 = 0x00200000,
|
|
|
|
B_15_BIT_1600x1200 = 0x00400000,
|
|
|
|
B_15_BIT_1152x900 = 0x00800000,
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2008-06-03 21:44:46 +04:00
|
|
|
B_8_BIT_640x400 = 0x80000000
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2008-06-03 21:44:46 +04:00
|
|
|
#endif // _GRAPHICS_DEFS_H
|