vl/compositor: add support for per layer dst areas
Signed-off-by: Christian König <deathsimple@vodafone.de>
This commit is contained in:
parent
b90727bb24
commit
74a4e90894
|
@ -641,10 +641,10 @@ calc_drawn_area(struct vl_compositor_state *s, struct vl_compositor_layer *layer
|
||||||
struct u_rect result;
|
struct u_rect result;
|
||||||
|
|
||||||
// scale
|
// scale
|
||||||
result.x0 = layer->dst.tl.x * s->viewport.scale[0] + s->viewport.translate[0];
|
result.x0 = layer->dst.tl.x * layer->viewport.scale[0] + layer->viewport.translate[0];
|
||||||
result.y0 = layer->dst.tl.y * s->viewport.scale[1] + s->viewport.translate[1];
|
result.y0 = layer->dst.tl.y * layer->viewport.scale[1] + layer->viewport.translate[1];
|
||||||
result.x1 = layer->dst.br.x * s->viewport.scale[0] + s->viewport.translate[0];
|
result.x1 = layer->dst.br.x * layer->viewport.scale[0] + layer->viewport.translate[0];
|
||||||
result.y1 = layer->dst.br.y * s->viewport.scale[1] + s->viewport.translate[1];
|
result.y1 = layer->dst.br.y * layer->viewport.scale[1] + layer->viewport.translate[1];
|
||||||
|
|
||||||
// and clip
|
// and clip
|
||||||
result.x0 = MAX2(result.x0, s->scissor.minx);
|
result.x0 = MAX2(result.x0, s->scissor.minx);
|
||||||
|
@ -681,6 +681,13 @@ gen_vertex_data(struct vl_compositor *c, struct vl_compositor_state *s, struct u
|
||||||
gen_rect_verts(vb, layer);
|
gen_rect_verts(vb, layer);
|
||||||
vb += 20;
|
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) {
|
if (dirty && layer->clearing) {
|
||||||
struct u_rect drawn = calc_drawn_area(s, layer);
|
struct u_rect drawn = calc_drawn_area(s, layer);
|
||||||
if (
|
if (
|
||||||
|
@ -715,6 +722,7 @@ draw_layers(struct vl_compositor *c, struct vl_compositor_state *s, struct u_rec
|
||||||
void *blend = layer->blend ? layer->blend : i ? c->blend_add : c->blend_clear;
|
void *blend = layer->blend ? layer->blend : i ? c->blend_add : c->blend_clear;
|
||||||
|
|
||||||
c->pipe->bind_blend_state(c->pipe, blend);
|
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_fs_state(c->pipe, layer->fs);
|
||||||
c->pipe->bind_fragment_sampler_states(c->pipe, num_sampler_views, layer->samplers);
|
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);
|
c->pipe->set_fragment_sampler_views(c->pipe, num_sampler_views, samplers);
|
||||||
|
@ -773,6 +781,11 @@ vl_compositor_clear_layers(struct vl_compositor_state *s)
|
||||||
s->layers[i].clearing = i ? false : true;
|
s->layers[i].clearing = i ? false : true;
|
||||||
s->layers[i].blend = NULL;
|
s->layers[i].blend = NULL;
|
||||||
s->layers[i].fs = 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++)
|
for ( j = 0; j < 3; j++)
|
||||||
pipe_sampler_view_reference(&s->layers[i].sampler_views[j], NULL);
|
pipe_sampler_view_reference(&s->layers[i].sampler_views[j], NULL);
|
||||||
for ( j = 0; j < 4; ++j)
|
for ( j = 0; j < 4; ++j)
|
||||||
|
@ -809,20 +822,6 @@ vl_compositor_set_csc_matrix(struct vl_compositor_state *s, const float matrix[1
|
||||||
pipe_buffer_unmap(s->pipe, buf_transfer);
|
pipe_buffer_unmap(s->pipe, buf_transfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
void
|
||||||
vl_compositor_set_dst_clip(struct vl_compositor_state *s, struct u_rect *dst_clip)
|
vl_compositor_set_dst_clip(struct vl_compositor_state *s, struct u_rect *dst_clip)
|
||||||
{
|
{
|
||||||
|
@ -850,6 +849,23 @@ vl_compositor_set_layer_blend(struct vl_compositor_state *s,
|
||||||
s->layers[layer].blend = blend;
|
s->layers[layer].blend = blend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
void
|
||||||
vl_compositor_set_buffer_layer(struct vl_compositor_state *s,
|
vl_compositor_set_buffer_layer(struct vl_compositor_state *s,
|
||||||
struct vl_compositor *c,
|
struct vl_compositor *c,
|
||||||
|
@ -978,13 +994,6 @@ vl_compositor_render(struct vl_compositor_state *s,
|
||||||
c->fb_state.height = dst_surface->height;
|
c->fb_state.height = dst_surface->height;
|
||||||
c->fb_state.cbufs[0] = dst_surface;
|
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) {
|
if (!s->scissor_valid) {
|
||||||
s->scissor.minx = 0;
|
s->scissor.minx = 0;
|
||||||
s->scissor.miny = 0;
|
s->scissor.miny = 0;
|
||||||
|
@ -1005,7 +1014,6 @@ vl_compositor_render(struct vl_compositor_state *s,
|
||||||
|
|
||||||
c->pipe->set_scissor_state(c->pipe, &s->scissor);
|
c->pipe->set_scissor_state(c->pipe, &s->scissor);
|
||||||
c->pipe->set_framebuffer_state(c->pipe, &c->fb_state);
|
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->bind_vs_state(c->pipe, c->vs);
|
||||||
c->pipe->set_vertex_buffers(c->pipe, 1, &c->vertex_buf);
|
c->pipe->set_vertex_buffers(c->pipe, 1, &c->vertex_buf);
|
||||||
c->pipe->bind_vertex_elements_state(c->pipe, c->vertex_elems_state);
|
c->pipe->bind_vertex_elements_state(c->pipe, c->vertex_elems_state);
|
||||||
|
@ -1052,11 +1060,6 @@ vl_compositor_init_state(struct vl_compositor_state *s, struct pipe_context *pip
|
||||||
|
|
||||||
s->pipe = pipe;
|
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[0] = s->clear_color.f[1] = 0.0f;
|
||||||
s->clear_color.f[2] = s->clear_color.f[3] = 0.0f;
|
s->clear_color.f[2] = s->clear_color.f[3] = 0.0f;
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,9 @@ struct vl_compositor_layer
|
||||||
{
|
{
|
||||||
bool clearing;
|
bool clearing;
|
||||||
|
|
||||||
|
bool viewport_valid;
|
||||||
|
struct pipe_viewport_state viewport;
|
||||||
|
|
||||||
void *fs;
|
void *fs;
|
||||||
void *samplers[3];
|
void *samplers[3];
|
||||||
void *blend;
|
void *blend;
|
||||||
|
@ -72,8 +75,7 @@ struct vl_compositor_state
|
||||||
{
|
{
|
||||||
struct pipe_context *pipe;
|
struct pipe_context *pipe;
|
||||||
|
|
||||||
bool viewport_valid, scissor_valid;
|
bool scissor_valid;
|
||||||
struct pipe_viewport_state viewport;
|
|
||||||
struct pipe_scissor_state scissor;
|
struct pipe_scissor_state scissor;
|
||||||
struct pipe_resource *csc_matrix;
|
struct pipe_resource *csc_matrix;
|
||||||
|
|
||||||
|
@ -144,12 +146,6 @@ vl_compositor_set_clear_color(struct vl_compositor_state *settings, union pipe_c
|
||||||
void
|
void
|
||||||
vl_compositor_get_clear_color(struct vl_compositor_state *settings, union pipe_color_union *color);
|
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
|
* set the destination clipping
|
||||||
*/
|
*/
|
||||||
|
@ -174,6 +170,13 @@ void
|
||||||
vl_compositor_set_layer_blend(struct vl_compositor_state *state,
|
vl_compositor_set_layer_blend(struct vl_compositor_state *state,
|
||||||
unsigned layer, void *blend, bool is_clearing);
|
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
|
* set a video buffer as a layer to render
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -265,9 +265,9 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
|
||||||
default:
|
default:
|
||||||
return VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE;
|
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);
|
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_set_dst_clip(&vmixer->cstate, RectToPipe(destination_rect, &dst_clip));
|
||||||
vl_compositor_render(&vmixer->cstate, compositor, dst->surface, &dst->dirty_area);
|
vl_compositor_render(&vmixer->cstate, compositor, dst->surface, &dst->dirty_area);
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
|
||||||
|
|
||||||
vl_compositor_clear_layers(cstate);
|
vl_compositor_clear_layers(cstate);
|
||||||
vl_compositor_set_palette_layer(cstate, compositor, 0, sv_idx, sv_tbl, NULL, NULL, false);
|
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);
|
vl_compositor_render(cstate, compositor, vlsurface->surface, NULL);
|
||||||
|
|
||||||
pipe_sampler_view_reference(&sv_idx, NULL);
|
pipe_sampler_view_reference(&sv_idx, NULL);
|
||||||
|
@ -473,7 +473,7 @@ vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface,
|
||||||
vl_compositor_set_layer_blend(cstate, 0, blend, false);
|
vl_compositor_set_layer_blend(cstate, 0, blend, false);
|
||||||
vl_compositor_set_rgba_layer(cstate, compositor, 0, src_vlsurface->sampler_view,
|
vl_compositor_set_rgba_layer(cstate, compositor, 0, src_vlsurface->sampler_view,
|
||||||
RectToPipe(source_rect, &src_rect), NULL, NULL);
|
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);
|
vl_compositor_render(cstate, compositor, dst_vlsurface->surface, NULL);
|
||||||
|
|
||||||
context->delete_blend_state(context, blend);
|
context->delete_blend_state(context, blend);
|
||||||
|
|
|
@ -432,7 +432,8 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
|
||||||
// Workaround for r600g, there seems to be a bug in the fence refcounting code
|
// Workaround for r600g, there seems to be a bug in the fence refcounting code
|
||||||
pipe->screen->fence_reference(pipe->screen, &surface_priv->fence, NULL);
|
pipe->screen->fence_reference(pipe->screen, &surface_priv->fence, NULL);
|
||||||
|
|
||||||
vl_compositor_set_dst_area(cstate, &dst_rect);
|
vl_compositor_set_layer_dst_area(cstate, 0, &dst_rect);
|
||||||
|
vl_compositor_set_layer_dst_area(cstate, 1, &dst_rect);
|
||||||
vl_compositor_render(cstate, compositor, surf, dirty_area);
|
vl_compositor_render(cstate, compositor, surf, dirty_area);
|
||||||
|
|
||||||
pipe->flush(pipe, &surface_priv->fence);
|
pipe->flush(pipe, &surface_priv->fence);
|
||||||
|
|
Loading…
Reference in New Issue