[g3dvl] make clear color configureable
authorChristian König <deathsimple@vodafone.de>
Wed, 27 Apr 2011 14:50:34 +0000 (16:50 +0200)
committerChristian König <deathsimple@vodafone.de>
Wed, 27 Apr 2011 14:50:34 +0000 (16:50 +0200)
src/gallium/auxiliary/vl/vl_compositor.c
src/gallium/auxiliary/vl/vl_compositor.h
src/gallium/include/pipe/p_video_context.h

index c13e69d53d1628cc479da9fafbd1101a671e2fca..cc257e5614f0353df5124f2e76e1fd4556a254e3 100644 (file)
@@ -511,6 +511,18 @@ vl_compositor_reset_dirty_area(struct pipe_video_compositor *compositor)
    c->dirty_br.x = c->dirty_br.y = 1.0f;
 }
 
+static void
+vl_compositor_set_clear_color(struct pipe_video_compositor *compositor, float color[4])
+{
+   struct vl_compositor *c = (struct vl_compositor *)compositor;
+   unsigned i;
+
+   assert(compositor);
+
+   for (i = 0; i < 4; ++i)
+      c->clear_color[i] = color[i];
+}
+
 static void
 vl_compositor_clear_layers(struct pipe_video_compositor *compositor)
 {
@@ -655,7 +667,6 @@ vl_compositor_render(struct pipe_video_compositor *compositor,
 {
    struct vl_compositor *c = (struct vl_compositor *)compositor;
    struct pipe_scissor_state scissor;
-   float clearcolor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
 
    assert(compositor);
    assert(dst_surface);
@@ -682,7 +693,7 @@ vl_compositor_render(struct pipe_video_compositor *compositor,
    gen_vertex_data(c);
 
    if (c->dirty_tl.x < c->dirty_br.x || c->dirty_tl.y < c->dirty_br.y) {
-      util_clear_render_target(c->pipe, dst_surface, clearcolor, 0, 0, dst_surface->width, dst_surface->height);
+      util_clear_render_target(c->pipe, dst_surface, c->clear_color, 0, 0, dst_surface->width, dst_surface->height);
       c->dirty_tl.x = c->dirty_tl.y = 1.0f;
       c->dirty_br.x = c->dirty_br.y = 0.0f;
    }
@@ -714,6 +725,7 @@ vl_compositor_init(struct pipe_video_context *vpipe, struct pipe_context *pipe)
    compositor->base.destroy = vl_compositor_destroy;
    compositor->base.set_csc_matrix = vl_compositor_set_csc_matrix;
    compositor->base.reset_dirty_area = vl_compositor_reset_dirty_area;
+   compositor->base.set_clear_color = vl_compositor_set_clear_color;
    compositor->base.clear_layers = vl_compositor_clear_layers;
    compositor->base.set_buffer_layer = vl_compositor_set_buffer_layer;
    compositor->base.set_palette_layer = vl_compositor_set_palette_layer;
@@ -739,6 +751,9 @@ vl_compositor_init(struct pipe_video_context *vpipe, struct pipe_context *pipe)
 
    vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_IDENTITY, NULL, true, csc_matrix);
    vl_compositor_set_csc_matrix(&compositor->base, csc_matrix);
+
+   compositor->clear_color[0] = compositor->clear_color[1] = 0.0f;
+   compositor->clear_color[2] = compositor->clear_color[3] = 0.0f;
    vl_compositor_reset_dirty_area(&compositor->base);
 
    return &compositor->base;
index 725dcc15a136d5a61d6d1b25fca4d8699700e16f..33d2a20733dcd2e42834b6305c878d6439c3b637 100644 (file)
@@ -72,6 +72,7 @@ struct vl_compositor
    void *fs_palette;
    void *fs_rgba;
 
+   float clear_color[4];
    struct vertex2f dirty_tl, dirty_br;
 
    unsigned used_layers:VL_COMPOSITOR_MAX_LAYERS;
index 933b377a0c30e693294acb3be0ed3dca2598ac3b..80bbb6e1376089e453cde789987fb1055da21758 100644 (file)
@@ -269,6 +269,11 @@ struct pipe_video_compositor
     */
    void (*reset_dirty_area)(struct pipe_video_compositor *compositor);
 
+   /**
+    * set the clear color
+    */
+   void (*set_clear_color)(struct pipe_video_compositor *compositor, float color[4]);
+
    /**
     * set overlay samplers
     */