xref: /haiku/headers/private/graphics/video_overlay.h (revision b8ded2f89783a220c7b3019d48266a682cc79158)
1 #if !defined(_VIDEO_OVERLAY_H_)
2 #define _VIDEO_OVERLAY_H_
3 
4 /*
5 	Copyright Be Incorporated.
6 	This file will eventually be merged into Accelerant.h once the API is finalized.
7 */
8 
9 #include <Accelerant.h>
10 #include <GraphicsDefs.h>
11 
12 #if defined(__cplusplus)
13 extern "C" {
14 #endif
15 
16 enum {
17 	B_SUPPORTS_OVERLAYS = 1U << 31	// part of display_mode.flags
18 };
19 
20 enum {
21 	B_OVERLAY_COUNT = 0x08000000,
22 	B_OVERLAY_SUPPORTED_SPACES,
23 	B_OVERLAY_SUPPORTED_FEATURES,
24 	B_ALLOCATE_OVERLAY_BUFFER,
25 	B_RELEASE_OVERLAY_BUFFER,
26 	B_GET_OVERLAY_CONSTRAINTS,
27 	B_ALLOCATE_OVERLAY,
28 	B_RELEASE_OVERLAY,
29 	B_CONFIGURE_OVERLAY
30 };
31 
32 typedef struct {
33 	uint32	space;	/* color_space of buffer */
34 	uint16	width;	/* width in pixels */
35 	uint16	height;	/* height in lines */
36 	uint32	bytes_per_row;		/* number of bytes in one line */
37 	void	*buffer;		/* pointer to first byte of overlay buffer in virtual memory */
38 	void	*buffer_dma;	/* pointer to first byte of overlay buffer in physical memory for DMA */
39 } overlay_buffer;
40 
41 typedef struct {
42 	uint16	h_start;
43 	uint16	v_start;
44 	uint16	width;
45 	uint16	height;
46 } overlay_view;
47 
48 enum {
49 	B_OVERLAY_COLOR_KEY = 1 << 0,
50 	B_OVERLAY_CHROMA_KEY = 1 << 1,
51 	B_OVERLAY_HORIZONTAL_FILTERING = 1 << 2,
52 	B_OVERLAY_VERTICAL_FILTERING = 1 << 3,
53 	B_OVERLAY_HORIZONTAL_MIRRORING = 1 << 4,
54 	B_OVERLAY_KEYING_USES_ALPHA = 1 << 5
55 };
56 
57 typedef struct {
58 	uint8	value;	/* if DAC color component of graphic pixel & mask == value, */
59 	uint8	mask;	/*  then show overlay pixel, else show graphic pixel */
60 } overlay_key_color;
61 
62 typedef struct {
63 	int16	h_start;	/* Top left un-clipped corner of the window in the virtual display */
64 	int16	v_start;	/* Note that these are _signed_ values */
65 	uint16	width;		/* un-clipped width of the overlay window */
66 	uint16	height;		/* un-clipped height of the overlay window */
67 
68 	uint16	offset_left;	/* that portion of the overlay_window which is actually displayed */
69 	uint16	offset_top;		/* ie, the first line displayed is v_start + offset_top           */
70 	uint16	offset_right;	/*     and the first pixel displayed is h_start + offset_left     */
71 	uint16	offset_bottom;
72 
73 	overlay_key_color	red;	/* when using color keying, all components must match */
74 	overlay_key_color	green;
75 	overlay_key_color	blue;
76 	overlay_key_color	alpha;
77 	uint32	flags;	/* which features should be enabled.  See enum above. */
78 } overlay_window;
79 
80 typedef struct {
81 	uint16	min;
82 	uint16	max;
83 } overlay_uint16_minmax;
84 
85 typedef struct {
86 	float	min;
87 	float	max;
88 } overlay_float_minmax;
89 
90 typedef struct {
91 	uint16	h_alignment;	/* alignments: a 1 bit set in every bit which must be zero */
92 	uint16	v_alignment;
93 	uint16	width_alignment;
94 	uint16	height_alignment;
95 	overlay_uint16_minmax	width;	/* min and max sizes in each axis */
96 	overlay_uint16_minmax	height;
97 } overlay_limits;
98 
99 typedef struct {
100 	overlay_limits	view;
101 	overlay_limits	window;
102 	overlay_float_minmax	h_scale;
103 	overlay_float_minmax	v_scale;
104 } overlay_constraints;
105 
106 typedef void * overlay_token;
107 
108 typedef uint32 (*overlay_count)(const display_mode *dm);
109 typedef const uint32 *(*overlay_supported_spaces)(const display_mode *dm);
110 typedef uint32 (*overlay_supported_features)(uint32 a_color_space);
111 typedef const overlay_buffer *(*allocate_overlay_buffer)(color_space cs, uint16 width, uint16 height);
112 typedef status_t (*release_overlay_buffer)(const overlay_buffer *ob);
113 typedef status_t (*get_overlay_constraints)(const display_mode *dm, const overlay_buffer *ob, overlay_constraints *oc);
114 typedef overlay_token (*allocate_overlay)(void);
115 typedef status_t (*release_overlay)(overlay_token ot);
116 typedef status_t (*configure_overlay)(overlay_token ot, const overlay_buffer *ob, const overlay_window *ow, const overlay_view *ov);
117 
118 #if defined(__cplusplus)
119 }
120 #endif
121 
122 #endif
123