1 /**************************************************************************
3 * Copyright 2009 Younes Manton.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #ifndef vl_compositor_h
29 #define vl_compositor_h
31 #include "pipe/p_state.h"
32 #include "pipe/p_video_codec.h"
33 #include "pipe/p_video_state.h"
35 #include "util/u_rect.h"
43 * composing and displaying of image data
46 #define VL_COMPOSITOR_MAX_LAYERS 16
47 #define VL_COMPOSITOR_MIN_DIRTY (0)
48 #define VL_COMPOSITOR_MAX_DIRTY (1 << 15)
50 /* deinterlace allgorithem */
51 enum vl_compositor_deinterlace
54 VL_COMPOSITOR_BOB_TOP
,
55 VL_COMPOSITOR_BOB_BOTTOM
58 /* clockwise degree */
59 enum vl_compositor_rotation
61 VL_COMPOSITOR_ROTATE_0
,
62 VL_COMPOSITOR_ROTATE_90
,
63 VL_COMPOSITOR_ROTATE_180
,
64 VL_COMPOSITOR_ROTATE_270
67 struct vl_compositor_layer
72 struct pipe_viewport_state viewport
;
79 struct pipe_sampler_view
*sampler_views
[3];
81 struct vertex2f tl
, br
;
84 struct vertex4f colors
[4];
85 enum vl_compositor_rotation rotate
;
88 struct vl_compositor_state
90 struct pipe_context
*pipe
;
93 struct pipe_scissor_state scissor
;
94 struct pipe_resource
*shader_params
;
96 union pipe_color_union clear_color
;
98 unsigned used_layers
:VL_COMPOSITOR_MAX_LAYERS
;
99 struct vl_compositor_layer layers
[VL_COMPOSITOR_MAX_LAYERS
];
104 struct pipe_context
*pipe
;
106 struct pipe_framebuffer_state fb_state
;
107 struct pipe_vertex_buffer vertex_buf
;
109 void *sampler_linear
;
110 void *sampler_nearest
;
111 void *blend_clear
, *blend_add
;
114 void *vertex_elems_state
;
117 void *fs_video_buffer
;
120 void *cs_video_buffer
;
124 bool pipe_cs_composit_supported
;
125 bool pipe_gfx_supported
;
161 * initialize this compositor
164 vl_compositor_init(struct vl_compositor
*compositor
, struct pipe_context
*pipe
);
170 vl_compositor_init_state(struct vl_compositor_state
*state
, struct pipe_context
*pipe
);
173 * set yuv -> rgba conversion matrix
176 vl_compositor_set_csc_matrix(struct vl_compositor_state
*settings
,
177 const vl_csc_matrix
*matrix
,
178 float luma_min
, float luma_max
);
181 * reset dirty area, so it's cleared with the clear colour
184 vl_compositor_reset_dirty_area(struct u_rect
*dirty
);
187 * set the clear color
190 vl_compositor_set_clear_color(struct vl_compositor_state
*settings
, union pipe_color_union
*color
);
193 * get the clear color
196 vl_compositor_get_clear_color(struct vl_compositor_state
*settings
, union pipe_color_union
*color
);
199 * set the destination clipping
202 vl_compositor_set_dst_clip(struct vl_compositor_state
*settings
, struct u_rect
*dst_clip
);
205 * set overlay samplers
210 * reset all currently set layers
213 vl_compositor_clear_layers(struct vl_compositor_state
*state
);
216 * set the blender used to render a layer
219 vl_compositor_set_layer_blend(struct vl_compositor_state
*state
,
220 unsigned layer
, void *blend
, bool is_clearing
);
223 * set the layer destination area
226 vl_compositor_set_layer_dst_area(struct vl_compositor_state
*settings
,
227 unsigned layer
, struct u_rect
*dst_area
);
230 * set a video buffer as a layer to render
233 vl_compositor_set_buffer_layer(struct vl_compositor_state
*state
,
234 struct vl_compositor
*compositor
,
236 struct pipe_video_buffer
*buffer
,
237 struct u_rect
*src_rect
,
238 struct u_rect
*dst_rect
,
239 enum vl_compositor_deinterlace deinterlace
);
242 * set a paletted sampler as a layer to render
245 vl_compositor_set_palette_layer(struct vl_compositor_state
*state
,
246 struct vl_compositor
*compositor
,
248 struct pipe_sampler_view
*indexes
,
249 struct pipe_sampler_view
*palette
,
250 struct u_rect
*src_rect
,
251 struct u_rect
*dst_rect
,
252 bool include_color_conversion
);
255 * set a rgba sampler as a layer to render
258 vl_compositor_set_rgba_layer(struct vl_compositor_state
*state
,
259 struct vl_compositor
*compositor
,
261 struct pipe_sampler_view
*rgba
,
262 struct u_rect
*src_rect
,
263 struct u_rect
*dst_rect
,
264 struct vertex4f
*colors
);
267 * set the layer rotation
270 vl_compositor_set_layer_rotation(struct vl_compositor_state
*state
,
272 enum vl_compositor_rotation rotate
);
275 * deinterlace yuv buffer with full abilities
278 vl_compositor_yuv_deint_full(struct vl_compositor_state
*state
,
279 struct vl_compositor
*compositor
,
280 struct pipe_video_buffer
*src
,
281 struct pipe_video_buffer
*dst
,
282 struct u_rect
*src_rect
,
283 struct u_rect
*dst_rect
,
284 enum vl_compositor_deinterlace deinterlace
);
287 + * convert rgb to yuv
290 vl_compositor_convert_rgb_to_yuv(struct vl_compositor_state
*state
,
291 struct vl_compositor
*compositor
,
293 struct pipe_resource
*src_res
,
294 struct pipe_video_buffer
*dst
,
295 struct u_rect
*src_rect
,
296 struct u_rect
*dst_rect
);
301 * render the layers to the frontbuffer
304 vl_compositor_render(struct vl_compositor_state
*state
,
305 struct vl_compositor
*compositor
,
306 struct pipe_surface
*dst_surface
,
307 struct u_rect
*dirty_area
,
311 * destroy this compositor
314 vl_compositor_cleanup(struct vl_compositor
*compositor
);
317 * destroy this state bag
320 vl_compositor_cleanup_state(struct vl_compositor_state
*state
);
322 #endif /* vl_compositor_h */