Commit 599340cf authored by Damien Fouilleul's avatar Damien Fouilleul

- direct3d: new video output module using Direct3D 9 APIs

parent 27c3154a
...@@ -3908,11 +3908,15 @@ then ...@@ -3908,11 +3908,15 @@ then
AC_CHECK_HEADERS(ddraw.h, AC_CHECK_HEADERS(ddraw.h,
[ VLC_ADD_PLUGINS([vout_directx aout_directx]) [ VLC_ADD_PLUGINS([vout_directx aout_directx])
VLC_ADD_LDFLAGS([vout_directx],[-lgdi32]) VLC_ADD_LDFLAGS([vout_directx],[-lgdi32])
dnl to be moved when dependance is removed ])
AC_CHECK_HEADERS(GL/gl.h, [ AC_CHECK_HEADERS(GL/gl.h,
VLC_ADD_PLUGINS([glwin32]) [ VLC_ADD_PLUGINS([glwin32])
VLC_ADD_LDFLAGS([glwin32],[-lopengl32 -lgdi32]) VLC_ADD_LDFLAGS([glwin32],[-lopengl32 -lgdi32])
]) ]) ])
AC_CHECK_HEADERS(d3d9.h,
[ VLC_ADD_PLUGINS([direct3d])
VLC_ADD_LDFLAGS([direct3d],[-ld3d9 -lgdi32])
])
else else
AC_MSG_CHECKING(for directX headers in ${with_directx}) AC_MSG_CHECKING(for directX headers in ${with_directx})
if test -f ${with_directx}/ddraw.h if test -f ${with_directx}/ddraw.h
......
...@@ -4,6 +4,12 @@ SOURCES_vout_directx = \ ...@@ -4,6 +4,12 @@ SOURCES_vout_directx = \
events.c \ events.c \
$(NULL) $(NULL)
SOURCES_direct3d = \
direct3d.c \
vout.h \
events.c \
$(NULL)
SOURCES_glwin32 = \ SOURCES_glwin32 = \
glwin32.c \ glwin32.c \
vout.h \ vout.h \
......
This diff is collapsed.
...@@ -57,6 +57,19 @@ ...@@ -57,6 +57,19 @@
#include "vout.h" #include "vout.h"
/*****************************************************************************
* picture_sys_t: direct buffer method descriptor
*****************************************************************************
* This structure is part of the picture descriptor, it describes the
* DirectX specific properties of a direct buffer.
*****************************************************************************/
struct picture_sys_t
{
LPDIRECTDRAWSURFACE2 p_surface;
LPDIRECTDRAWSURFACE2 p_front_surface;
DDSURFACEDESC ddsd;
};
/***************************************************************************** /*****************************************************************************
* DirectDraw GUIDs. * DirectDraw GUIDs.
* Defining them here allows us to get rid of the dxguid library during * Defining them here allows us to get rid of the dxguid library during
...@@ -908,7 +921,7 @@ BOOL WINAPI DirectXEnumCallback( GUID* p_guid, LPTSTR psz_desc, ...@@ -908,7 +921,7 @@ BOOL WINAPI DirectXEnumCallback( GUID* p_guid, LPTSTR psz_desc,
rect.left = monitor_info.rcWork.left; rect.left = monitor_info.rcWork.left;
rect.top = monitor_info.rcWork.top; rect.top = monitor_info.rcWork.top;
msg_Dbg( p_vout, "DirectXEnumCallback: setting window " msg_Dbg( p_vout, "DirectXEnumCallback: setting window "
"position to %d,%d", rect.left, rect.top ); "position to %ld,%ld", rect.left, rect.top );
SetWindowPos( p_vout->p_sys->hwnd, NULL, SetWindowPos( p_vout->p_sys->hwnd, NULL,
rect.left, rect.top, 0, 0, rect.left, rect.top, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
...@@ -1040,7 +1053,7 @@ static int DirectXInitDDraw( vout_thread_t *p_vout ) ...@@ -1040,7 +1053,7 @@ static int DirectXInitDDraw( vout_thread_t *p_vout )
p_vout->p_sys->rect_display.bottom = GetSystemMetrics(SM_CYSCREEN); p_vout->p_sys->rect_display.bottom = GetSystemMetrics(SM_CYSCREEN);
} }
msg_Dbg( p_vout, "screen dimensions (%ix%i,%ix%i)", msg_Dbg( p_vout, "screen dimensions (%lix%li,%lix%li)",
p_vout->p_sys->rect_display.left, p_vout->p_sys->rect_display.left,
p_vout->p_sys->rect_display.top, p_vout->p_sys->rect_display.top,
p_vout->p_sys->rect_display.right, p_vout->p_sys->rect_display.right,
......
...@@ -44,7 +44,15 @@ ...@@ -44,7 +44,15 @@
#include <windowsx.h> #include <windowsx.h>
#include <shellapi.h> #include <shellapi.h>
#ifdef MODULE_NAME_IS_vout_directx
#include <ddraw.h> #include <ddraw.h>
#endif
#ifdef MODULE_NAME_IS_direct3d
#include <d3d9.h>
#endif
#ifdef MODULE_NAME_IS_glwin32
#include <GL/gl.h>
#endif
#include "vlc_keys.h" #include "vlc_keys.h"
#include "vout.h" #include "vout.h"
...@@ -301,7 +309,11 @@ void E_(DirectXEventThread)( event_thread_t *p_event ) ...@@ -301,7 +309,11 @@ void E_(DirectXEventThread)( event_thread_t *p_event )
#ifdef MODULE_NAME_IS_glwin32 #ifdef MODULE_NAME_IS_glwin32
val.psz_string = strdup( VOUT_TITLE " (OpenGL output)" ); val.psz_string = strdup( VOUT_TITLE " (OpenGL output)" );
#else #endif
#ifdef MODULE_NAME_IS_direct3d
val.psz_string = strdup( VOUT_TITLE " (Direct3D output)" );
#endif
#ifdef MODULE_NAME_IS_directx
if( p_event->p_vout->p_sys->b_using_overlay ) val.psz_string = if( p_event->p_vout->p_sys->b_using_overlay ) val.psz_string =
strdup( VOUT_TITLE " (hardware YUV overlay DirectX output)" ); strdup( VOUT_TITLE " (hardware YUV overlay DirectX output)" );
else if( p_event->p_vout->p_sys->b_hw_yuv ) val.psz_string = else if( p_event->p_vout->p_sys->b_hw_yuv ) val.psz_string =
...@@ -481,9 +493,9 @@ static int DirectXCreateWindow( vout_thread_t *p_vout ) ...@@ -481,9 +493,9 @@ static int DirectXCreateWindow( vout_thread_t *p_vout )
_T(VOUT_TITLE) _T(" (DirectX Output)"), /* window title */ _T(VOUT_TITLE) _T(" (DirectX Output)"), /* window title */
i_style, /* window style */ i_style, /* window style */
(p_vout->p_sys->i_window_x < 0) ? CW_USEDEFAULT : (p_vout->p_sys->i_window_x < 0) ? CW_USEDEFAULT :
p_vout->p_sys->i_window_x, /* default X coordinate */ (UINT)p_vout->p_sys->i_window_x, /* default X coordinate */
(p_vout->p_sys->i_window_y < 0) ? CW_USEDEFAULT : (p_vout->p_sys->i_window_y < 0) ? CW_USEDEFAULT :
p_vout->p_sys->i_window_y, /* default Y coordinate */ (UINT)p_vout->p_sys->i_window_y, /* default Y coordinate */
rect_window.right - rect_window.left, /* window width */ rect_window.right - rect_window.left, /* window width */
rect_window.bottom - rect_window.top, /* window height */ rect_window.bottom - rect_window.top, /* window height */
p_vout->p_sys->hparent, /* parent window */ p_vout->p_sys->hparent, /* parent window */
...@@ -519,20 +531,33 @@ static int DirectXCreateWindow( vout_thread_t *p_vout ) ...@@ -519,20 +531,33 @@ static int DirectXCreateWindow( vout_thread_t *p_vout )
NULL, NULL, hInstance, NULL ); NULL, NULL, hInstance, NULL );
} }
/* Now display the window */
ShowWindow( p_vout->p_sys->hwnd, SW_SHOW );
/* Create video sub-window. This sub window will always exactly match
* the size of the video, which allows us to use crazy overlay colorkeys
* without having them shown outside of the video area. */
SendMessage( p_vout->p_sys->hwnd, WM_VLC_CREATE_VIDEO_WIN, 0, 0 );
/* Append a "Always On Top" entry in the system menu */ /* Append a "Always On Top" entry in the system menu */
hMenu = GetSystemMenu( p_vout->p_sys->hwnd, FALSE ); hMenu = GetSystemMenu( p_vout->p_sys->hwnd, FALSE );
AppendMenu( hMenu, MF_SEPARATOR, 0, _T("") ); AppendMenu( hMenu, MF_SEPARATOR, 0, _T("") );
AppendMenu( hMenu, MF_STRING | MF_UNCHECKED, AppendMenu( hMenu, MF_STRING | MF_UNCHECKED,
IDM_TOGGLE_ON_TOP, _T("Always on &Top") ); IDM_TOGGLE_ON_TOP, _T("Always on &Top") );
/* Create video sub-window. This sub window will always exactly match
* the size of the video, which allows us to use crazy overlay colorkeys
* without having them shown outside of the video area. */
p_vout->p_sys->hvideownd =
CreateWindow( _T("VLC DirectX video"), _T(""), /* window class */
WS_CHILD | WS_VISIBLE, /* window style */
0, 0,
p_vout->render.i_width, /* default width */
p_vout->render.i_height, /* default height */
p_vout->p_sys->hwnd, /* parent window */
NULL, hInstance,
(LPVOID)p_vout ); /* send p_vout to WM_CREATE */
if( !p_vout->p_sys->hvideownd )
msg_Warn( p_vout, "can't create video sub-window" );
else
msg_Dbg( p_vout, "created video sub-window" );
/* Now display the window */
ShowWindow( p_vout->p_sys->hwnd, SW_SHOW );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -613,6 +638,7 @@ void E_(DirectXUpdateRects)( vout_thread_t *p_vout, vlc_bool_t b_force ) ...@@ -613,6 +638,7 @@ void E_(DirectXUpdateRects)( vout_thread_t *p_vout, vlc_bool_t b_force )
rect_dest.top = point.y + i_y; rect_dest.top = point.y + i_y;
rect_dest.bottom = rect_dest.top + i_height; rect_dest.bottom = rect_dest.top + i_height;
#ifdef MODULE_NAME_IS_vout_directx
/* Apply overlay hardware constraints */ /* Apply overlay hardware constraints */
if( p_vout->p_sys->b_using_overlay ) if( p_vout->p_sys->b_using_overlay )
{ {
...@@ -626,6 +652,7 @@ void E_(DirectXUpdateRects)( vout_thread_t *p_vout, vlc_bool_t b_force ) ...@@ -626,6 +652,7 @@ void E_(DirectXUpdateRects)( vout_thread_t *p_vout, vlc_bool_t b_force )
p_vout->p_sys->i_align_dest_size / 2 ) & p_vout->p_sys->i_align_dest_size / 2 ) &
~p_vout->p_sys->i_align_dest_size) + rect_dest.left; ~p_vout->p_sys->i_align_dest_size) + rect_dest.left;
} }
#endif
/* UpdateOverlay directdraw function doesn't automatically clip to the /* UpdateOverlay directdraw function doesn't automatically clip to the
* display size so we need to do it otherwise it will fail */ * display size so we need to do it otherwise it will fail */
...@@ -675,6 +702,7 @@ void E_(DirectXUpdateRects)( vout_thread_t *p_vout, vlc_bool_t b_force ) ...@@ -675,6 +702,7 @@ void E_(DirectXUpdateRects)( vout_thread_t *p_vout, vlc_bool_t b_force )
(rect_dest.bottom - rect_dest_clipped.bottom) * (rect_dest.bottom - rect_dest_clipped.bottom) *
p_vout->fmt_out.i_visible_height / (rect_dest.bottom - rect_dest.top); p_vout->fmt_out.i_visible_height / (rect_dest.bottom - rect_dest.top);
#ifdef MODULE_NAME_IS_vout_directx
/* Apply overlay hardware constraints */ /* Apply overlay hardware constraints */
if( p_vout->p_sys->b_using_overlay ) if( p_vout->p_sys->b_using_overlay )
{ {
...@@ -689,6 +717,7 @@ void E_(DirectXUpdateRects)( vout_thread_t *p_vout, vlc_bool_t b_force ) ...@@ -689,6 +717,7 @@ void E_(DirectXUpdateRects)( vout_thread_t *p_vout, vlc_bool_t b_force )
p_vout->p_sys->i_align_src_size / 2 ) & p_vout->p_sys->i_align_src_size / 2 ) &
~p_vout->p_sys->i_align_src_size) + rect_src_clipped.left; ~p_vout->p_sys->i_align_src_size) + rect_src_clipped.left;
} }
#endif
#if 0 #if 0
msg_Dbg( p_vout, "DirectXUpdateRects image_src_clipped" msg_Dbg( p_vout, "DirectXUpdateRects image_src_clipped"
...@@ -704,8 +733,10 @@ void E_(DirectXUpdateRects)( vout_thread_t *p_vout, vlc_bool_t b_force ) ...@@ -704,8 +733,10 @@ void E_(DirectXUpdateRects)( vout_thread_t *p_vout, vlc_bool_t b_force )
rect_dest_clipped.top -= p_vout->p_sys->rect_display.top; rect_dest_clipped.top -= p_vout->p_sys->rect_display.top;
rect_dest_clipped.bottom -= p_vout->p_sys->rect_display.top; rect_dest_clipped.bottom -= p_vout->p_sys->rect_display.top;
#ifdef MODULE_NAME_IS_vout_directx
if( p_vout->p_sys->b_using_overlay ) if( p_vout->p_sys->b_using_overlay )
E_(DirectXUpdateOverlay)( p_vout ); E_(DirectXUpdateOverlay)( p_vout );
#endif
/* Signal the change in size/position */ /* Signal the change in size/position */
p_vout->p_sys->i_changes |= DX_POSITION_CHANGE; p_vout->p_sys->i_changes |= DX_POSITION_CHANGE;
...@@ -808,23 +839,6 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message, ...@@ -808,23 +839,6 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
} }
break; break;
case WM_VLC_CREATE_VIDEO_WIN:
/* Create video sub-window */
p_vout->p_sys->hvideownd =
CreateWindow( _T("VLC DirectX video"), _T(""), /* window class */
WS_CHILD | WS_VISIBLE, /* window style */
CW_USEDEFAULT, CW_USEDEFAULT, /* default coordinates */
CW_USEDEFAULT, CW_USEDEFAULT,
hwnd, /* parent window */
NULL, GetModuleHandle(NULL),
(LPVOID)p_vout ); /* send p_vout to WM_CREATE */
if( !p_vout->p_sys->hvideownd )
msg_Warn( p_vout, "can't create video sub-window" );
else
msg_Dbg( p_vout, "created video sub-window" );
break;
case WM_PAINT: case WM_PAINT:
case WM_NCPAINT: case WM_NCPAINT:
case WM_ERASEBKGND: case WM_ERASEBKGND:
......
...@@ -104,10 +104,6 @@ static int OpenVideo( vlc_object_t *p_this ) ...@@ -104,10 +104,6 @@ static int OpenVideo( vlc_object_t *p_this )
p_vout->pf_manage = Manage; p_vout->pf_manage = Manage;
p_vout->pf_swap = GLSwapBuffers; p_vout->pf_swap = GLSwapBuffers;
p_vout->p_sys->p_ddobject = NULL;
p_vout->p_sys->p_display = NULL;
p_vout->p_sys->p_current_surface = NULL;
p_vout->p_sys->p_clipper = NULL;
p_vout->p_sys->hwnd = p_vout->p_sys->hvideownd = NULL; p_vout->p_sys->hwnd = p_vout->p_sys->hvideownd = NULL;
p_vout->p_sys->hparent = p_vout->p_sys->hfswnd = NULL; p_vout->p_sys->hparent = p_vout->p_sys->hfswnd = NULL;
p_vout->p_sys->i_changes = 0; p_vout->p_sys->i_changes = 0;
...@@ -485,8 +481,3 @@ static void GLSwapBuffers( vout_thread_t *p_vout ) ...@@ -485,8 +481,3 @@ static void GLSwapBuffers( vout_thread_t *p_vout )
{ {
SwapBuffers( p_vout->p_sys->hGLDC ); SwapBuffers( p_vout->p_sys->hGLDC );
} }
int E_(DirectXUpdateOverlay)( vout_thread_t *p_vout )
{
return 1;
}
...@@ -40,12 +40,6 @@ typedef struct event_thread_t ...@@ -40,12 +40,6 @@ typedef struct event_thread_t
*****************************************************************************/ *****************************************************************************/
struct vout_sys_t struct vout_sys_t
{ {
LPDIRECTDRAW2 p_ddobject; /* DirectDraw object */
LPDIRECTDRAWSURFACE2 p_display; /* Display device */
LPDIRECTDRAWSURFACE2 p_current_surface; /* surface currently displayed */
LPDIRECTDRAWCLIPPER p_clipper; /* clipper used for blitting */
HINSTANCE hddraw_dll; /* handle of the opened ddraw dll */
HWND hwnd; /* Handle of the main window */ HWND hwnd; /* Handle of the main window */
HWND hvideownd; /* Handle of the video sub-window */ HWND hvideownd; /* Handle of the video sub-window */
HWND hparent; /* Handle of the parent window */ HWND hparent; /* Handle of the parent window */
...@@ -58,15 +52,13 @@ struct vout_sys_t ...@@ -58,15 +52,13 @@ struct vout_sys_t
HMONITOR (WINAPI* MonitorFromWindow)( HWND, DWORD ); HMONITOR (WINAPI* MonitorFromWindow)( HWND, DWORD );
BOOL (WINAPI* GetMonitorInfo)( HMONITOR, LPMONITORINFO ); BOOL (WINAPI* GetMonitorInfo)( HMONITOR, LPMONITORINFO );
vlc_bool_t b_using_overlay; /* Are we using an overlay surface */
vlc_bool_t b_use_sysmem; /* Should we use system memory for surfaces */
vlc_bool_t b_hw_yuv; /* Should we use hardware YUV->RGB conversions */
vlc_bool_t b_3buf_overlay; /* Should we use triple buffered overlays */
/* size of the display */ /* size of the display */
RECT rect_display; RECT rect_display;
int i_display_depth; int i_display_depth;
/* size of the overall window (including black bands) */
RECT rect_parent;
/* Window position and size */ /* Window position and size */
int i_window_x; int i_window_x;
int i_window_y; int i_window_y;
...@@ -74,65 +66,74 @@ struct vout_sys_t ...@@ -74,65 +66,74 @@ struct vout_sys_t
int i_window_height; int i_window_height;
int i_window_style; int i_window_style;
volatile uint16_t i_changes; /* changes made to the video display */
/* Mouse */
volatile vlc_bool_t b_cursor_hidden;
volatile mtime_t i_lastmoved;
/* Misc */
vlc_bool_t b_on_top_change;
vlc_bool_t b_wallpaper;
/* screensaver system settings to be restored when vout is closed */
UINT i_spi_lowpowertimeout;
UINT i_spi_powerofftimeout;
UINT i_spi_screensavetimeout;
/* Coordinates of src and dest images (used when blitting to display) */ /* Coordinates of src and dest images (used when blitting to display) */
RECT rect_src; RECT rect_src;
RECT rect_src_clipped; RECT rect_src_clipped;
RECT rect_dest; RECT rect_dest;
RECT rect_dest_clipped; RECT rect_dest_clipped;
RECT rect_parent;
#ifdef MODULE_NAME_IS_vout_directx
/* Overlay alignment restrictions */ /* Overlay alignment restrictions */
int i_align_src_boundary; int i_align_src_boundary;
int i_align_src_size; int i_align_src_size;
int i_align_dest_boundary; int i_align_dest_boundary;
int i_align_dest_size; int i_align_dest_size;
vlc_bool_t b_using_overlay; /* Are we using an overlay surface */
vlc_bool_t b_use_sysmem; /* Should we use system memory for surfaces */
vlc_bool_t b_hw_yuv; /* Should we use hardware YUV->RGB conversions */
vlc_bool_t b_3buf_overlay; /* Should we use triple buffered overlays */
/* DDraw capabilities */ /* DDraw capabilities */
int b_caps_overlay_clipping; int b_caps_overlay_clipping;
int i_rgb_colorkey; /* colorkey in RGB used by the overlay */ int i_rgb_colorkey; /* colorkey in RGB used by the overlay */
int i_colorkey; /* colorkey used by the overlay */ int i_colorkey; /* colorkey used by the overlay */
volatile uint16_t i_changes; /* changes made to the video display */
/* Mouse */
volatile vlc_bool_t b_cursor_hidden;
volatile mtime_t i_lastmoved;
/* Misc */
vlc_bool_t b_on_top_change;
vlc_bool_t b_wallpaper;
COLORREF color_bkg; COLORREF color_bkg;
COLORREF color_bkgtxt; COLORREF color_bkgtxt;
LPDIRECTDRAW2 p_ddobject; /* DirectDraw object */
LPDIRECTDRAWSURFACE2 p_display; /* Display device */
LPDIRECTDRAWSURFACE2 p_current_surface; /* surface currently displayed */
LPDIRECTDRAWCLIPPER p_clipper; /* clipper used for blitting */
HINSTANCE hddraw_dll; /* handle of the opened ddraw dll */
#endif
#ifdef MODULE_NAME_IS_glwin32 #ifdef MODULE_NAME_IS_glwin32
HDC hGLDC; HDC hGLDC;
HGLRC hGLRC; HGLRC hGLRC;
#endif #endif
/* screensaver system settings to be restored when vout is closed */ #ifdef MODULE_NAME_IS_direct3d
UINT i_spi_lowpowertimeout; // core objects
UINT i_spi_powerofftimeout; LPDIRECT3D9 p_d3dobj;
UINT i_spi_screensavetimeout; LPDIRECT3DDEVICE9 p_d3ddev;
D3DPRESENT_PARAMETERS d3dpp;
// scene objects
LPDIRECT3DTEXTURE9 p_d3dtex;
LPDIRECT3DVERTEXBUFFER9 p_d3dvtc;
#endif
event_thread_t *p_event; event_thread_t *p_event;
vlc_mutex_t lock; vlc_mutex_t lock;
}; };
/*****************************************************************************
* picture_sys_t: direct buffer method descriptor
*****************************************************************************
* This structure is part of the picture descriptor, it describes the
* DirectX specific properties of a direct buffer.
*****************************************************************************/
struct picture_sys_t
{
LPDIRECTDRAWSURFACE2 p_surface;
DDSURFACEDESC ddsd;
LPDIRECTDRAWSURFACE2 p_front_surface;
};
/***************************************************************************** /*****************************************************************************
* Prototypes from vout.c * Prototypes from vout.c
*****************************************************************************/ *****************************************************************************/
...@@ -149,8 +150,7 @@ void E_(DirectXUpdateRects) ( vout_thread_t *p_vout, vlc_bool_t b_force ); ...@@ -149,8 +150,7 @@ void E_(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_SHOW_MOUSE WM_APP + 1 #define WM_VLC_SHOW_MOUSE WM_APP + 1
#define WM_VLC_CREATE_VIDEO_WIN WM_APP + 2 #define WM_VLC_CHANGE_TEXT WM_APP + 2
#define WM_VLC_CHANGE_TEXT WM_APP + 3
#define IDM_TOGGLE_ON_TOP WM_USER + 1 #define IDM_TOGGLE_ON_TOP WM_USER + 1
#define DX_POSITION_CHANGE 0x1000 #define DX_POSITION_CHANGE 0x1000
#define DX_WALLPAPER_CHANGE 0x2000 #define DX_WALLPAPER_CHANGE 0x2000
......
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