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 #ifdef MODULE_NAME_IS_direct2d
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
;
61 ID3D11Texture2D
*pTexture
;
62 ID3D11ShaderResourceView
*d3dresViewY
;
63 ID3D11ShaderResourceView
*d3dresViewUV
;
64 ID3D11PixelShader
*d3dpixelShader
;
65 D3D11_VIEWPORT cropViewport
;
70 extern const GUID GUID_SWAPCHAIN_WIDTH
;
71 extern const GUID GUID_SWAPCHAIN_HEIGHT
;
74 /*****************************************************************************
75 * vout_sys_t: video output method descriptor
76 *****************************************************************************
77 * This structure is part of the video output thread descriptor.
78 * It describes the module specific properties of an output thread.
79 *****************************************************************************/
80 struct vout_display_sys_t
83 event_thread_t
*event
;
86 HWND hwnd
; /* Handle of the main window */
87 HWND hvideownd
; /* Handle of the video sub-window */
88 struct vout_window_t
*parent_window
; /* Parent window VLC object */
89 HWND hparent
; /* Handle of the parent window */
90 HWND hfswnd
; /* Handle of the fullscreen window */
92 /* size of the display */
95 /* size of the overall window (including black bands) */
98 unsigned changes
; /* changes made to the video display */
101 bool is_first_display
;
104 /* screensaver system settings to be restored when vout is closed */
105 UINT i_spi_screensaveactive
;
107 /* Coordinates of src and dest images (used when blitting to display) */
109 RECT rect_src_clipped
;
111 RECT rect_dest_clipped
;
113 picture_pool_t
*pool
;
115 #ifdef MODULE_NAME_IS_directdraw
116 /* Multi-monitor support */
117 HMONITOR hmonitor
; /* handle of the current monitor */
118 GUID
*display_driver
;
120 /* Overlay alignment restrictions */
121 int i_align_src_boundary
;
122 int i_align_src_size
;
123 int i_align_dest_boundary
;
124 int i_align_dest_size
;
126 bool use_wallpaper
; /* show as desktop wallpaper ? */
128 bool use_overlay
; /* Are we using an overlay surface */
129 bool restore_overlay
;
131 /* DDraw capabilities */
132 bool can_blit_fourcc
;
134 uint32_t i_rgb_colorkey
; /* colorkey in RGB used by the overlay */
135 uint32_t i_colorkey
; /* colorkey used by the overlay */
138 COLORREF color_bkgtxt
;
140 LPDIRECTDRAW2 ddobject
; /* DirectDraw object */
141 LPDIRECTDRAWSURFACE2 display
; /* Display device */
142 LPDIRECTDRAWCLIPPER clipper
; /* clipper used for blitting */
143 HINSTANCE hddraw_dll
; /* handle of the opened ddraw dll */
145 picture_sys_t
*picsys
;
147 /* It protects the following variables */
150 bool wallpaper_requested
;
153 #if defined(MODULE_NAME_IS_glwin32) || defined(MODULE_NAME_IS_wgl)
157 # ifdef MODULE_NAME_IS_glwin32
158 vout_display_opengl_t
*vgl
;
160 HDC affinityHDC
; // DC for the selected GPU
163 #ifdef MODULE_NAME_IS_direct2d
164 HINSTANCE d2_dll
; /* handle of the opened d2d1 dll */
165 ID2D1Factory
*d2_factory
; /* D2D factory */
166 ID2D1HwndRenderTarget
*d2_render_target
; /* D2D rendering target */
167 ID2D1Bitmap
*d2_bitmap
; /* D2 bitmap */
170 #ifdef MODULE_NAME_IS_direct3d11
171 #if !VLC_WINSTORE_APP
172 HINSTANCE hdxgi_dll
; /* handle of the opened dxgi dll */
173 HINSTANCE hd3d11_dll
; /* handle of the opened d3d11 dll */
174 HINSTANCE hd3dcompiler_dll
; /* handle of the opened d3dcompiler dll */
175 IDXGIFactory2
*dxgifactory
; /* DXGI 1.2 factory */
176 /* We should find a better way to store this or atleast a shorter name */
177 PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN OurD3D11CreateDeviceAndSwapChain
;
178 PFN_D3D11_CREATE_DEVICE OurD3D11CreateDevice
;
179 pD3DCompile OurD3DCompile
;
181 HANDLE context_lock
; /* D3D11 Context lock necessary
182 for hw decoding on WinRT */
184 IDXGISwapChain1
*dxgiswapChain
; /* DXGI 1.1 swap chain */
185 ID3D11Device
*d3ddevice
; /* D3D device */
186 ID3D11DeviceContext
*d3dcontext
; /* D3D context */
188 d3d_quad_cfg_t picQuadConfig
;
190 /* staging quad to adjust visible borders */
191 d3d_quad_t stagingQuad
;
193 ID3D11RenderTargetView
*d3drenderTargetView
;
194 ID3D11DepthStencilView
*d3ddepthStencilView
;
195 const char *d3dPxShader
;
198 vlc_fourcc_t pSubpictureChromas
[2];
199 const char *psz_rgbaPxShader
;
200 ID3D11PixelShader
*pSPUPixelShader
;
201 DXGI_FORMAT d3dregion_format
;
203 picture_t
**d3dregions
;
206 #ifdef MODULE_NAME_IS_direct3d9
207 bool allow_hw_yuv
; /* Should we use hardware YUV->RGB conversions */
208 /* show video on desktop window ? */
215 vout_display_cfg_t cfg_saved
; /* configuration used before going into desktop mode */
218 HINSTANCE hd3d9_dll
; /* handle of the opened d3d9 dll */
219 HINSTANCE hd3d9x_dll
; /* handle of the opened d3d9x dll */
220 IDirect3DPixelShader9
* d3dx_shader
;
223 LPDIRECT3DDEVICE9 d3ddev
;
224 D3DPRESENT_PARAMETERS d3dpp
;
228 LPDIRECT3DTEXTURE9 d3dtex
;
229 LPDIRECT3DVERTEXBUFFER9 d3dvtc
;
230 D3DFORMAT d3dregion_format
;
232 struct d3d_region_t
*d3dregion
;
234 picture_sys_t
*picsys
;
242 /* It protects the following variables */
245 bool desktop_requested
;
248 #if defined(MODULE_NAME_IS_wingdi)
251 /* Our offscreen bitmap and its framebuffer */
257 BITMAPINFO bitmapinfo
;
265 /*****************************************************************************
266 * Prototypes from common.c
267 *****************************************************************************/
268 int CommonInit(vout_display_t
*);
269 void CommonClean(vout_display_t
*);
270 void CommonManage(vout_display_t
*);
271 int CommonControl(vout_display_t
*, int , va_list );
272 void CommonDisplay(vout_display_t
*);
273 int CommonUpdatePicture(picture_t
*, picture_t
**, uint8_t *, unsigned);
275 void UpdateRects (vout_display_t
*,
276 const vout_display_cfg_t
*,
277 const video_format_t
*,
279 void AlignRect(RECT
*, int align_boundary
, int align_size
);
281 picture_pool_t
*CommonPool(vout_display_t
*, unsigned);
283 /*****************************************************************************
285 *****************************************************************************/
286 #define IDM_TOGGLE_ON_TOP WM_USER + 1
287 #define DX_POSITION_CHANGE 0x1000
288 #define DX_WALLPAPER_CHANGE 0x2000
289 #define DX_DESKTOP_CHANGE 0x4000