1 /*****************************************************************************
2 * common.h: Windows video output header file
3 *****************************************************************************
4 * Copyright (C) 2001-2009 VLC authors and VideoLAN
7 * Authors: Gildas Bazin <gbazin@videolan.org>
8 * Damien Fouilleul <damienf@videolan.org>
9 * Martell Malone <martellmalone@gmail.com>
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation; either version 2.1 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with this program; if not, write to the Free Software Foundation,
23 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
26 #ifdef MODULE_NAME_IS_directdraw
29 #ifdef MODULE_NAME_IS_direct3d11
32 # include <d3dcompiler.h>
34 #ifdef MODULE_NAME_IS_direct3d9
36 # include <d3dx9effect.h>
38 #if defined(MODULE_NAME_IS_glwin32) || defined(MODULE_NAME_IS_wgl)
39 # include "../opengl.h"
41 #if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
42 # include <dxgidebug.h>
45 /*****************************************************************************
46 * event_thread_t: event thread
47 *****************************************************************************/
50 #ifdef MODULE_NAME_IS_direct3d11
53 DXGI_FORMAT textureFormat
;
54 DXGI_FORMAT resourceFormatYRGB
;
55 DXGI_FORMAT resourceFormatUV
;
60 ID3D11Buffer
*pVertexBuffer
;
62 ID3D11VertexShader
*d3dvertexShader
;
63 ID3D11Buffer
*pIndexBuffer
;
65 ID3D11Buffer
*pVertexShaderConstants
;
66 ID3D11Texture2D
*pTexture
;
67 ID3D11Buffer
*pPixelShaderConstants
;
68 ID3D11ShaderResourceView
*d3dresViewY
;
69 ID3D11ShaderResourceView
*d3dresViewUV
;
70 ID3D11PixelShader
*d3dpixelShader
;
71 D3D11_VIEWPORT cropViewport
;
76 extern const GUID GUID_SWAPCHAIN_WIDTH
;
77 extern const GUID GUID_SWAPCHAIN_HEIGHT
;
80 /*****************************************************************************
81 * vout_sys_t: video output method descriptor
82 *****************************************************************************
83 * This structure is part of the video output thread descriptor.
84 * It describes the module specific properties of an output thread.
85 *****************************************************************************/
86 struct vout_display_sys_t
89 event_thread_t
*event
;
92 HWND hwnd
; /* Handle of the main window */
93 HWND hvideownd
; /* Handle of the video sub-window */
94 struct vout_window_t
*parent_window
; /* Parent window VLC object */
95 HWND hparent
; /* Handle of the parent window */
96 HWND hfswnd
; /* Handle of the fullscreen window */
98 /* size of the display */
101 /* size of the overall window (including black bands) */
104 # if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
105 HINSTANCE dxgidebug_dll
;
108 unsigned changes
; /* changes made to the video display */
111 bool is_first_display
;
114 /* screensaver system settings to be restored when vout is closed */
115 UINT i_spi_screensaveactive
;
117 /* Coordinates of src and dest images (used when blitting to display) */
119 RECT rect_src_clipped
;
121 RECT rect_dest_clipped
;
123 picture_pool_t
*pool
;
125 #ifdef MODULE_NAME_IS_directdraw
126 /* Multi-monitor support */
127 HMONITOR hmonitor
; /* handle of the current monitor */
128 GUID
*display_driver
;
130 /* Overlay alignment restrictions */
131 int i_align_src_boundary
;
132 int i_align_src_size
;
133 int i_align_dest_boundary
;
134 int i_align_dest_size
;
136 bool use_wallpaper
; /* show as desktop wallpaper ? */
138 bool use_overlay
; /* Are we using an overlay surface */
139 bool restore_overlay
;
141 /* DDraw capabilities */
142 bool can_blit_fourcc
;
144 uint32_t i_rgb_colorkey
; /* colorkey in RGB used by the overlay */
145 uint32_t i_colorkey
; /* colorkey used by the overlay */
148 COLORREF color_bkgtxt
;
150 LPDIRECTDRAW2 ddobject
; /* DirectDraw object */
151 LPDIRECTDRAWSURFACE2 display
; /* Display device */
152 LPDIRECTDRAWCLIPPER clipper
; /* clipper used for blitting */
153 HINSTANCE hddraw_dll
; /* handle of the opened ddraw dll */
155 picture_sys_t
*picsys
;
157 /* It protects the following variables */
160 bool wallpaper_requested
;
163 #if defined(MODULE_NAME_IS_glwin32) || defined(MODULE_NAME_IS_wgl)
167 # ifdef MODULE_NAME_IS_glwin32
168 vout_display_opengl_t
*vgl
;
170 HDC affinityHDC
; // DC for the selected GPU
173 #ifdef MODULE_NAME_IS_direct3d11
174 #if !VLC_WINSTORE_APP
175 HINSTANCE hdxgi_dll
; /* handle of the opened dxgi dll */
176 HINSTANCE hd3d11_dll
; /* handle of the opened d3d11 dll */
177 HINSTANCE hd3dcompiler_dll
; /* handle of the opened d3dcompiler dll */
178 IDXGIFactory2
*dxgifactory
; /* DXGI 1.2 factory */
179 /* We should find a better way to store this or atleast a shorter name */
180 PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN OurD3D11CreateDeviceAndSwapChain
;
181 PFN_D3D11_CREATE_DEVICE OurD3D11CreateDevice
;
182 pD3DCompile OurD3DCompile
;
184 #if defined(HAVE_ID3D11VIDEODECODER)
185 HANDLE context_lock
; /* D3D11 Context lock necessary
188 IDXGISwapChain1
*dxgiswapChain
; /* DXGI 1.1 swap chain */
189 ID3D11Device
*d3ddevice
; /* D3D device */
190 ID3D11DeviceContext
*d3dcontext
; /* D3D context */
192 d3d_quad_cfg_t picQuadConfig
;
194 /* staging quad to adjust visible borders */
195 d3d_quad_t stagingQuad
;
197 ID3D11RenderTargetView
*d3drenderTargetView
;
198 ID3D11DepthStencilView
*d3ddepthStencilView
;
199 const char *d3dPxShader
;
201 ID3D11VertexShader
*flatVSShader
;
202 ID3D11VertexShader
*projectionVSShader
;
205 vlc_fourcc_t pSubpictureChromas
[2];
206 const char *psz_rgbaPxShader
;
207 ID3D11PixelShader
*pSPUPixelShader
;
208 DXGI_FORMAT d3dregion_format
;
210 picture_t
**d3dregions
;
213 #ifdef MODULE_NAME_IS_direct3d9
214 bool allow_hw_yuv
; /* Should we use hardware YUV->RGB conversions */
215 /* show video on desktop window ? */
222 vout_display_cfg_t cfg_saved
; /* configuration used before going into desktop mode */
225 HINSTANCE hd3d9_dll
; /* handle of the opened d3d9 dll */
226 HINSTANCE hd3d9x_dll
; /* handle of the opened d3d9x dll */
227 IDirect3DPixelShader9
* d3dx_shader
;
230 LPDIRECT3DDEVICE9 d3ddev
;
231 D3DPRESENT_PARAMETERS d3dpp
;
235 LPDIRECT3DTEXTURE9 d3dtex
;
236 LPDIRECT3DVERTEXBUFFER9 d3dvtc
;
237 D3DFORMAT d3dregion_format
;
239 struct d3d_region_t
*d3dregion
;
241 picture_sys_t
*picsys
;
249 /* It protects the following variables */
252 bool desktop_requested
;
255 #if defined(MODULE_NAME_IS_wingdi)
258 /* Our offscreen bitmap and its framebuffer */
264 BITMAPINFO bitmapinfo
;
272 /*****************************************************************************
273 * Prototypes from common.c
274 *****************************************************************************/
275 int CommonInit(vout_display_t
*);
276 void CommonClean(vout_display_t
*);
277 void CommonManage(vout_display_t
*);
278 int CommonControl(vout_display_t
*, int , va_list );
279 void CommonDisplay(vout_display_t
*);
280 int CommonUpdatePicture(picture_t
*, picture_t
**, uint8_t *, unsigned);
282 void UpdateRects (vout_display_t
*,
283 const vout_display_cfg_t
*,
284 const video_format_t
*,
286 void AlignRect(RECT
*, int align_boundary
, int align_size
);
288 picture_pool_t
*CommonPool(vout_display_t
*, unsigned);
290 /*****************************************************************************
292 *****************************************************************************/
293 #define IDM_TOGGLE_ON_TOP WM_USER + 1
294 #define DX_POSITION_CHANGE 0x1000
295 #define DX_WALLPAPER_CHANGE 0x2000
296 #define DX_DESKTOP_CHANGE 0x4000