On 02/15/2013 02:10 PM, Holger Kaelberer wrote:
Thinking about a good value for this background color, I wonder whether it could not be bound to, i.e. derived from VADisplayAttribBackgroundColor which is already mapped to VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR in vdpau-driver.
The attached patch implements this approach. Thanks, regards, Holger
>From f62c0cafd84ccc4e1dfbb1f30c6c788ee208cd6a Mon Sep 17 00:00:00 2001 From: Holger Kaelberer <[email protected]> Date: Fri, 15 Feb 2013 14:28:22 +0100 Subject: [PATCH] Initialize surface background from VADisplayAttribBackgroundColor This initializes the background color of vdpau surfaces from VADisplayAttribBackgroundColor, if set. The default value is changed to (almost) black because the default greenish value of libvdpau ({ 0.462745, 0.725490, 0.003922}) leads to ugly green flickering during startup after shutdown. Note: Plain black or white should not be set as background, because it is commonly used and causes video to bleed through into other windows using this color. --- src/vdpau_video_x11.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/vdpau_video_x11.c b/src/vdpau_video_x11.c index 8171549..ea9c147 100644 --- a/src/vdpau_video_x11.c +++ b/src/vdpau_video_x11.c @@ -206,6 +206,10 @@ output_surface_create( if (drawable != None) { VdpStatus vdp_status; + /* note: choose a rare color close to plain black as default background + * 0/0/0 causes the window to bleed through black in other windows.*/ + VdpColor vdp_bg = {0.003922f, 0.007843f, 0.003922f, 0}; + unsigned int i; vdp_status = vdpau_presentation_queue_target_create_x11( driver_data, driver_data->vdp_device, @@ -227,6 +231,23 @@ output_surface_create( output_surface_destroy(driver_data, obj_output); return NULL; } + + for (i = 0; i < driver_data->va_display_attrs_count; i++) { + VADisplayAttribute * const attr = &driver_data->va_display_attrs[i]; + if (attr->type != VADisplayAttribBackgroundColor) + continue; + + vdp_bg.red = ((attr->value >> 16) & 0xff) / 255.0f; + vdp_bg.green = ((attr->value >> 8) & 0xff) / 255.0f; + vdp_bg.blue = (attr->value & 0xff)/ 255.0f; + vdp_bg.alpha = 1.0f; + } + + vdp_status = vdpau_presentation_queue_set_background_color( + driver_data, + obj_output->vdp_flip_queue, + &vdp_bg + ); } return obj_output; } -- 1.7.9.5
_______________________________________________ Libva mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libva
