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
;
78 struct pipe_sampler_view
*sampler_views
[3];
80 struct vertex2f tl
, br
;
83 struct vertex4f colors
[4];
84 enum vl_compositor_rotation rotate
;
87 struct vl_compositor_state
89 struct pipe_context
*pipe
;
92 struct pipe_scissor_state scissor
;
93 struct pipe_resource
*csc_matrix
;
95 union pipe_color_union clear_color
;
97 unsigned used_layers
:VL_COMPOSITOR_MAX_LAYERS
;
98 struct vl_compositor_layer layers
[VL_COMPOSITOR_MAX_LAYERS
];
103 struct pipe_context
*pipe
;
105 struct pipe_framebuffer_state fb_state
;
106 struct pipe_vertex_buffer vertex_buf
;
108 void *sampler_linear
;
109 void *sampler_nearest
;
110 void *blend_clear
, *blend_add
;
113 void *vertex_elems_state
;
116 void *fs_video_buffer
;
143 * initialize this compositor
146 vl_compositor_init(struct vl_compositor
*compositor
, struct pipe_context
*pipe
);
152 vl_compositor_init_state(struct vl_compositor_state
*state
, struct pipe_context
*pipe
);
155 * set yuv -> rgba conversion matrix
158 vl_compositor_set_csc_matrix(struct vl_compositor_state
*settings
,
159 const vl_csc_matrix
*matrix
,
160 float luma_min
, float luma_max
);
163 * reset dirty area, so it's cleared with the clear colour
166 vl_compositor_reset_dirty_area(struct u_rect
*dirty
);
169 * set the clear color
172 vl_compositor_set_clear_color(struct vl_compositor_state
*settings
, union pipe_color_union
*color
);
175 * get the clear color
178 vl_compositor_get_clear_color(struct vl_compositor_state
*settings
, union pipe_color_union
*color
);
181 * set the destination clipping
184 vl_compositor_set_dst_clip(struct vl_compositor_state
*settings
, struct u_rect
*dst_clip
);
187 * set overlay samplers
192 * reset all currently set layers
195 vl_compositor_clear_layers(struct vl_compositor_state
*state
);
198 * set the blender used to render a layer
201 vl_compositor_set_layer_blend(struct vl_compositor_state
*state
,
202 unsigned layer
, void *blend
, bool is_clearing
);
205 * set the layer destination area
208 vl_compositor_set_layer_dst_area(struct vl_compositor_state
*settings
,
209 unsigned layer
, struct u_rect
*dst_area
);
212 * set a video buffer as a layer to render
215 vl_compositor_set_buffer_layer(struct vl_compositor_state
*state
,
216 struct vl_compositor
*compositor
,
218 struct pipe_video_buffer
*buffer
,
219 struct u_rect
*src_rect
,
220 struct u_rect
*dst_rect
,
221 enum vl_compositor_deinterlace deinterlace
);
224 * set a paletted sampler as a layer to render
227 vl_compositor_set_palette_layer(struct vl_compositor_state
*state
,
228 struct vl_compositor
*compositor
,
230 struct pipe_sampler_view
*indexes
,
231 struct pipe_sampler_view
*palette
,
232 struct u_rect
*src_rect
,
233 struct u_rect
*dst_rect
,
234 bool include_color_conversion
);
237 * set a rgba sampler as a layer to render
240 vl_compositor_set_rgba_layer(struct vl_compositor_state
*state
,
241 struct vl_compositor
*compositor
,
243 struct pipe_sampler_view
*rgba
,
244 struct u_rect
*src_rect
,
245 struct u_rect
*dst_rect
,
246 struct vertex4f
*colors
);
249 * set the layer rotation
252 vl_compositor_set_layer_rotation(struct vl_compositor_state
*state
,
254 enum vl_compositor_rotation rotate
);
257 * deinterlace yuv buffer with full abilities
260 vl_compositor_yuv_deint_full(struct vl_compositor_state
*state
,
261 struct vl_compositor
*compositor
,
262 struct pipe_video_buffer
*src
,
263 struct pipe_video_buffer
*dst
,
264 struct u_rect
*src_rect
,
265 struct u_rect
*dst_rect
,
266 enum vl_compositor_deinterlace deinterlace
);
269 + * convert rgb to yuv
272 vl_compositor_convert_rgb_to_yuv(struct vl_compositor_state
*state
,
273 struct vl_compositor
*compositor
,
275 struct pipe_resource
*src_res
,
276 struct pipe_video_buffer
*dst
,
277 struct u_rect
*src_rect
,
278 struct u_rect
*dst_rect
);
283 * render the layers to the frontbuffer
286 vl_compositor_render(struct vl_compositor_state
*state
,
287 struct vl_compositor
*compositor
,
288 struct pipe_surface
*dst_surface
,
289 struct u_rect
*dirty_area
,
293 * destroy this compositor
296 vl_compositor_cleanup(struct vl_compositor
*compositor
);
299 * destroy this state bag
302 vl_compositor_cleanup_state(struct vl_compositor_state
*state
);
304 #endif /* vl_compositor_h */