core: remove the 360 video viewpoint zoom
[vlc.git] / modules / video_output / win32 / common.h
blobbfa59bdf1c41bc1caea48ea1a6011f255a0ea873
1 /*****************************************************************************
2 * common.h: Windows video output header file
3 *****************************************************************************
4 * Copyright (C) 2001-2009 VLC authors and VideoLAN
5 * $Id$
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
27 # include <ddraw.h>
28 #endif
29 #ifdef MODULE_NAME_IS_direct3d11
30 # include <d3d11.h>
31 # include <dxgi1_2.h>
32 # include <d3dcompiler.h>
33 #endif
34 #ifdef MODULE_NAME_IS_direct3d9
35 # include <d3d9.h>
36 # include <d3dx9effect.h>
37 #endif
38 #if defined(MODULE_NAME_IS_glwin32) || defined(MODULE_NAME_IS_wgl)
39 # include "../opengl.h"
40 #endif
41 #if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
42 # include <dxgidebug.h>
43 #endif
45 /*****************************************************************************
46 * event_thread_t: event thread
47 *****************************************************************************/
48 #include "events.h"
50 #ifdef MODULE_NAME_IS_direct3d11
51 typedef struct
53 DXGI_FORMAT textureFormat;
54 DXGI_FORMAT resourceFormatYRGB;
55 DXGI_FORMAT resourceFormatUV;
56 } d3d_quad_cfg_t;
58 typedef struct
60 ID3D11Buffer *pVertexBuffer;
61 UINT vertexCount;
62 ID3D11VertexShader *d3dvertexShader;
63 ID3D11Buffer *pIndexBuffer;
64 UINT indexCount;
65 ID3D11Buffer *pVertexShaderConstants;
66 ID3D11Texture2D *pTexture;
67 ID3D11Buffer *pPixelShaderConstants;
68 ID3D11ShaderResourceView *d3dresViewY;
69 ID3D11ShaderResourceView *d3dresViewUV;
70 ID3D11PixelShader *d3dpixelShader;
71 D3D11_VIEWPORT cropViewport;
72 } d3d_quad_t;
73 #endif
75 #if VLC_WINSTORE_APP
76 extern const GUID GUID_SWAPCHAIN_WIDTH;
77 extern const GUID GUID_SWAPCHAIN_HEIGHT;
78 #endif
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
88 /* */
89 event_thread_t *event;
91 /* */
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 */
99 RECT rect_display;
101 /* size of the overall window (including black bands) */
102 RECT rect_parent;
104 # if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
105 HINSTANCE dxgidebug_dll;
106 # endif
108 unsigned changes; /* changes made to the video display */
110 /* Misc */
111 bool is_first_display;
112 bool is_on_top;
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) */
118 RECT rect_src;
119 RECT rect_src_clipped;
120 RECT rect_dest;
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 */
147 COLORREF color_bkg;
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 */
158 vlc_mutex_t lock;
159 bool ch_wallpaper;
160 bool wallpaper_requested;
161 #endif
163 #if defined(MODULE_NAME_IS_glwin32) || defined(MODULE_NAME_IS_wgl)
164 HDC hGLDC;
165 HGLRC hGLRC;
166 vlc_gl_t gl;
167 # ifdef MODULE_NAME_IS_glwin32
168 vout_display_opengl_t *vgl;
169 # endif
170 HDC affinityHDC; // DC for the selected GPU
171 #endif
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;
183 #endif
184 #if defined(HAVE_ID3D11VIDEODECODER)
185 HANDLE context_lock; /* D3D11 Context lock necessary
186 for hw decoding */
187 #endif
188 IDXGISwapChain1 *dxgiswapChain; /* DXGI 1.1 swap chain */
189 ID3D11Device *d3ddevice; /* D3D device */
190 ID3D11DeviceContext *d3dcontext; /* D3D context */
191 d3d_quad_t picQuad;
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;
204 // SPU
205 vlc_fourcc_t pSubpictureChromas[2];
206 const char *psz_rgbaPxShader;
207 ID3D11PixelShader *pSPUPixelShader;
208 DXGI_FORMAT d3dregion_format;
209 int d3dregion_count;
210 picture_t **d3dregions;
211 #endif
213 #ifdef MODULE_NAME_IS_direct3d9
214 bool allow_hw_yuv; /* Should we use hardware YUV->RGB conversions */
215 /* show video on desktop window ? */
216 bool use_desktop;
217 struct {
218 bool is_fullscreen;
219 bool is_on_top;
220 RECT win;
221 } desktop_save;
222 vout_display_cfg_t cfg_saved; /* configuration used before going into desktop mode */
224 // core objects
225 HINSTANCE hd3d9_dll; /* handle of the opened d3d9 dll */
226 HINSTANCE hd3d9x_dll; /* handle of the opened d3d9x dll */
227 IDirect3DPixelShader9* d3dx_shader;
228 LPDIRECT3D9 d3dobj;
229 D3DCAPS9 d3dcaps;
230 LPDIRECT3DDEVICE9 d3ddev;
231 D3DPRESENT_PARAMETERS d3dpp;
232 bool use_d3d9ex;
234 // scene objects
235 LPDIRECT3DTEXTURE9 d3dtex;
236 LPDIRECT3DVERTEXBUFFER9 d3dvtc;
237 D3DFORMAT d3dregion_format;
238 int d3dregion_count;
239 struct d3d_region_t *d3dregion;
241 picture_sys_t *picsys;
243 /* */
244 bool reset_device;
245 bool reopen_device;
246 bool lost_not_ready;
247 bool clear_scene;
249 /* It protects the following variables */
250 vlc_mutex_t lock;
251 bool ch_desktop;
252 bool desktop_requested;
253 #endif
255 #if defined(MODULE_NAME_IS_wingdi)
256 int i_depth;
258 /* Our offscreen bitmap and its framebuffer */
259 HDC off_dc;
260 HBITMAP off_bitmap;
262 struct
264 BITMAPINFO bitmapinfo;
265 RGBQUAD red;
266 RGBQUAD green;
267 RGBQUAD blue;
269 #endif
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 *,
285 bool is_forced);
286 void AlignRect(RECT *, int align_boundary, int align_size);
288 picture_pool_t *CommonPool(vout_display_t *, unsigned);
290 /*****************************************************************************
291 * Constants
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