struct u_rect result;
// scale
- result.x0 = layer->dst.tl.x * s->viewport.scale[0] + s->viewport.translate[0];
- result.y0 = layer->dst.tl.y * s->viewport.scale[1] + s->viewport.translate[1];
- result.x1 = layer->dst.br.x * s->viewport.scale[0] + s->viewport.translate[0];
- result.y1 = layer->dst.br.y * s->viewport.scale[1] + s->viewport.translate[1];
+ result.x0 = layer->dst.tl.x * layer->viewport.scale[0] + layer->viewport.translate[0];
+ result.y0 = layer->dst.tl.y * layer->viewport.scale[1] + layer->viewport.translate[1];
+ result.x1 = layer->dst.br.x * layer->viewport.scale[0] + layer->viewport.translate[0];
+ result.y1 = layer->dst.br.y * layer->viewport.scale[1] + layer->viewport.translate[1];
// and clip
result.x0 = MAX2(result.x0, s->scissor.minx);
gen_rect_verts(vb, layer);
vb += 20;
+ if (!layer->viewport_valid) {
+ layer->viewport.scale[0] = c->fb_state.width;
+ layer->viewport.scale[1] = c->fb_state.height;
+ layer->viewport.translate[0] = 0;
+ layer->viewport.translate[1] = 0;
+ }
+
if (dirty && layer->clearing) {
struct u_rect drawn = calc_drawn_area(s, layer);
if (
void *blend = layer->blend ? layer->blend : i ? c->blend_add : c->blend_clear;
c->pipe->bind_blend_state(c->pipe, blend);
+ c->pipe->set_viewport_state(c->pipe, &layer->viewport);
c->pipe->bind_fs_state(c->pipe, layer->fs);
c->pipe->bind_fragment_sampler_states(c->pipe, num_sampler_views, layer->samplers);
c->pipe->set_fragment_sampler_views(c->pipe, num_sampler_views, samplers);
s->layers[i].clearing = i ? false : true;
s->layers[i].blend = NULL;
s->layers[i].fs = NULL;
+ s->layers[i].viewport.scale[2] = 1;
+ s->layers[i].viewport.scale[3] = 1;
+ s->layers[i].viewport.translate[2] = 0;
+ s->layers[i].viewport.translate[3] = 0;
+
for ( j = 0; j < 3; j++)
pipe_sampler_view_reference(&s->layers[i].sampler_views[j], NULL);
for ( j = 0; j < 4; ++j)
}
void
-vl_compositor_set_dst_area(struct vl_compositor_state *s, struct u_rect *dst_area)
-{
- assert(s);
-
- s->viewport_valid = dst_area != NULL;
- if (dst_area) {
- s->viewport.scale[0] = dst_area->x1 - dst_area->x0;
- s->viewport.scale[1] = dst_area->y1 - dst_area->y0;
- s->viewport.translate[0] = dst_area->x0;
- s->viewport.translate[1] = dst_area->y0;
- }
-}
-
-void
vl_compositor_set_dst_clip(struct vl_compositor_state *s, struct u_rect *dst_clip)
{
assert(s);
}
void
+vl_compositor_set_layer_dst_area(struct vl_compositor_state *s,
+ unsigned layer, struct u_rect *dst_area)
+{
+ assert(s);
+
+ assert(layer < VL_COMPOSITOR_MAX_LAYERS);
+
+ s->layers[layer].viewport_valid = dst_area != NULL;
+ if (dst_area) {
+ s->layers[layer].viewport.scale[0] = dst_area->x1 - dst_area->x0;
+ s->layers[layer].viewport.scale[1] = dst_area->y1 - dst_area->y0;
+ s->layers[layer].viewport.translate[0] = dst_area->x0;
+ s->layers[layer].viewport.translate[1] = dst_area->y0;
+ }
+}
+
+void
vl_compositor_set_buffer_layer(struct vl_compositor_state *s,
struct vl_compositor *c,
unsigned layer,
c->fb_state.height = dst_surface->height;
c->fb_state.cbufs[0] = dst_surface;
- if (!s->viewport_valid) {
- s->viewport.scale[0] = dst_surface->width;
- s->viewport.scale[1] = dst_surface->height;
- s->viewport.translate[0] = 0;
- s->viewport.translate[1] = 0;
- }
-
if (!s->scissor_valid) {
s->scissor.minx = 0;
s->scissor.miny = 0;
c->pipe->set_scissor_state(c->pipe, &s->scissor);
c->pipe->set_framebuffer_state(c->pipe, &c->fb_state);
- c->pipe->set_viewport_state(c->pipe, &s->viewport);
c->pipe->bind_vs_state(c->pipe, c->vs);
c->pipe->set_vertex_buffers(c->pipe, 1, &c->vertex_buf);
c->pipe->bind_vertex_elements_state(c->pipe, c->vertex_elems_state);
s->pipe = pipe;
- s->viewport.scale[2] = 1;
- s->viewport.scale[3] = 1;
- s->viewport.translate[2] = 0;
- s->viewport.translate[3] = 0;
-
s->clear_color.f[0] = s->clear_color.f[1] = 0.0f;
s->clear_color.f[2] = s->clear_color.f[3] = 0.0f;
{
bool clearing;
+ bool viewport_valid;
+ struct pipe_viewport_state viewport;
+
void *fs;
void *samplers[3];
void *blend;
{
struct pipe_context *pipe;
- bool viewport_valid, scissor_valid;
- struct pipe_viewport_state viewport;
+ bool scissor_valid;
struct pipe_scissor_state scissor;
struct pipe_resource *csc_matrix;
vl_compositor_get_clear_color(struct vl_compositor_state *settings, union pipe_color_union *color);
/**
- * set the destination area
- */
-void
-vl_compositor_set_dst_area(struct vl_compositor_state *settings, struct u_rect *dst_area);
-
-/**
* set the destination clipping
*/
void
unsigned layer, void *blend, bool is_clearing);
/**
+ * set the layer destination area
+ */
+void
+vl_compositor_set_layer_dst_area(struct vl_compositor_state *settings,
+ unsigned layer, struct u_rect *dst_area);
+
+/**
* set a video buffer as a layer to render
*/
void
default:
return VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE;
};
- vl_compositor_set_buffer_layer(&vmixer->cstate, compositor, layer++, surf->video_buffer,
+ vl_compositor_set_buffer_layer(&vmixer->cstate, compositor, layer, surf->video_buffer,
RectToPipe(video_source_rect, &src_rect), NULL, deinterlace);
- vl_compositor_set_dst_area(&vmixer->cstate, RectToPipe(destination_video_rect, &dst_rect));
+ vl_compositor_set_layer_dst_area(&vmixer->cstate, layer++, RectToPipe(destination_video_rect, &dst_rect));
vl_compositor_set_dst_clip(&vmixer->cstate, RectToPipe(destination_rect, &dst_clip));
vl_compositor_render(&vmixer->cstate, compositor, dst->surface, &dst->dirty_area);
vl_compositor_clear_layers(cstate);
vl_compositor_set_palette_layer(cstate, compositor, 0, sv_idx, sv_tbl, NULL, NULL, false);
- vl_compositor_set_dst_area(cstate, RectToPipe(destination_rect, &dst_rect));
+ vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
vl_compositor_render(cstate, compositor, vlsurface->surface, NULL);
pipe_sampler_view_reference(&sv_idx, NULL);
vl_compositor_set_layer_blend(cstate, 0, blend, false);
vl_compositor_set_rgba_layer(cstate, compositor, 0, src_vlsurface->sampler_view,
RectToPipe(source_rect, &src_rect), NULL, NULL);
- vl_compositor_set_dst_area(cstate, RectToPipe(destination_rect, &dst_rect));
+ vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
vl_compositor_render(cstate, compositor, dst_vlsurface->surface, NULL);
context->delete_blend_state(context, blend);