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
48 /* deinterlace allgorithem */
49 enum vl_compositor_deinterlace
52 VL_COMPOSITOR_BOB_TOP
,
53 VL_COMPOSITOR_BOB_BOTTOM
56 /* clockwise degree */
57 enum vl_compositor_rotation
59 VL_COMPOSITOR_ROTATE_0
,
60 VL_COMPOSITOR_ROTATE_90
,
61 VL_COMPOSITOR_ROTATE_180
,
62 VL_COMPOSITOR_ROTATE_270
65 struct vl_compositor_layer
70 struct pipe_viewport_state viewport
;
76 struct pipe_sampler_view
*sampler_views
[3];
78 struct vertex2f tl
, br
;
81 struct vertex4f colors
[4];
82 enum vl_compositor_rotation rotate
;
85 struct vl_compositor_state
87 struct pipe_context
*pipe
;
90 struct pipe_scissor_state scissor
;
91 struct pipe_resource
*csc_matrix
;
93 union pipe_color_union clear_color
;
95 unsigned used_layers
:VL_COMPOSITOR_MAX_LAYERS
;
96 struct vl_compositor_layer layers
[VL_COMPOSITOR_MAX_LAYERS
];
101 struct pipe_context
*pipe
;
102 struct u_upload_mgr
*upload
;
104 struct pipe_framebuffer_state fb_state
;
105 struct pipe_vertex_buffer vertex_buf
;
107 void *sampler_linear
;
108 void *sampler_nearest
;
109 void *blend_clear
, *blend_add
;
112 void *vertex_elems_state
;
115 void *fs_video_buffer
;
126 * initialize this compositor
129 vl_compositor_init(struct vl_compositor
*compositor
, struct pipe_context
*pipe
);
135 vl_compositor_init_state(struct vl_compositor_state
*state
, struct pipe_context
*pipe
);
138 * set yuv -> rgba conversion matrix
141 vl_compositor_set_csc_matrix(struct vl_compositor_state
*settings
,
142 const vl_csc_matrix
*matrix
,
143 float luma_min
, float luma_max
);
146 * reset dirty area, so it's cleared with the clear colour
149 vl_compositor_reset_dirty_area(struct u_rect
*dirty
);
152 * set the clear color
155 vl_compositor_set_clear_color(struct vl_compositor_state
*settings
, union pipe_color_union
*color
);
158 * get the clear color
161 vl_compositor_get_clear_color(struct vl_compositor_state
*settings
, union pipe_color_union
*color
);
164 * set the destination clipping
167 vl_compositor_set_dst_clip(struct vl_compositor_state
*settings
, struct u_rect
*dst_clip
);
170 * set overlay samplers
175 * reset all currently set layers
178 vl_compositor_clear_layers(struct vl_compositor_state
*state
);
181 * set the blender used to render a layer
184 vl_compositor_set_layer_blend(struct vl_compositor_state
*state
,
185 unsigned layer
, void *blend
, bool is_clearing
);
188 * set the layer destination area
191 vl_compositor_set_layer_dst_area(struct vl_compositor_state
*settings
,
192 unsigned layer
, struct u_rect
*dst_area
);
195 * set a video buffer as a layer to render
198 vl_compositor_set_buffer_layer(struct vl_compositor_state
*state
,
199 struct vl_compositor
*compositor
,
201 struct pipe_video_buffer
*buffer
,
202 struct u_rect
*src_rect
,
203 struct u_rect
*dst_rect
,
204 enum vl_compositor_deinterlace deinterlace
);
207 * set a paletted sampler as a layer to render
210 vl_compositor_set_palette_layer(struct vl_compositor_state
*state
,
211 struct vl_compositor
*compositor
,
213 struct pipe_sampler_view
*indexes
,
214 struct pipe_sampler_view
*palette
,
215 struct u_rect
*src_rect
,
216 struct u_rect
*dst_rect
,
217 bool include_color_conversion
);
220 * set a rgba sampler as a layer to render
223 vl_compositor_set_rgba_layer(struct vl_compositor_state
*state
,
224 struct vl_compositor
*compositor
,
226 struct pipe_sampler_view
*rgba
,
227 struct u_rect
*src_rect
,
228 struct u_rect
*dst_rect
,
229 struct vertex4f
*colors
);
232 * set the layer rotation
235 vl_compositor_set_layer_rotation(struct vl_compositor_state
*state
,
237 enum vl_compositor_rotation rotate
);
242 * render the layers to the frontbuffer
245 vl_compositor_render(struct vl_compositor_state
*state
,
246 struct vl_compositor
*compositor
,
247 struct pipe_surface
*dst_surface
,
248 struct u_rect
*dirty_area
,
252 * destroy this compositor
255 vl_compositor_cleanup(struct vl_compositor
*compositor
);
258 * destroy this state bag
261 vl_compositor_cleanup_state(struct vl_compositor_state
*state
);
263 #endif /* vl_compositor_h */