]> git.sesse.net Git - vlc/blobdiff - modules/video_output/opengl.c
Removed non converted omapfb video output module.
[vlc] / modules / video_output / opengl.c
index 1a751547fb9a5473c9f248c1ed971203657dd495..874eb0d7f1814e9550c10d1d241fc457d126e3a4 100644 (file)
@@ -63,7 +63,7 @@ vlc_module_begin ()
     set_subcategory( SUBCAT_VIDEO_VOUT )
     set_description( N_("OpenGL video output") )
 #ifdef __APPLE__
-    set_capability( "video output", 200 )
+    set_capability( "video output", 400 )
 #else
     set_capability( "video output", 20 )
 #endif
@@ -129,10 +129,8 @@ static int CreateVout( vlc_object_t *p_this )
                 VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
 
     /* Forward events from the opengl provider */
-    var_Create( p_sys->p_vout, "mouse-x", VLC_VAR_INTEGER );
-    var_Create( p_sys->p_vout, "mouse-y", VLC_VAR_INTEGER );
-    var_Create( p_sys->p_vout, "mouse-moved", VLC_VAR_BOOL );
-    var_Create( p_sys->p_vout, "mouse-clicked", VLC_VAR_BOOL );
+    var_Create( p_sys->p_vout, "mouse-moved", VLC_VAR_COORDS );
+    var_Create( p_sys->p_vout, "mouse-clicked", VLC_VAR_COORDS );
     var_Create( p_sys->p_vout, "mouse-button-down", VLC_VAR_INTEGER );
     var_Create( p_sys->p_vout, "video-on-top",
                 VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
@@ -141,8 +139,6 @@ static int CreateVout( vlc_object_t *p_this )
     var_Create( p_sys->p_vout, "scale",
                 VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
 
-    var_AddCallback( p_sys->p_vout, "mouse-x", SendEvents, p_vout );
-    var_AddCallback( p_sys->p_vout, "mouse-y", SendEvents, p_vout );
     var_AddCallback( p_sys->p_vout, "mouse-moved", SendEvents, p_vout );
     var_AddCallback( p_sys->p_vout, "mouse-clicked", SendEvents, p_vout );
     var_AddCallback( p_sys->p_vout, "mouse-button-down", SendEvents, p_vout );
@@ -157,7 +153,6 @@ static int CreateVout( vlc_object_t *p_this )
     if( p_sys->p_vout->p_module == NULL )
     {
         msg_Warn( p_vout, "No OpenGL provider found" );
-        vlc_object_detach( p_sys->p_vout );
         /* no need for var_DelCallback here :-) */
         vlc_object_release( p_sys->p_vout );
         free( p_sys );
@@ -210,11 +205,13 @@ static int Init( vout_thread_t *p_vout )
     p_sys->gl.sys = p_sys->p_vout;
 
     video_format_t fmt;
+    video_format_Init( &fmt, 0 );
     video_format_Setup( &fmt,
                         p_vout->render.i_chroma,
                         p_vout->render.i_width,
                         p_vout->render.i_height,
-                        p_vout->render.i_aspect );
+                        p_vout->render.i_aspect * p_vout->render.i_height,
+                        VOUT_ASPECT_FACTOR      * p_vout->render.i_width );
 
 
     if( vout_display_opengl_Init( &p_sys->vgl, &fmt, &p_sys->gl ) )
@@ -317,13 +314,12 @@ static int Manage( vout_thread_t *p_vout )
         p_vout->fmt_in.i_visible_width;
     p_vout->fmt_out.i_visible_height = p_sys->p_vout->fmt_in.i_visible_height =
         p_vout->fmt_in.i_visible_height;
-    p_vout->fmt_out.i_aspect = p_sys->p_vout->fmt_in.i_aspect =
-        p_vout->fmt_in.i_aspect;
     p_vout->fmt_out.i_sar_num = p_sys->p_vout->fmt_in.i_sar_num =
         p_vout->fmt_in.i_sar_num;
     p_vout->fmt_out.i_sar_den = p_sys->p_vout->fmt_in.i_sar_den =
         p_vout->fmt_in.i_sar_den;
-    p_vout->output.i_aspect = p_vout->fmt_in.i_aspect;
+    p_vout->output.i_aspect = (int64_t)p_vout->fmt_in.i_sar_num * p_vout->fmt_in.i_width * VOUT_ASPECT_FACTOR /
+                              p_vout->fmt_in.i_sar_den / p_vout->fmt_in.i_height;
 
     p_sys->p_vout->i_changes = p_vout->i_changes;
     i_ret = p_sys->p_vout->pf_manage( p_sys->p_vout );
@@ -343,7 +339,7 @@ static int Manage( vout_thread_t *p_vout )
     if (p_sys->p_vout->i_alignment != p_vout->i_alignment)
     {
         p_vout->i_changes |= VOUT_CROP_CHANGE;        //to force change
-        p_sys->p_vout->i_alignment = p_vout->i_alignment;    
+        p_sys->p_vout->i_alignment = p_vout->i_alignment;
     }
 
     /* forward signal that autoscale toggle has changed */
@@ -373,17 +369,40 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
 {
     vout_sys_t *p_sys = p_vout->p_sys;
 
+    picture_t *p_next = p_sys->p_current;
+
+    if( VLCGL_TEXTURE_COUNT > 1 )
+    {
+        /* Get the next picture to display */
+        p_next = picture_pool_Get( p_sys->p_pool );
+        assert( p_next );
+    }
+
     if( p_sys->p_current )
     {
         assert( p_sys->p_current->p[0].p_pixels == p_pic->p[0].p_pixels );
 
+        /* Make sure we have the prepare after the picture_pool_Get,
+         * because picture_pool_Get() will bind the new picture texture,
+         * and vout_display_opengl_Prepare() bind the current rendered picture
+         * texture.
+         * DisplayVideo() will effectively use the last binded texture. */
+
         vout_display_opengl_Prepare( &p_sys->vgl, p_sys->p_current );
-        picture_Release( p_sys->p_current );
     }
 
-    p_sys->p_current = picture_pool_Get( p_sys->p_pool );
-    if( p_sys->p_current )
+    if( p_sys->p_current != p_next ) {
+        if( p_sys->p_current )
+            picture_Release( p_sys->p_current );
+
+        /* Swap the picture texture on opengl vout side. */
+        p_sys->p_current = p_next;
+
+        /* Now, switch the only picture that is being used
+         * to render in the backend to point to our "next"
+         * picture texture */
         p_pic->p[0].p_pixels = p_sys->p_current->p[0].p_pixels;
+    }
 
     VLC_UNUSED( p_pic );
 }