[Mesa-dev] [PATCH 24/25] st/vdpau: add support for per vertex colors
Christian König
deathsimple at vodafone.de
Mon Feb 27 08:25:52 PST 2012
Signed-off-by: Christian König <deathsimple at vodafone.de>
---
src/gallium/state_trackers/vdpau/output.c | 30 +++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
index 11a2c20..cf94fe7 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -570,6 +570,28 @@ BlenderToPipe(struct pipe_context *context,
return context->create_blend_state(context, &blend);
}
+static struct vertex4f *
+ColorsToPipe(VdpColor const *colors, uint32_t flags, struct vertex4f result[4])
+{
+ unsigned i;
+ struct vertex4f *dst = result;
+
+ if (!colors)
+ return NULL;
+
+ for (i = 0; i < 4; ++i) {
+ dst->x = colors->red;
+ dst->y = colors->green;
+ dst->z = colors->blue;
+ dst->w = colors->alpha;
+
+ ++dst;
+ if (flags & VDP_OUTPUT_SURFACE_RENDER_COLOR_PER_VERTEX)
+ ++colors;
+ }
+ return result;
+}
+
/**
* Composite a sub-rectangle of a VdpOutputSurface into a sub-rectangle of
* another VdpOutputSurface; Output Surface object VdpOutputSurface.
@@ -592,6 +614,7 @@ vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface,
struct u_rect src_rect, dst_rect;
+ struct vertex4f vlcolors[4];
void *blend;
dst_vlsurface = vlGetDataHTAB(destination_surface);
@@ -616,7 +639,8 @@ vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface,
vl_compositor_clear_layers(cstate);
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);
+ RectToPipe(source_rect, &src_rect), NULL,
+ ColorsToPipe(colors, flags, vlcolors));
vl_compositor_set_dst_area(cstate, RectToPipe(destination_rect, &dst_rect));
vl_compositor_render(cstate, compositor, dst_vlsurface->surface, NULL);
@@ -647,6 +671,7 @@ vlVdpOutputSurfaceRenderBitmapSurface(VdpOutputSurface destination_surface,
struct u_rect src_rect, dst_rect;
+ struct vertex4f vlcolors[4];
void *blend;
dst_vlsurface = vlGetDataHTAB(destination_surface);
@@ -671,7 +696,8 @@ vlVdpOutputSurfaceRenderBitmapSurface(VdpOutputSurface destination_surface,
vl_compositor_clear_layers(cstate);
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);
+ RectToPipe(source_rect, &src_rect), NULL,
+ ColorsToPipe(colors, flags, vlcolors));
vl_compositor_set_dst_area(cstate, RectToPipe(destination_rect, &dst_rect));
vl_compositor_render(cstate, compositor, dst_vlsurface->surface, NULL);
--
1.7.5.4
More information about the mesa-dev
mailing list