Commit f5d38066 authored by Gildas Bazin's avatar Gildas Bazin

* mozilla/vlcshell.cpp, modules/video_output/directx/*: round of fixes for the win32 mozilla plugin.
parent 2c54b61a
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout.c: Windows DirectX video output display method * vout.c: Windows DirectX video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: directx.c,v 1.24 2003/11/19 23:44:35 gbazin Exp $ * $Id: directx.c,v 1.25 2003/11/20 17:48:44 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -162,7 +162,6 @@ static int OpenVideo( vlc_object_t *p_this ) ...@@ -162,7 +162,6 @@ static int OpenVideo( vlc_object_t *p_this )
p_vout->p_sys->hwnd = NULL; p_vout->p_sys->hwnd = NULL;
p_vout->p_sys->hparent = NULL; p_vout->p_sys->hparent = NULL;
p_vout->p_sys->i_changes = 0; p_vout->p_sys->i_changes = 0;
p_vout->p_sys->b_caps_overlay_clipping = 0;
SetRectEmpty( &p_vout->p_sys->rect_display ); SetRectEmpty( &p_vout->p_sys->rect_display );
p_vout->p_sys->b_using_overlay = config_GetInt( p_vout, "overlay" ); p_vout->p_sys->b_using_overlay = config_GetInt( p_vout, "overlay" );
p_vout->p_sys->b_use_sysmem = config_GetInt( p_vout, "directx-use-sysmem"); p_vout->p_sys->b_use_sysmem = config_GetInt( p_vout, "directx-use-sysmem");
...@@ -959,9 +958,7 @@ int DirectXUpdateOverlay( vout_thread_t *p_vout ) ...@@ -959,9 +958,7 @@ int DirectXUpdateOverlay( vout_thread_t *p_vout )
ddofx.dckDestColorkey.dwColorSpaceLowValue = p_vout->p_sys->i_colorkey; ddofx.dckDestColorkey.dwColorSpaceLowValue = p_vout->p_sys->i_colorkey;
ddofx.dckDestColorkey.dwColorSpaceHighValue = p_vout->p_sys->i_colorkey; ddofx.dckDestColorkey.dwColorSpaceHighValue = p_vout->p_sys->i_colorkey;
dwFlags = DDOVER_SHOW; dwFlags = DDOVER_SHOW | DDOVER_KEYDESTOVERRIDE;
if( !p_vout->p_sys->b_caps_overlay_clipping )
dwFlags |= DDOVER_KEYDESTOVERRIDE;
dxresult = IDirectDrawSurface2_UpdateOverlay( dxresult = IDirectDrawSurface2_UpdateOverlay(
p_vout->p_sys->p_current_surface, p_vout->p_sys->p_current_surface,
...@@ -1448,7 +1445,7 @@ static void DirectXGetDDrawCaps( vout_thread_t *p_vout ) ...@@ -1448,7 +1445,7 @@ static void DirectXGetDDrawCaps( vout_thread_t *p_vout )
} }
else else
{ {
BOOL bHasOverlay, bHasOverlayFourCC, bCanClipOverlay, BOOL bHasOverlay, bHasOverlayFourCC, bCanDeinterlace,
bHasColorKey, bCanStretch, bCanBltFourcc; bHasColorKey, bCanStretch, bCanBltFourcc;
/* Determine if the hardware supports overlay surfaces */ /* Determine if the hardware supports overlay surfaces */
...@@ -1457,8 +1454,8 @@ static void DirectXGetDDrawCaps( vout_thread_t *p_vout ) ...@@ -1457,8 +1454,8 @@ static void DirectXGetDDrawCaps( vout_thread_t *p_vout )
/* Determine if the hardware supports overlay surfaces */ /* Determine if the hardware supports overlay surfaces */
bHasOverlayFourCC = ((ddcaps.dwCaps & DDCAPS_OVERLAYFOURCC) == bHasOverlayFourCC = ((ddcaps.dwCaps & DDCAPS_OVERLAYFOURCC) ==
DDCAPS_OVERLAYFOURCC) ? TRUE : FALSE; DDCAPS_OVERLAYFOURCC) ? TRUE : FALSE;
/* Determine if the hardware supports overlay surfaces */ /* Determine if the hardware supports overlay deinterlacing */
bCanClipOverlay = ((ddcaps.dwCaps & DDCAPS_OVERLAYCANTCLIP) == bCanDeinterlace = ((ddcaps.dwCaps & DDCAPS2_CANFLIPODDEVEN) ==
0 ) ? TRUE : FALSE; 0 ) ? TRUE : FALSE;
/* Determine if the hardware supports colorkeying */ /* Determine if the hardware supports colorkeying */
bHasColorKey = ((ddcaps.dwCaps & DDCAPS_COLORKEY) == bHasColorKey = ((ddcaps.dwCaps & DDCAPS_COLORKEY) ==
...@@ -1471,15 +1468,11 @@ static void DirectXGetDDrawCaps( vout_thread_t *p_vout ) ...@@ -1471,15 +1468,11 @@ static void DirectXGetDDrawCaps( vout_thread_t *p_vout )
DDCAPS_BLTFOURCC) ? TRUE : FALSE; DDCAPS_BLTFOURCC) ? TRUE : FALSE;
msg_Dbg( p_vout, "DirectDraw Capabilities: overlay=%i yuvoverlay=%i " msg_Dbg( p_vout, "DirectDraw Capabilities: overlay=%i yuvoverlay=%i "
"can_clip_overlay=%i colorkey=%i stretch=%i " "can_deinterlace_overlay=%i colorkey=%i stretch=%i "
"bltfourcc=%i", "bltfourcc=%i",
bHasOverlay, bHasOverlayFourCC, bCanClipOverlay, bHasOverlay, bHasOverlayFourCC, bCanDeinterlace,
bHasColorKey, bCanStretch, bCanBltFourcc ); bHasColorKey, bCanStretch, bCanBltFourcc );
/* Overlay clipping support is interesting for us as it means we can
* get rid of the colorkey alltogether */
p_vout->p_sys->b_caps_overlay_clipping = bCanClipOverlay;
/* Don't ask for troubles */ /* Don't ask for troubles */
if( !bCanBltFourcc ) p_vout->p_sys->b_hw_yuv = FALSE; if( !bCanBltFourcc ) p_vout->p_sys->b_hw_yuv = FALSE;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* events.c: Windows DirectX video output events handler * events.c: Windows DirectX video output events handler
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: events.c,v 1.29 2003/11/19 23:44:35 gbazin Exp $ * $Id: events.c,v 1.30 2003/11/20 17:48:44 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -50,8 +50,8 @@ ...@@ -50,8 +50,8 @@
*****************************************************************************/ *****************************************************************************/
static int DirectXCreateWindow( vout_thread_t *p_vout ); static int DirectXCreateWindow( vout_thread_t *p_vout );
static void DirectXCloseWindow ( vout_thread_t *p_vout ); static void DirectXCloseWindow ( vout_thread_t *p_vout );
static long FAR PASCAL DirectXEventProc ( HWND hwnd, UINT message, static long FAR PASCAL DirectXEventProc( HWND, UINT, WPARAM, LPARAM );
WPARAM wParam, LPARAM lParam ); static long FAR PASCAL DirectXVideoEventProc( HWND, UINT, WPARAM, LPARAM );
static void DirectXPopupMenu( event_thread_t *p_event, vlc_bool_t b_open ) static void DirectXPopupMenu( event_thread_t *p_event, vlc_bool_t b_open )
{ {
...@@ -106,7 +106,13 @@ void DirectXEventThread( event_thread_t *p_event ) ...@@ -106,7 +106,13 @@ void DirectXEventThread( event_thread_t *p_event )
if( p_event->b_die ) if( p_event->b_die )
break; break;
if( p_event->p_vout->p_sys->hparent ) msleep( INTF_IDLE_SLEEP ); if( p_event->p_vout->p_sys->hparent )
{
/* Parent window was created in another thread so we can't
* access the window messages. */
msleep( INTF_IDLE_SLEEP );
continue;
}
switch( msg.message ) switch( msg.message )
{ {
...@@ -311,8 +317,7 @@ static int DirectXCreateWindow( vout_thread_t *p_vout ) ...@@ -311,8 +317,7 @@ static int DirectXCreateWindow( vout_thread_t *p_vout )
GWL_WNDPROC, (LONG)DirectXEventProc ); GWL_WNDPROC, (LONG)DirectXEventProc );
/* Blam! Erase everything that might have been there. */ /* Blam! Erase everything that might have been there. */
RedrawWindow( p_vout->p_sys->hwnd, NULL, NULL, InvalidateRect( p_vout->p_sys->hwnd, NULL, TRUE );
RDW_INVALIDATE | RDW_ERASE );
} }
else else
{ {
...@@ -424,9 +429,13 @@ static void DirectXCloseWindow( vout_thread_t *p_vout ) ...@@ -424,9 +429,13 @@ static void DirectXCloseWindow( vout_thread_t *p_vout )
} }
else if( p_vout->p_sys->hparent ) else if( p_vout->p_sys->hparent )
{ {
/* Get rid of the video sub-window */
PostMessage( p_vout->p_sys->hvideownd, WM_VLC_DESTROY_VIDEO_WIN, 0, 0);
/* We don't want our windowproc to be called anymore */ /* We don't want our windowproc to be called anymore */
SetWindowLong( p_vout->p_sys->hwnd, SetWindowLong( p_vout->p_sys->hwnd,
GWL_WNDPROC, (LONG)p_vout->p_sys->pf_wndproc ); GWL_WNDPROC, (LONG)p_vout->p_sys->pf_wndproc );
SetWindowLong( p_vout->p_sys->hwnd, GWL_USERDATA, (LONG)NULL );
/* Blam! Erase everything that might have been there. */ /* Blam! Erase everything that might have been there. */
InvalidateRect( p_vout->p_sys->hwnd, NULL, TRUE ); InvalidateRect( p_vout->p_sys->hwnd, NULL, TRUE );
...@@ -587,6 +596,13 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message, ...@@ -587,6 +596,13 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
p_vout = (vout_thread_t *)GetWindowLong( hwnd, GWL_USERDATA ); p_vout = (vout_thread_t *)GetWindowLong( hwnd, GWL_USERDATA );
} }
if( !p_vout )
{
/* Hmmm mozilla does manage somehow to save the pointer to our
* windowproc and still calls it after the vout has been closed. */
return DefWindowProc(hwnd, message, wParam, lParam);
}
switch( message ) switch( message )
{ {
...@@ -653,12 +669,12 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message, ...@@ -653,12 +669,12 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
if( !p_vout->p_sys->hvideownd ) if( !p_vout->p_sys->hvideownd )
{ {
msg_Warn( p_vout, "Can create video sub-window" ); msg_Warn( p_vout, "Can't create video sub-window" );
} }
else else
{ {
SetWindowLong( p_vout->p_sys->hvideownd, SetWindowLong( p_vout->p_sys->hvideownd,
GWL_WNDPROC, (LONG)DefWindowProc ); GWL_WNDPROC, (LONG)DirectXVideoEventProc );
} }
break; break;
...@@ -669,6 +685,19 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message, ...@@ -669,6 +685,19 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
return DefWindowProc(hwnd, message, wParam, lParam); return DefWindowProc(hwnd, message, wParam, lParam);
} }
static long FAR PASCAL DirectXVideoEventProc( HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_VLC_DESTROY_VIDEO_WIN:
/* Destroy video sub-window */
DestroyWindow( hwnd );
break;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
static struct static struct
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout.h: Windows DirectX video output header file * vout.h: Windows DirectX video output header file
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vout.h,v 1.8 2003/11/19 23:44:35 gbazin Exp $ * $Id: vout.h,v 1.9 2003/11/20 17:48:44 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -119,4 +119,5 @@ void DirectXUpdateRects ( vout_thread_t *p_vout, vlc_bool_t b_force ); ...@@ -119,4 +119,5 @@ void DirectXUpdateRects ( vout_thread_t *p_vout, vlc_bool_t b_force );
*****************************************************************************/ *****************************************************************************/
#define WM_VLC_HIDE_MOUSE WM_APP #define WM_VLC_HIDE_MOUSE WM_APP
#define WM_VLC_CREATE_VIDEO_WIN WM_APP + 1 #define WM_VLC_CREATE_VIDEO_WIN WM_APP + 1
#define WM_VLC_DESTROY_VIDEO_WIN WM_APP + 2
#define IDM_TOGGLE_ON_TOP WM_USER + 1 #define IDM_TOGGLE_ON_TOP WM_USER + 1
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vlcshell.cpp: a VLC plugin for Mozilla * vlcshell.cpp: a VLC plugin for Mozilla
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: vlcshell.cpp,v 1.26 2003/10/23 17:04:40 sam Exp $ * $Id: vlcshell.cpp,v 1.27 2003/11/20 17:48:44 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -104,27 +104,10 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event ); ...@@ -104,27 +104,10 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event );
# define VOUT_PLUGINS "directx,wingdi,dummy" # define VOUT_PLUGINS "directx,wingdi,dummy"
# define AOUT_PLUGINS "directx,waveout,dummy" # define AOUT_PLUGINS "directx,waveout,dummy"
HINSTANCE g_hDllInstance = NULL; #if defined(XP_WIN) && !USE_LIBVLC
BOOL WINAPI DllMain( HINSTANCE hinstDLL, /* handle of DLL module */
DWORD fdwReason, /* reason for calling the function */
LPVOID lpvReserved )
{
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
g_hDllInstance = hinstDLL;
break;
case DLL_THREAD_ATTACH:
case DLL_PROCESS_DETACH:
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
LRESULT CALLBACK Manage( HWND, UINT, WPARAM, LPARAM ); LRESULT CALLBACK Manage( HWND, UINT, WPARAM, LPARAM );
#endif #endif
#endif
/****************************************************************************** /******************************************************************************
* UNIX-only API calls * UNIX-only API calls
...@@ -555,8 +538,10 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -555,8 +538,10 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
/* Window was destroyed. Invalidate everything. */ /* Window was destroyed. Invalidate everything. */
if( p_plugin->p_npwin ) if( p_plugin->p_npwin )
{ {
#if !USE_LIBVLC
SetWindowLong( p_plugin->p_hwnd, GWL_WNDPROC, SetWindowLong( p_plugin->p_hwnd, GWL_WNDPROC,
(LONG)p_plugin->pf_wndproc ); (LONG)p_plugin->pf_wndproc );
#endif
p_plugin->pf_wndproc = NULL; p_plugin->pf_wndproc = NULL;
p_plugin->p_hwnd = NULL; p_plugin->p_hwnd = NULL;
} }
...@@ -571,24 +556,31 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -571,24 +556,31 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
{ {
/* Same window, but something may have changed. First we /* Same window, but something may have changed. First we
* update the plugin structure, then we redraw the window */ * update the plugin structure, then we redraw the window */
InvalidateRect( p_plugin->p_hwnd, NULL, TRUE );
p_plugin->i_width = window->width; p_plugin->i_width = window->width;
p_plugin->i_height = window->height; p_plugin->i_height = window->height;
p_plugin->p_npwin = window; p_plugin->p_npwin = window;
#if !USE_LIBVLC
InvalidateRect( p_plugin->p_hwnd, NULL, TRUE );
UpdateWindow( p_plugin->p_hwnd ); UpdateWindow( p_plugin->p_hwnd );
#endif
return NPERR_NO_ERROR; return NPERR_NO_ERROR;
} }
/* Window has changed. Destroy the one we have, and go /* Window has changed. Destroy the one we have, and go
* on as if it was a real initialization. */ * on as if it was a real initialization. */
#if !USE_LIBVLC
SetWindowLong( p_plugin->p_hwnd, GWL_WNDPROC, SetWindowLong( p_plugin->p_hwnd, GWL_WNDPROC,
(LONG)p_plugin->pf_wndproc ); (LONG)p_plugin->pf_wndproc );
#endif
p_plugin->pf_wndproc = NULL; p_plugin->pf_wndproc = NULL;
p_plugin->p_hwnd = NULL; p_plugin->p_hwnd = NULL;
} }
#if !USE_LIBVLC
p_plugin->pf_wndproc = (WNDPROC)SetWindowLong( (HWND)window->window, p_plugin->pf_wndproc = (WNDPROC)SetWindowLong( (HWND)window->window,
GWL_WNDPROC, (LONG)Manage ); GWL_WNDPROC, (LONG)Manage );
#endif
p_plugin->p_hwnd = (HWND)window->window; p_plugin->p_hwnd = (HWND)window->window;
SetProp( p_plugin->p_hwnd, "w00t", (HANDLE)p_plugin ); SetProp( p_plugin->p_hwnd, "w00t", (HANDLE)p_plugin );
InvalidateRect( p_plugin->p_hwnd, NULL, TRUE ); InvalidateRect( p_plugin->p_hwnd, NULL, TRUE );
...@@ -810,14 +802,13 @@ void NPP_Print( NPP instance, NPPrint* printInfo ) ...@@ -810,14 +802,13 @@ void NPP_Print( NPP instance, NPPrint* printInfo )
/****************************************************************************** /******************************************************************************
* Windows-only methods * Windows-only methods
*****************************************************************************/ *****************************************************************************/
#ifdef XP_WIN #if defined(XP_WIN) && !USE_LIBVLC
LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar ) LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar )
{ {
VlcPlugin* p_plugin = (VlcPlugin*) GetProp( p_hwnd, "w00t" ); VlcPlugin* p_plugin = (VlcPlugin*) GetProp( p_hwnd, "w00t" );
switch( i_msg ) switch( i_msg )
{ {
#if !USE_LIBVLC
case WM_PAINT: case WM_PAINT:
{ {
PAINTSTRUCT paintstruct; PAINTSTRUCT paintstruct;
...@@ -834,7 +825,6 @@ LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar ) ...@@ -834,7 +825,6 @@ LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar )
EndPaint( p_hwnd, &paintstruct ); EndPaint( p_hwnd, &paintstruct );
break; break;
} }
#endif
default: default:
p_plugin->pf_wndproc( p_hwnd, i_msg, wpar, lpar ); p_plugin->pf_wndproc( p_hwnd, i_msg, wpar, lpar );
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment