- sdl resising rulze, still buggy
authorArnaud de Bossoreille de Ribou <bozo@videolan.org>
Fri, 22 Dec 2000 18:57:35 +0000 (18:57 +0000)
committerArnaud de Bossoreille de Ribou <bozo@videolan.org>
Fri, 22 Dec 2000 18:57:35 +0000 (18:57 +0000)
plugins/sdl/intf_sdl.c
plugins/sdl/vout_sdl.c

index c950ef1..27366d3 100644 (file)
@@ -75,6 +75,7 @@ typedef struct vout_sys_s
 
 /* local prototype */
 void    intf_SDL_Keymap( intf_thread_t * p_intf );
+void intf_SDL_Resize( intf_thread_t * p_intf, int width, int height );
 void intf_SDL_Fullscreen(intf_thread_t * p_intf);
 void intf_SDL_YUVSwitch(intf_thread_t * p_intf);
   
@@ -157,6 +158,8 @@ void intf_SDLManage( intf_thread_t *p_intf )
         i_key = event.key.keysym.sym;                          /* forward it */
 
         switch (event.type) {
+            case SDL_VIDEORESIZE:                      /* Resizing of window */
+                intf_SDL_Resize( p_intf, event.resize.w, event.resize.h );
             case SDL_KEYDOWN:                         /* if a key is pressed */
                 switch(i_key) {
                                                     /* switch to fullscreen  */
@@ -185,16 +188,30 @@ void intf_SDLManage( intf_thread_t *p_intf )
     }
 }
 
+void intf_SDL_Resize( intf_thread_t * p_intf, int width, int height )
+{
+    intf_Msg( "Video display resized (%dx%d)", width, height ); 
+    vlc_mutex_lock( &p_intf->p_vout->change_lock );
+    p_intf->p_vout->i_width = width/* & 0xffffffe*/;
+    p_intf->p_vout->i_height = height;
+    p_intf->p_vout->p_sys->b_reopen_display = 1;
+    p_intf->p_vout->i_changes |= VOUT_YUV_CHANGE;
+    vlc_mutex_unlock( &p_intf->p_vout->change_lock );
+}
+
 void intf_SDL_YUVSwitch(intf_thread_t * p_intf)
 {
+    vlc_mutex_lock( &p_intf->p_vout->change_lock );
     p_intf->p_vout->b_need_render = 1 - p_intf->p_vout->b_need_render;
     intf_DbgMsg( "need render now : '%d'",p_intf->p_vout->b_need_render); 
-
+    vlc_mutex_unlock( &p_intf->p_vout->change_lock );
 }
 void intf_SDL_Fullscreen(intf_thread_t * p_intf)
 {
+    vlc_mutex_lock( &p_intf->p_vout->change_lock );
     p_intf->p_vout->p_sys->b_fullscreen = 1-p_intf->p_vout->p_sys->b_fullscreen;
     p_intf->p_vout->p_sys->b_reopen_display = 1;
+    vlc_mutex_unlock( &p_intf->p_vout->change_lock );
 } 
     
 
@@ -202,7 +219,7 @@ void intf_SDL_Fullscreen(intf_thread_t * p_intf)
 
 void intf_SDL_Keymap(intf_thread_t * p_intf )
 {
-    //p_intf->p_intf_getKey = intf_getKey; 
+    /* p_intf->p_intf_getKey = intf_getKey; */
     intf_AssignKey(p_intf, SDLK_q,      INTF_KEY_QUIT, 0);
     intf_AssignKey(p_intf, SDLK_ESCAPE, INTF_KEY_QUIT, 0);
     /* intf_AssignKey(p_intf,3,'Q'); */
index 00b4b88..1deacc1 100644 (file)
@@ -229,11 +229,11 @@ void vout_SDLDisplay( vout_thread_t *p_vout )
         {
             /* TODO: support for streams other than 4:2:0 */
             /* create the overlay if necessary */
-            if( !p_vout->p_sys->p_overlay )
+            if( p_vout->p_sys->p_overlay == NULL )
             {
                 p_vout->p_sys->p_overlay = SDL_CreateYUVOverlay( 
                                              p_vout->p_rendered_pic->i_width, 
-                                             p_vout->p_rendered_pic->i_height, 
+                                             p_vout->p_rendered_pic->i_height,
                                              SDL_YV12_OVERLAY, 
                                              p_vout->p_sys->p_display
                                            );
@@ -258,12 +258,12 @@ void vout_SDLDisplay( vout_thread_t *p_vout )
                    p_vout->p_rendered_pic->p_u,
                    p_vout->p_sys->p_overlay->h *
                    p_vout->p_sys->p_overlay->pitches[2] / 2);
-       
+
             disp.w = (&p_vout->p_buffer[p_vout->i_buffer_index])->i_pic_width;
             disp.h = (&p_vout->p_buffer[p_vout->i_buffer_index])->i_pic_height;
             disp.x = (p_vout->i_width - disp.w)/2;
             disp.y = (p_vout->i_height - disp.h)/2;
+
             SDL_DisplayYUVOverlay( p_vout->p_sys->p_overlay , &disp );
             SDL_UnlockYUVOverlay(p_vout->p_sys->p_overlay);
         }
@@ -296,7 +296,7 @@ static int SDLOpenDisplay( vout_thread_t *p_vout )
         p_vout->p_sys->p_display = SDL_SetVideoMode(p_vout->i_width, 
             p_vout->i_height, 
             0, 
-            SDL_ANYFORMAT | SDL_HWSURFACE | SDL_DOUBLEBUF );
+            SDL_ANYFORMAT | SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_RESIZABLE );
         SDL_ShowCursor( 1 );
     }
        
@@ -305,6 +305,11 @@ static int SDLOpenDisplay( vout_thread_t *p_vout )
         intf_ErrMsg( "error: can't open DISPLAY default display" );
         return( 1 );
     }
+    intf_DbgMsg( "sdl display size : %dx%d - pitch : %d",
+                 p_vout->p_sys->p_display->w,
+                 p_vout->p_sys->p_display->h,
+                 p_vout->p_sys->p_display->pitch);
+
     SDL_WM_SetCaption( VOUT_TITLE , VOUT_TITLE );
     SDL_EventState(SDL_KEYUP , SDL_IGNORE);    /* ignore keys up */