Commit a4b7b656 authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

vout: win32: move each vout_display_sys_t in their respective module

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 70437b20
......@@ -41,6 +41,8 @@
#define COBJMACROS
#include <shobjidl.h>
#define vout_display_sys_win32_t vout_display_sys_t
#include "common.h"
#if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
......@@ -59,7 +61,7 @@ static void RestoreScreensaver(vout_display_t *);
/* */
int CommonInit(vout_display_t *vd)
{
vout_display_sys_win32_t *sys = &vd->sys->sys;
vout_display_sys_t *sys = vd->sys;
sys->hwnd = NULL;
sys->hvideownd = NULL;
......@@ -124,7 +126,7 @@ int CommonInit(vout_display_t *vd)
picture_pool_t *CommonPool(vout_display_t *vd, unsigned count)
{
VLC_UNUSED(count);
return vd->sys->sys.pool;
return vd->sys->pool;
}
/*****************************************************************************
......@@ -139,7 +141,7 @@ void UpdateRects(vout_display_t *vd,
const video_format_t *source,
bool is_forced)
{
vout_display_sys_win32_t *sys = &vd->sys->sys;
vout_display_sys_t *sys = vd->sys;
#define rect_src sys->rect_src
#define rect_src_clipped sys->rect_src_clipped
#define rect_dest sys->rect_dest
......@@ -355,7 +357,7 @@ exit:
/* */
void CommonClean(vout_display_t *vd)
{
vout_display_sys_win32_t *sys = &vd->sys->sys;
vout_display_sys_t *sys = vd->sys;
if (sys->event) {
CommonChangeThumbnailClip(vd, false);
EventThreadStop(sys->event);
......@@ -382,7 +384,7 @@ void CommonClean(vout_display_t *vd)
void CommonManage(vout_display_t *vd)
{
vout_display_sys_win32_t *sys = &vd->sys->sys;
vout_display_sys_t *sys = vd->sys;
/* We used to call the Win32 PeekMessage function here to read the window
* messages. But since window can stay blocked into this function for a
......@@ -432,7 +434,7 @@ void CommonManage(vout_display_t *vd)
*/
void CommonDisplay(vout_display_t *vd)
{
vout_display_sys_win32_t *sys = &vd->sys->sys;
vout_display_sys_t *sys = vd->sys;
if (!sys->is_first_display)
return;
......@@ -536,7 +538,7 @@ void AlignRect(RECT *r, int align_boundary, int align_size)
/* */
static void CommonChangeThumbnailClip(vout_display_t *vd, bool show)
{
vout_display_sys_win32_t *sys = &vd->sys->sys;
vout_display_sys_t *sys = vd->sys;
/* Windows 7 taskbar thumbnail code */
OSVERSIONINFO winVer;
......@@ -578,7 +580,7 @@ static void CommonChangeThumbnailClip(vout_display_t *vd, bool show)
static int CommonControlSetFullscreen(vout_display_t *vd, bool is_fullscreen)
{
vout_display_sys_win32_t *sys = &vd->sys->sys;
vout_display_sys_t *sys = vd->sys;
#ifdef MODULE_NAME_IS_direct3d9
if (sys->use_desktop && is_fullscreen)
......@@ -665,7 +667,7 @@ static int CommonControlSetFullscreen(vout_display_t *vd, bool is_fullscreen)
int CommonControl(vout_display_t *vd, int query, va_list args)
{
vout_display_sys_win32_t *sys = &vd->sys->sys;
vout_display_sys_t *sys = vd->sys;
switch (query) {
case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE: /* const vout_display_cfg_t *p_cfg */
......@@ -741,7 +743,7 @@ int CommonControl(vout_display_t *vd, int query, va_list args)
static void DisableScreensaver(vout_display_t *vd)
{
vout_display_sys_win32_t *sys = &vd->sys->sys;
vout_display_sys_t *sys = vd->sys;
/* disable screensaver by temporarily changing system settings */
sys->i_spi_screensaveactive = 0;
......@@ -758,7 +760,7 @@ static void DisableScreensaver(vout_display_t *vd)
static void RestoreScreensaver(vout_display_t *vd)
{
vout_display_sys_win32_t *sys = &vd->sys->sys;
vout_display_sys_t *sys = vd->sys;
/* restore screensaver system settings */
if (0 != sys->i_spi_screensaveactive) {
......
......@@ -23,57 +23,11 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef MODULE_NAME_IS_directdraw
# include <ddraw.h>
#endif
#ifdef MODULE_NAME_IS_direct3d11
# include <d3d11.h>
# include <dxgi1_2.h>
# include <d3dcompiler.h>
#endif
#ifdef MODULE_NAME_IS_direct3d9
# include <d3d9.h>
# include <d3dx9effect.h>
#endif
#if defined(MODULE_NAME_IS_glwin32) || defined(MODULE_NAME_IS_wgl)
# include "../opengl/vout_helper.h"
#endif
/*****************************************************************************
* event_thread_t: event thread
*****************************************************************************/
#include "events.h"
#ifdef MODULE_NAME_IS_direct3d11
#include "../../video_chroma/dxgi_fmt.h"
#ifdef HAVE_ID3D11VIDEODECODER
#include "../../video_chroma/d3d11_fmt.h"
#endif
typedef struct
{
DXGI_FORMAT textureFormat;
DXGI_FORMAT resourceFormatYRGB;
DXGI_FORMAT resourceFormatUV;
} d3d_quad_cfg_t;
typedef struct
{
ID3D11Buffer *pVertexBuffer;
UINT vertexCount;
ID3D11VertexShader *d3dvertexShader;
ID3D11Buffer *pIndexBuffer;
UINT indexCount;
ID3D11Buffer *pVertexShaderConstants;
ID3D11Texture2D *pTexture;
ID3D11Buffer *pPixelShaderConstants[2];
UINT PSConstantsCount;
ID3D11ShaderResourceView *d3dresViewY;
ID3D11ShaderResourceView *d3dresViewUV;
ID3D11PixelShader *d3dpixelShader;
D3D11_VIEWPORT cropViewport;
} d3d_quad_t;
#endif
#if VLC_WINSTORE_APP
extern const GUID GUID_SWAPCHAIN_WIDTH;
extern const GUID GUID_SWAPCHAIN_HEIGHT;
......@@ -135,147 +89,6 @@ typedef struct vout_display_sys_win32_t
} vout_display_sys_win32_t;
struct vout_display_sys_t
{
vout_display_sys_win32_t sys;
#ifdef MODULE_NAME_IS_directdraw
/* Multi-monitor support */
HMONITOR hmonitor; /* handle of the current monitor */
GUID *display_driver;
bool use_wallpaper; /* show as desktop wallpaper ? */
bool restore_overlay;
/* DDraw capabilities */
bool can_blit_fourcc;
uint32_t i_rgb_colorkey; /* colorkey in RGB used by the overlay */
uint32_t i_colorkey; /* colorkey used by the overlay */
COLORREF color_bkg;
COLORREF color_bkgtxt;
LPDIRECTDRAW2 ddobject; /* DirectDraw object */
LPDIRECTDRAWSURFACE2 display; /* Display device */
LPDIRECTDRAWCLIPPER clipper; /* clipper used for blitting */
HINSTANCE hddraw_dll; /* handle of the opened ddraw dll */
picture_sys_t *picsys;
/* It protects the following variables */
vlc_mutex_t lock;
bool ch_wallpaper;
bool wallpaper_requested;
#endif
#if defined(MODULE_NAME_IS_glwin32) || defined(MODULE_NAME_IS_wgl)
HDC hGLDC;
HGLRC hGLRC;
vlc_gl_t *gl;
# ifdef MODULE_NAME_IS_glwin32
vout_display_opengl_t *vgl;
# endif
HDC affinityHDC; // DC for the selected GPU
#endif
#ifdef MODULE_NAME_IS_direct3d11
#if !VLC_WINSTORE_APP
HINSTANCE hdxgi_dll; /* handle of the opened dxgi dll */
HINSTANCE hd3d11_dll; /* handle of the opened d3d11 dll */
HINSTANCE hd3dcompiler_dll; /* handle of the opened d3dcompiler dll */
IDXGIFactory2 *dxgifactory; /* DXGI 1.2 factory */
/* We should find a better way to store this or atleast a shorter name */
PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN OurD3D11CreateDeviceAndSwapChain;
PFN_D3D11_CREATE_DEVICE OurD3D11CreateDevice;
pD3DCompile OurD3DCompile;
#endif
#if defined(HAVE_ID3D11VIDEODECODER)
HANDLE context_lock; /* D3D11 Context lock necessary
for hw decoding */
#endif
IDXGISwapChain1 *dxgiswapChain; /* DXGI 1.1 swap chain */
ID3D11Device *d3ddevice; /* D3D device */
ID3D11DeviceContext *d3dcontext; /* D3D context */
d3d_quad_t picQuad;
d3d_quad_cfg_t picQuadConfig;
/* staging quad to adjust visible borders */
d3d_quad_t stagingQuad;
ID3D11RenderTargetView *d3drenderTargetView;
ID3D11DepthStencilView *d3ddepthStencilView;
const char *d3dPxShader;
ID3D11VertexShader *flatVSShader;
ID3D11VertexShader *projectionVSShader;
// SPU
vlc_fourcc_t pSubpictureChromas[2];
const char *psz_rgbaPxShader;
ID3D11PixelShader *pSPUPixelShader;
DXGI_FORMAT d3dregion_format;
int d3dregion_count;
picture_t **d3dregions;
#endif
#ifdef MODULE_NAME_IS_direct3d9
bool allow_hw_yuv; /* Should we use hardware YUV->RGB conversions */
struct {
bool is_fullscreen;
bool is_on_top;
RECT win;
} desktop_save;
vout_display_cfg_t cfg_saved; /* configuration used before going into desktop mode */
// core objects
HINSTANCE hd3d9_dll; /* handle of the opened d3d9 dll */
HINSTANCE hd3d9x_dll; /* handle of the opened d3d9x dll */
IDirect3DPixelShader9* d3dx_shader;
LPDIRECT3D9 d3dobj;
D3DCAPS9 d3dcaps;
LPDIRECT3DDEVICE9 d3ddev;
D3DPRESENT_PARAMETERS d3dpp;
bool use_d3d9ex;
// scene objects
LPDIRECT3DTEXTURE9 d3dtex;
LPDIRECT3DVERTEXBUFFER9 d3dvtc;
D3DFORMAT d3dregion_format;
int d3dregion_count;
struct d3d_region_t *d3dregion;
picture_sys_t *picsys;
/* */
bool reset_device;
bool reopen_device;
bool lost_not_ready;
bool clear_scene;
/* It protects the following variables */
vlc_mutex_t lock;
bool ch_desktop;
bool desktop_requested;
#endif
#if defined(MODULE_NAME_IS_wingdi)
int i_depth;
/* Our offscreen bitmap and its framebuffer */
HDC off_dc;
HBITMAP off_bitmap;
struct
{
BITMAPINFO bitmapinfo;
RGBQUAD red;
RGBQUAD green;
RGBQUAD blue;
};
#endif
};
/*****************************************************************************
* Prototypes from common.c
*****************************************************************************/
......
......@@ -40,6 +40,8 @@
#define COBJMACROS
#include <initguid.h>
#include <d3d11.h>
#include <dxgi1_2.h>
#include <d3dcompiler.h>
/* avoided until we can pass ISwapchainPanel without c++/cx mode
# include <windows.ui.xaml.media.dxinterop.h> */
......@@ -87,6 +89,75 @@ vlc_module_begin ()
set_callbacks(Open, Close)
vlc_module_end ()
/* A Quad is texture that can be displayed in a rectangle */
typedef struct
{
DXGI_FORMAT textureFormat;
DXGI_FORMAT resourceFormatYRGB;
DXGI_FORMAT resourceFormatUV;
} d3d_quad_cfg_t;
typedef struct
{
ID3D11Buffer *pVertexBuffer;
UINT vertexCount;
ID3D11VertexShader *d3dvertexShader;
ID3D11Buffer *pIndexBuffer;
UINT indexCount;
ID3D11Buffer *pVertexShaderConstants;
picture_sys_t picSys;
ID3D11Texture2D *pTexture;
ID3D11Buffer *pPixelShaderConstants[2];
UINT PSConstantsCount;
ID3D11ShaderResourceView *d3dresViewY;
ID3D11ShaderResourceView *d3dresViewUV;
ID3D11PixelShader *d3dpixelShader;
D3D11_VIEWPORT cropViewport;
} d3d_quad_t;
struct vout_display_sys_t
{
vout_display_sys_win32_t sys;
#if !VLC_WINSTORE_APP
HINSTANCE hdxgi_dll; /* handle of the opened dxgi dll */
HINSTANCE hd3d11_dll; /* handle of the opened d3d11 dll */
HINSTANCE hd3dcompiler_dll; /* handle of the opened d3dcompiler dll */
IDXGIFactory2 *dxgifactory; /* DXGI 1.2 factory */
/* We should find a better way to store this or atleast a shorter name */
PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN OurD3D11CreateDeviceAndSwapChain;
PFN_D3D11_CREATE_DEVICE OurD3D11CreateDevice;
pD3DCompile OurD3DCompile;
#endif
#if defined(HAVE_ID3D11VIDEODECODER)
HANDLE context_lock; /* D3D11 Context lock necessary
for hw decoding */
#endif
IDXGISwapChain1 *dxgiswapChain; /* DXGI 1.1 swap chain */
ID3D11Device *d3ddevice; /* D3D device */
ID3D11DeviceContext *d3dcontext; /* D3D context */
d3d_quad_t picQuad;
d3d_quad_cfg_t picQuadConfig;
/* staging quad to adjust visible borders */
d3d_quad_t stagingQuad;
ID3D11RenderTargetView *d3drenderTargetView;
ID3D11DepthStencilView *d3ddepthStencilView;
const char *d3dPxShader;
ID3D11VertexShader *flatVSShader;
ID3D11VertexShader *projectionVSShader;
// SPU
vlc_fourcc_t pSubpictureChromas[2];
const char *psz_rgbaPxShader;
ID3D11PixelShader *pSPUPixelShader;
DXGI_FORMAT d3dregion_format;
int d3dregion_count;
picture_t **d3dregions;
};
/* internal picture_t pool */
typedef struct
{
......
......@@ -47,6 +47,7 @@
#include <windows.h>
#include <d3d9.h>
#include <d3dx9effect.h>
#include "common.h"
#include "builtin_shaders.h"
......@@ -104,6 +105,49 @@ static const vlc_fourcc_t d3d_subpicture_chromas[] = {
0
};
struct vout_display_sys_t
{
vout_display_sys_win32_t sys;
bool allow_hw_yuv; /* Should we use hardware YUV->RGB conversions */
struct {
bool is_fullscreen;
bool is_on_top;
RECT win;
} desktop_save;
vout_display_cfg_t cfg_saved; /* configuration used before going into desktop mode */
// core objects
HINSTANCE hd3d9_dll; /* handle of the opened d3d9 dll */
HINSTANCE hd3d9x_dll; /* handle of the opened d3d9x dll */
IDirect3DPixelShader9* d3dx_shader;
LPDIRECT3D9 d3dobj;
D3DCAPS9 d3dcaps;
LPDIRECT3DDEVICE9 d3ddev;
D3DPRESENT_PARAMETERS d3dpp;
bool use_d3d9ex;
// scene objects
LPDIRECT3DTEXTURE9 d3dtex;
LPDIRECT3DVERTEXBUFFER9 d3dvtc;
D3DFORMAT d3dregion_format;
int d3dregion_count;
struct d3d_region_t *d3dregion;
picture_sys_t *picsys;
/* */
bool reset_device;
bool reopen_device;
bool lost_not_ready;
bool clear_scene;
/* It protects the following variables */
vlc_mutex_t lock;
bool ch_desktop;
bool desktop_requested;
};
struct picture_sys_t
{
LPDIRECT3DSURFACE9 surface;
......
......@@ -129,6 +129,39 @@ struct picture_sys_t {
picture_t *fallback;
};
struct vout_display_sys_t
{
vout_display_sys_win32_t sys;
/* Multi-monitor support */
HMONITOR hmonitor; /* handle of the current monitor */
GUID *display_driver;
bool use_wallpaper; /* show as desktop wallpaper ? */
bool restore_overlay;
/* DDraw capabilities */
bool can_blit_fourcc;
uint32_t i_rgb_colorkey; /* colorkey in RGB used by the overlay */
uint32_t i_colorkey; /* colorkey used by the overlay */
COLORREF color_bkg;
COLORREF color_bkgtxt;
LPDIRECTDRAW2 ddobject; /* DirectDraw object */
LPDIRECTDRAWSURFACE2 display; /* Display device */
LPDIRECTDRAWCLIPPER clipper; /* clipper used for blitting */
HINSTANCE hddraw_dll; /* handle of the opened ddraw dll */
picture_sys_t *picsys;
/* It protects the following variables */
vlc_mutex_t lock;
bool ch_wallpaper;
bool wallpaper_requested;
};
/*****************************************************************************
* DirectDraw GUIDs.
* Defining them here allows us to get rid of the dxguid library during
......
......@@ -41,6 +41,8 @@
#include <windowsx.h> /* GET_X_LPARAM */
#include <shellapi.h> /* ExtractIcon */
#define vout_display_sys_win32_t vout_display_sys_t
#include "common.h"
/*****************************************************************************
......@@ -1020,7 +1022,7 @@ static long FAR PASCAL WinVoutEventProc( HWND hwnd, UINT message,
case IDM_TOGGLE_ON_TOP: /* toggle the "on top" status */
{
msg_Dbg(vd, "WinProc WM_SYSCOMMAND: IDM_TOGGLE_ON_TOP");
HMENU hMenu = GetSystemMenu(vd->sys->sys.hwnd, FALSE);
HMENU hMenu = GetSystemMenu(vd->sys->hwnd, FALSE);
vout_display_SendWindowState(vd, (GetMenuState(hMenu, IDM_TOGGLE_ON_TOP, MF_BYCOMMAND) & MF_CHECKED) ?
VOUT_WINDOW_STATE_NORMAL : VOUT_WINDOW_STATE_ABOVE);
return 0;
......
......@@ -60,6 +60,17 @@ vlc_module_end()
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
struct vout_display_sys_t
{
vout_display_sys_win32_t sys;
HDC hGLDC;
HGLRC hGLRC;
vlc_gl_t *gl;
vout_display_opengl_t *vgl;
HDC affinityHDC; // DC for the selected GPU
};
static picture_pool_t *Pool (vout_display_t *, unsigned);
static void Prepare(vout_display_t *, picture_t *, subpicture_t *);
static void Display(vout_display_t *, picture_t *, subpicture_t *);
......
......@@ -58,6 +58,16 @@ vlc_module_end()
* Local prototypes.
*****************************************************************************/
struct vout_display_sys_t
{
vout_display_sys_win32_t sys;
HDC hGLDC;
HGLRC hGLRC;
vlc_gl_t *gl;
HDC affinityHDC; // DC for the selected GPU
};
static void Swap(vlc_gl_t *);
static void *OurGetProcAddress(vlc_gl_t *, const char *);
static int MakeCurrent(vlc_gl_t *gl);
......
......@@ -58,6 +58,25 @@ vlc_module_end ()
/*****************************************************************************
* Local prototypes
*****************************************************************************/
struct vout_display_sys_t
{
vout_display_sys_win32_t sys;
int i_depth;
/* Our offscreen bitmap and its framebuffer */
HDC off_dc;
HBITMAP off_bitmap;
struct
{
BITMAPINFO bitmapinfo;
RGBQUAD red;
RGBQUAD green;
RGBQUAD blue;
};
};
static picture_pool_t *Pool (vout_display_t *, unsigned);
static void Display(vout_display_t *, picture_t *, subpicture_t *subpicture);
static int Control(vout_display_t *, int, va_list);
......
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