gallium/auxiliary/vl: Fix duplicate symbol build errors.
[mesa.git] / src / gallium / auxiliary / vl / vl_compositor.h
1 /**************************************************************************
2 *
3 * Copyright 2009 Younes Manton.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef vl_compositor_h
29 #define vl_compositor_h
30
31 #include "pipe/p_state.h"
32 #include "pipe/p_video_codec.h"
33 #include "pipe/p_video_state.h"
34
35 #include "util/u_rect.h"
36
37 #include "vl_types.h"
38 #include "vl_csc.h"
39
40 struct pipe_context;
41
42 /**
43 * composing and displaying of image data
44 */
45
46 #define VL_COMPOSITOR_MAX_LAYERS 16
47 #define VL_COMPOSITOR_MIN_DIRTY (0)
48 #define VL_COMPOSITOR_MAX_DIRTY (1 << 15)
49
50 /* deinterlace allgorithem */
51 enum vl_compositor_deinterlace
52 {
53 VL_COMPOSITOR_WEAVE,
54 VL_COMPOSITOR_BOB_TOP,
55 VL_COMPOSITOR_BOB_BOTTOM
56 };
57
58 /* clockwise degree */
59 enum vl_compositor_rotation
60 {
61 VL_COMPOSITOR_ROTATE_0,
62 VL_COMPOSITOR_ROTATE_90,
63 VL_COMPOSITOR_ROTATE_180,
64 VL_COMPOSITOR_ROTATE_270
65 };
66
67 struct vl_compositor_layer
68 {
69 bool clearing;
70
71 bool viewport_valid;
72 struct pipe_viewport_state viewport;
73
74 void *fs;
75 void *cs;
76 void *samplers[3];
77 void *blend;
78
79 struct pipe_sampler_view *sampler_views[3];
80 struct {
81 struct vertex2f tl, br;
82 } src, dst;
83 struct vertex2f zw;
84 struct vertex4f colors[4];
85 enum vl_compositor_rotation rotate;
86 };
87
88 struct vl_compositor_state
89 {
90 struct pipe_context *pipe;
91
92 bool scissor_valid;
93 struct pipe_scissor_state scissor;
94 struct pipe_resource *shader_params;
95
96 union pipe_color_union clear_color;
97
98 unsigned used_layers:VL_COMPOSITOR_MAX_LAYERS;
99 struct vl_compositor_layer layers[VL_COMPOSITOR_MAX_LAYERS];
100 };
101
102 struct vl_compositor
103 {
104 struct pipe_context *pipe;
105
106 struct pipe_framebuffer_state fb_state;
107 struct pipe_vertex_buffer vertex_buf;
108
109 void *sampler_linear;
110 void *sampler_nearest;
111 void *blend_clear, *blend_add;
112 void *rast;
113 void *dsa;
114 void *vertex_elems_state;
115
116 void *vs;
117 void *fs_video_buffer;
118 void *fs_weave_rgb;
119 void *fs_rgba;
120 void *cs_video_buffer;
121 void *cs_weave_rgb;
122 void *cs_rgba;
123
124 bool pipe_compute_supported;
125
126 struct {
127 struct {
128 void *y;
129 void *uv;
130 } weave;
131 struct {
132 void *y;
133 void *uv;
134 } bob;
135 } fs_yuv;
136
137 struct {
138 void *rgb;
139 void *yuv;
140 } fs_palette;
141
142 struct {
143 void *y;
144 void *uv;
145 } fs_rgb_yuv;
146 };
147
148 /**
149 * initialize this compositor
150 */
151 bool
152 vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *pipe);
153
154 /**
155 * init state bag
156 */
157 bool
158 vl_compositor_init_state(struct vl_compositor_state *state, struct pipe_context *pipe);
159
160 /**
161 * set yuv -> rgba conversion matrix
162 */
163 bool
164 vl_compositor_set_csc_matrix(struct vl_compositor_state *settings,
165 const vl_csc_matrix *matrix,
166 float luma_min, float luma_max);
167
168 /**
169 * reset dirty area, so it's cleared with the clear colour
170 */
171 void
172 vl_compositor_reset_dirty_area(struct u_rect *dirty);
173
174 /**
175 * set the clear color
176 */
177 void
178 vl_compositor_set_clear_color(struct vl_compositor_state *settings, union pipe_color_union *color);
179
180 /**
181 * get the clear color
182 */
183 void
184 vl_compositor_get_clear_color(struct vl_compositor_state *settings, union pipe_color_union *color);
185
186 /**
187 * set the destination clipping
188 */
189 void
190 vl_compositor_set_dst_clip(struct vl_compositor_state *settings, struct u_rect *dst_clip);
191
192 /**
193 * set overlay samplers
194 */
195 /*@{*/
196
197 /**
198 * reset all currently set layers
199 */
200 void
201 vl_compositor_clear_layers(struct vl_compositor_state *state);
202
203 /**
204 * set the blender used to render a layer
205 */
206 void
207 vl_compositor_set_layer_blend(struct vl_compositor_state *state,
208 unsigned layer, void *blend, bool is_clearing);
209
210 /**
211 * set the layer destination area
212 */
213 void
214 vl_compositor_set_layer_dst_area(struct vl_compositor_state *settings,
215 unsigned layer, struct u_rect *dst_area);
216
217 /**
218 * set a video buffer as a layer to render
219 */
220 void
221 vl_compositor_set_buffer_layer(struct vl_compositor_state *state,
222 struct vl_compositor *compositor,
223 unsigned layer,
224 struct pipe_video_buffer *buffer,
225 struct u_rect *src_rect,
226 struct u_rect *dst_rect,
227 enum vl_compositor_deinterlace deinterlace);
228
229 /**
230 * set a paletted sampler as a layer to render
231 */
232 void
233 vl_compositor_set_palette_layer(struct vl_compositor_state *state,
234 struct vl_compositor *compositor,
235 unsigned layer,
236 struct pipe_sampler_view *indexes,
237 struct pipe_sampler_view *palette,
238 struct u_rect *src_rect,
239 struct u_rect *dst_rect,
240 bool include_color_conversion);
241
242 /**
243 * set a rgba sampler as a layer to render
244 */
245 void
246 vl_compositor_set_rgba_layer(struct vl_compositor_state *state,
247 struct vl_compositor *compositor,
248 unsigned layer,
249 struct pipe_sampler_view *rgba,
250 struct u_rect *src_rect,
251 struct u_rect *dst_rect,
252 struct vertex4f *colors);
253
254 /**
255 * set the layer rotation
256 */
257 void
258 vl_compositor_set_layer_rotation(struct vl_compositor_state *state,
259 unsigned layer,
260 enum vl_compositor_rotation rotate);
261
262 /**
263 * deinterlace yuv buffer with full abilities
264 */
265 void
266 vl_compositor_yuv_deint_full(struct vl_compositor_state *state,
267 struct vl_compositor *compositor,
268 struct pipe_video_buffer *src,
269 struct pipe_video_buffer *dst,
270 struct u_rect *src_rect,
271 struct u_rect *dst_rect,
272 enum vl_compositor_deinterlace deinterlace);
273
274 /**
275 + * convert rgb to yuv
276 + */
277 void
278 vl_compositor_convert_rgb_to_yuv(struct vl_compositor_state *state,
279 struct vl_compositor *compositor,
280 unsigned layer,
281 struct pipe_resource *src_res,
282 struct pipe_video_buffer *dst,
283 struct u_rect *src_rect,
284 struct u_rect *dst_rect);
285
286 /*@}*/
287
288 /**
289 * render the layers to the frontbuffer
290 */
291 void
292 vl_compositor_render(struct vl_compositor_state *state,
293 struct vl_compositor *compositor,
294 struct pipe_surface *dst_surface,
295 struct u_rect *dirty_area,
296 bool clear_dirty);
297
298 /**
299 * destroy this compositor
300 */
301 void
302 vl_compositor_cleanup(struct vl_compositor *compositor);
303
304 /**
305 * destroy this state bag
306 */
307 void
308 vl_compositor_cleanup_state(struct vl_compositor_state *state);
309
310 #endif /* vl_compositor_h */