[Mesa-dev] [PATCH 1/2] vl: Add rotation
Christian König
deathsimple at vodafone.de
Thu Mar 6 00:54:11 PST 2014
Hi Kusanagi,
Am 06.03.2014 09:20, schrieb Kusanagi Kouichi:
> Signed-off-by: Kusanagi Kouichi <slash at ac.auone-net.jp>
> ---
> src/gallium/auxiliary/vl/vl_compositor.c | 52 +++++++++++++++++++++++++++++---
> src/gallium/auxiliary/vl/vl_compositor.h | 13 +++++++-
> 2 files changed, 60 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
> index 3cea044..031efb3 100644
> --- a/src/gallium/auxiliary/vl/vl_compositor.c
> +++ b/src/gallium/auxiliary/vl/vl_compositor.c
> @@ -570,6 +570,10 @@ calc_src_and_dst(struct vl_compositor_layer *layer, unsigned width, unsigned hei
> layer->src.br = calc_bottomright(size, src);
> layer->dst.tl = calc_topleft(size, dst);
> layer->dst.br = calc_bottomright(size, dst);
> + layer->dst.tr.x = layer->dst.br.x;
> + layer->dst.tr.y = layer->dst.tl.y;
> + layer->dst.bl.x = layer->dst.tl.x;
> + layer->dst.bl.y = layer->dst.br.y;
> layer->zw.x = 0.0f;
> layer->zw.y = size.y;
> }
> @@ -589,8 +593,8 @@ gen_rect_verts(struct vertex2f *vb, struct vl_compositor_layer *layer)
> vb[ 4].x = layer->colors[0].z;
> vb[ 4].y = layer->colors[0].w;
>
> - vb[ 5].x = layer->dst.br.x;
> - vb[ 5].y = layer->dst.tl.y;
> + vb[ 5].x = layer->dst.tr.x;
> + vb[ 5].y = layer->dst.tr.y;
> vb[ 6].x = layer->src.br.x;
> vb[ 6].y = layer->src.tl.y;
> vb[ 7] = layer->zw;
> @@ -609,8 +613,8 @@ gen_rect_verts(struct vertex2f *vb, struct vl_compositor_layer *layer)
> vb[14].x = layer->colors[2].z;
> vb[14].y = layer->colors[2].w;
>
> - vb[15].x = layer->dst.tl.x;
> - vb[15].y = layer->dst.br.y;
> + vb[15].x = layer->dst.bl.x;
> + vb[15].y = layer->dst.bl.y;
> vb[16].x = layer->src.tl.x;
> vb[16].y = layer->src.br.y;
> vb[17] = layer->zw;
A good start, but I would prefer that you do the rotation in
gen_rect_verts instead and keep dst as it is. Also please define an enum
for the rotation, make this enum compatible with VDPAU and have static
asserts in the VDPAU state tracker on this assumption.
Thx for working on this,
Christian.
> @@ -964,6 +968,46 @@ vl_compositor_set_rgba_layer(struct vl_compositor_state *s,
> }
>
> void
> +vl_compositor_rotate_layer(struct vl_compositor_state *s,
> + unsigned layer,
> + int rotate)
> +{
> + struct vl_compositor_layer *l;
> + struct vertex2f v;
> +
> + assert(s);
> + assert(layer < VL_COMPOSITOR_MAX_LAYERS);
> +
> + l = &s->layers[layer];
> + switch (rotate) {
> + case 1:
> + v = l->dst.tl;
> + l->dst.tl = l->dst.tr;
> + l->dst.tr = l->dst.br;
> + l->dst.br = l->dst.bl;
> + l->dst.bl = v;
> + break;
> + case 2:
> + v = l->dst.tl;
> + l->dst.tl = l->dst.br;
> + l->dst.br = v;
> + v = l->dst.tr;
> + l->dst.tr = l->dst.bl;
> + l->dst.bl = v;
> + break;
> + case 3:
> + v = l->dst.bl;
> + l->dst.bl = l->dst.br;
> + l->dst.br = l->dst.tr;
> + l->dst.tr = l->dst.tl;
> + l->dst.tl = v;
> + break;
> + default:
> + break;
> + }
> +}
> +
> +void
> vl_compositor_render(struct vl_compositor_state *s,
> struct vl_compositor *c,
> struct pipe_surface *dst_surface,
> diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h
> index 97cbef0..38383d8 100644
> --- a/src/gallium/auxiliary/vl/vl_compositor.h
> +++ b/src/gallium/auxiliary/vl/vl_compositor.h
> @@ -67,7 +67,10 @@ struct vl_compositor_layer
> struct pipe_sampler_view *sampler_views[3];
> struct {
> struct vertex2f tl, br;
> - } src, dst;
> + } src;
> + struct {
> + struct vertex2f tl, tr, br, bl;
> + } dst;
> struct vertex2f zw;
> struct vertex4f colors[4];
> };
> @@ -216,6 +219,14 @@ vl_compositor_set_rgba_layer(struct vl_compositor_state *state,
> struct u_rect *dst_rect,
> struct vertex4f *colors);
>
> +/**
> + * rotate a layer
> + */
> +void
> +vl_compositor_rotate_layer(struct vl_compositor_state *state,
> + unsigned layer,
> + int rotate);
> +
> /*@}*/
>
> /**
More information about the mesa-dev
mailing list