[vlc-devel] commit: * modules/video_output/x11/*: manually paint the xv colour key if XV_AUTOPAINT_COLORKEY isn't supported. (Gildas Bazin )

git version control git at videolan.org
Thu Mar 6 00:24:01 CET 2008


vlc | branch: master | Gildas Bazin <gbazin at videolan.org> | Mon Mar  3 20:58:17 2008 +0000| [55da14ec974e67d4197a8547a2a26ed540feded9]

* modules/video_output/x11/*: manually paint the xv colour key if XV_AUTOPAINT_COLORKEY isn't supported.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=55da14ec974e67d4197a8547a2a26ed540feded9
---

 modules/video_output/x11/xcommon.c |   42 ++++++++++++++++++++++++++++++------
 modules/video_output/x11/xcommon.h |    4 +-
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/modules/video_output/x11/xcommon.c b/modules/video_output/x11/xcommon.c
index 7fafacd..60e811c 100644
--- a/modules/video_output/x11/xcommon.c
+++ b/modules/video_output/x11/xcommon.c
@@ -1434,6 +1434,22 @@ static int ManageVideo( vout_thread_t *p_vout )
             if( ((XExposeEvent *)&xevent)->count == 0 )
             {
                 /* (if this is the last a collection of expose events...) */
+
+#if defined(MODULE_NAME_IS_xvideo)
+                x11_window_t *p_win = p_vout->p_sys->p_win;
+
+                /* Paint the colour key if needed */
+                if( p_vout->p_sys->b_paint_colourkey &&
+                    xevent.xexpose.window == p_win->video_window )
+                {
+                    XSetForeground( p_vout->p_sys->p_display,
+                                    p_win->gc, p_vout->p_sys->i_colourkey );
+                    XFillRectangle( p_vout->p_sys->p_display,
+                                    p_win->video_window, p_win->gc, 0, 0,
+                                    p_win->i_width, p_win->i_height );
+                }
+#endif 
+
 #if 0
                 if( p_vout->p_libvlc->p_input_bank->pp_input[0] != NULL )
                 {
@@ -1622,8 +1638,9 @@ static int CreateWindow( vout_thread_t *p_vout, x11_window_t *p_win )
 
     if( !p_vout->b_fullscreen )
     {
-        p_win->owner_window = (Window)vout_RequestWindow( p_vout, &p_win->i_x, &p_win->i_y,
-                                        &p_win->i_width, &p_win->i_height );
+        p_win->owner_window = (Window)
+            vout_RequestWindow( p_vout, &p_win->i_x, &p_win->i_y,
+                                &p_win->i_width, &p_win->i_height );
 
         xsize_hints.base_width  = xsize_hints.width = p_win->i_width;
         xsize_hints.base_height = xsize_hints.height = p_win->i_height;
@@ -2551,6 +2568,7 @@ static int XVideoGetPort( vout_thread_t *p_vout,
         {
             XvAttribute     *p_attr;
             int             i_attr, i_num_attributes;
+            Atom            autopaint = None, colorkey = None;
 
             /* If this is not the format we want, or at least a
              * similar one, forget it */
@@ -2587,7 +2605,8 @@ static int XVideoGetPort( vout_thread_t *p_vout,
                      ( p_formats[ i_format ].format == XvPacked ) ?
                          "packed" : "planar" );
 
-            /* Make sure XV_AUTOPAINT_COLORKEY is set */
+            /* Use XV_AUTOPAINT_COLORKEY if supported, otherwise we will
+             * manually paint the colour key */
             p_attr = XvQueryPortAttributes( p_vout->p_sys->p_display,
                                             i_selected_port,
                                             &i_num_attributes );
@@ -2596,14 +2615,23 @@ static int XVideoGetPort( vout_thread_t *p_vout,
             {
                 if( !strcmp( p_attr[i_attr].name, "XV_AUTOPAINT_COLORKEY" ) )
                 {
-                    const Atom autopaint =
-                        XInternAtom( p_vout->p_sys->p_display,
-                                     "XV_AUTOPAINT_COLORKEY", False );
+                    autopaint = XInternAtom( p_vout->p_sys->p_display,
+                                             "XV_AUTOPAINT_COLORKEY", False );
                     XvSetPortAttribute( p_vout->p_sys->p_display,
                                         i_selected_port, autopaint, 1 );
-                    break;
+                }
+                if( !strcmp( p_attr[i_attr].name, "XV_COLORKEY" ) )
+                {
+                    /* Find out the default colour key */
+                    colorkey = XInternAtom( p_vout->p_sys->p_display,
+                                            "XV_COLORKEY", False );
+                    XvGetPortAttribute( p_vout->p_sys->p_display,
+                                        i_selected_port, colorkey,
+                                        &p_vout->p_sys->i_colourkey );
                 }
             }
+            p_vout->p_sys->b_paint_colourkey =
+                autopaint == None && colorkey != None;
 
             if( p_attr != NULL )
             {
diff --git a/modules/video_output/x11/xcommon.h b/modules/video_output/x11/xcommon.h
index 17833ab..b1e9bd2 100644
--- a/modules/video_output/x11/xcommon.h
+++ b/modules/video_output/x11/xcommon.h
@@ -230,6 +230,8 @@ struct vout_sys_t
 
 #if defined(MODULE_NAME_IS_xvideo) || defined(MODULE_NAME_IS_xvmc)
     int                 i_xvport;
+    vlc_bool_t          b_paint_colourkey;
+    int                 i_colourkey;
 #else
     Colormap            colormap;               /* colormap used (8bpp only) */
 
@@ -336,8 +338,6 @@ struct vout_sys_t
     osso_context_t      *p_octx;
     int                 i_backlight_on_counter;
 #endif
-
- 
 };
 
 /*****************************************************************************




More information about the vlc-devel mailing list