Signed-off-by: Kusanagi Kouichi <sl...@ac.auone-net.jp> --- src/gallium/auxiliary/vl/vl_compositor.c | 64 ++++++++++++++++++++++++++++---- src/gallium/auxiliary/vl/vl_compositor.h | 18 +++++++++ 2 files changed, 74 insertions(+), 8 deletions(-)
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c index 3cea044..ad08b52 100644 --- a/src/gallium/auxiliary/vl/vl_compositor.c +++ b/src/gallium/auxiliary/vl/vl_compositor.c @@ -577,10 +577,48 @@ calc_src_and_dst(struct vl_compositor_layer *layer, unsigned width, unsigned hei static void gen_rect_verts(struct vertex2f *vb, struct vl_compositor_layer *layer) { + struct vertex2f tl, tr, br, bl; + assert(vb && layer); - vb[ 0].x = layer->dst.tl.x; - vb[ 0].y = layer->dst.tl.y; + switch (layer->rotate) { + default: + case VL_COMPOSITOR_ROTATE_0: + tl = layer->dst.tl; + tr.x = layer->dst.br.x; + tr.y = layer->dst.tl.y; + br = layer->dst.br; + bl.x = layer->dst.tl.x; + bl.y = layer->dst.br.y; + break; + case VL_COMPOSITOR_ROTATE_90: + tl.x = layer->dst.br.x; + tl.y = layer->dst.tl.y; + tr = layer->dst.br; + br.x = layer->dst.tl.x; + br.y = layer->dst.br.y; + bl = layer->dst.tl; + break; + case VL_COMPOSITOR_ROTATE_180: + tl = layer->dst.br; + tr.x = layer->dst.tl.x; + tr.y = layer->dst.br.y; + br = layer->dst.tl; + bl.x = layer->dst.br.x; + bl.y = layer->dst.tl.y; + break; + case VL_COMPOSITOR_ROTATE_270: + tl.x = layer->dst.tl.x; + tl.y = layer->dst.br.y; + tr = layer->dst.tl; + br.x = layer->dst.br.x; + br.y = layer->dst.tl.y; + bl = layer->dst.br; + break; + } + + vb[ 0].x = tl.x; + vb[ 0].y = tl.y; vb[ 1].x = layer->src.tl.x; vb[ 1].y = layer->src.tl.y; vb[ 2] = layer->zw; @@ -589,8 +627,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 = tr.x; + vb[ 5].y = tr.y; vb[ 6].x = layer->src.br.x; vb[ 6].y = layer->src.tl.y; vb[ 7] = layer->zw; @@ -599,8 +637,8 @@ gen_rect_verts(struct vertex2f *vb, struct vl_compositor_layer *layer) vb[ 9].x = layer->colors[1].z; vb[ 9].y = layer->colors[1].w; - vb[10].x = layer->dst.br.x; - vb[10].y = layer->dst.br.y; + vb[10].x = br.x; + vb[10].y = br.y; vb[11].x = layer->src.br.x; vb[11].y = layer->src.br.y; vb[12] = layer->zw; @@ -609,8 +647,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 = bl.x; + vb[15].y = bl.y; vb[16].x = layer->src.tl.x; vb[16].y = layer->src.br.y; vb[17] = layer->zw; @@ -964,6 +1002,16 @@ vl_compositor_set_rgba_layer(struct vl_compositor_state *s, } void +vl_compositor_set_layer_rotation(struct vl_compositor_state *s, + unsigned layer, + enum vl_compositor_rotation rotate) +{ + assert(s); + assert(layer < VL_COMPOSITOR_MAX_LAYERS); + s->layers[layer].rotate = rotate; +} + +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..934b634 100644 --- a/src/gallium/auxiliary/vl/vl_compositor.h +++ b/src/gallium/auxiliary/vl/vl_compositor.h @@ -53,6 +53,15 @@ enum vl_compositor_deinterlace VL_COMPOSITOR_BOB_BOTTOM }; +/* clockwise degree */ +enum vl_compositor_rotation +{ + VL_COMPOSITOR_ROTATE_0, + VL_COMPOSITOR_ROTATE_90, + VL_COMPOSITOR_ROTATE_180, + VL_COMPOSITOR_ROTATE_270 +}; + struct vl_compositor_layer { bool clearing; @@ -70,6 +79,7 @@ struct vl_compositor_layer } src, dst; struct vertex2f zw; struct vertex4f colors[4]; + enum vl_compositor_rotation rotate; }; struct vl_compositor_state @@ -216,6 +226,14 @@ vl_compositor_set_rgba_layer(struct vl_compositor_state *state, struct u_rect *dst_rect, struct vertex4f *colors); +/** + * set the layer rotation + */ +void +vl_compositor_set_layer_rotation(struct vl_compositor_state *state, + unsigned layer, + enum vl_compositor_rotation rotate); + /*@}*/ /** -- 1.9.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev