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
36 # include <d3dcompiler.h>
38 #ifdef MODULE_NAME_IS_direct3d9
40 # include <d3dx9effect.h>
42 #ifdef MODULE_NAME_IS_glwin32
43 # include "../opengl.h"
45 #ifdef MODULE_NAME_IS_direct2d
49 /*****************************************************************************
50 * event_thread_t: event thread
51 *****************************************************************************/
54 /*****************************************************************************
55 * vout_sys_t: video output method descriptor
56 *****************************************************************************
57 * This structure is part of the video output thread descriptor.
58 * It describes the module specific properties of an output thread.
59 *****************************************************************************/
60 struct vout_display_sys_t
63 event_thread_t *event;
66 HWND hwnd; /* Handle of the main window */
67 HWND hvideownd; /* Handle of the video sub-window */
68 struct vout_window_t *parent_window; /* Parent window VLC object */
69 HWND hparent; /* Handle of the parent window */
70 HWND hfswnd; /* Handle of the fullscreen window */
72 /* size of the display */
75 /* size of the overall window (including black bands) */
78 unsigned changes; /* changes made to the video display */
81 bool is_first_display;
84 /* screensaver system settings to be restored when vout is closed */
85 UINT i_spi_screensaveactive;
87 /* Coordinates of src and dest images (used when blitting to display) */
89 RECT rect_src_clipped;
91 RECT rect_dest_clipped;
95 #ifdef MODULE_NAME_IS_directdraw
96 /* Multi-monitor support */
97 HMONITOR hmonitor; /* handle of the current monitor */
100 /* Overlay alignment restrictions */
101 int i_align_src_boundary;
102 int i_align_src_size;
103 int i_align_dest_boundary;
104 int i_align_dest_size;
106 bool use_wallpaper; /* show as desktop wallpaper ? */
108 bool use_overlay; /* Are we using an overlay surface */
109 bool restore_overlay;
111 /* DDraw capabilities */
112 bool can_blit_fourcc;
114 uint32_t i_rgb_colorkey; /* colorkey in RGB used by the overlay */
115 uint32_t i_colorkey; /* colorkey used by the overlay */
118 COLORREF color_bkgtxt;
120 LPDIRECTDRAW2 ddobject; /* DirectDraw object */
121 LPDIRECTDRAWSURFACE2 display; /* Display device */
122 LPDIRECTDRAWCLIPPER clipper; /* clipper used for blitting */
123 HINSTANCE hddraw_dll; /* handle of the opened ddraw dll */
125 picture_sys_t *picsys;
127 /* It protects the following variables */
130 bool wallpaper_requested;
133 #ifdef MODULE_NAME_IS_glwin32
137 vout_display_opengl_t *vgl;
138 HDC affinityHDC; // DC for the selected GPU
141 #ifdef MODULE_NAME_IS_direct2d
142 HINSTANCE d2_dll; /* handle of the opened d2d1 dll */
143 ID2D1Factory *d2_factory; /* D2D factory */
144 ID2D1HwndRenderTarget *d2_render_target; /* D2D rendering target */
145 ID2D1Bitmap *d2_bitmap; /* D2 bitmap */
148 #ifdef MODULE_NAME_IS_direct3d11
149 #if !VLC_WINSTORE_APP
150 HINSTANCE hdxgi_dll; /* handle of the opened dxgi dll */
151 HINSTANCE hd3d11_dll; /* handle of the opened d3d11 dll */
152 HINSTANCE hd3dcompiler_dll; /* handle of the opened d3dcompiler dll */
153 IDXGIAdapter *dxgiadapter; /* DXGI adapter */
154 IDXGIFactory *dxgifactory; /* DXGI factory */
155 IDXGISwapChain *dxgiswapChain; /* DXGI 1.0 swap chain */
156 /* We should find a better way to store this or atleast a shorter name */
157 PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN OurD3D11CreateDeviceAndSwapChain;
158 PFN_D3D11_CREATE_DEVICE OurD3D11CreateDevice;
159 pD3DCompile OurD3DCompile;
161 IDXGISwapChain1 *dxgiswapChain; /* DXGI 1.1 swap chain */
163 ID3D11Device *d3ddevice; /* D3D device */
164 ID3D11DeviceContext *d3dcontext; /* D3D context */
165 ID3D11Texture2D *d3dtexture;
166 ID3D11ShaderResourceView *d3dresViewY;
167 ID3D11ShaderResourceView *d3dresViewUV;
168 ID3D11RenderTargetView *d3drenderTargetView;
169 ID3D11DepthStencilView *d3ddepthStencilView;
170 ID3D11VertexShader *d3dvertexShader;
171 ID3D11PixelShader *d3dpixelShader;
172 ID3D11InputLayout *d3dvertexLayout;
173 ID3D11SamplerState *d3dsampState;
174 picture_sys_t *picsys;
175 D3D_FEATURE_LEVEL d3dfeaturelevel;
176 DXGI_FORMAT d3dFormatTex;
177 DXGI_FORMAT d3dFormatY;
178 DXGI_FORMAT d3dFormatUV;
179 vlc_fourcc_t vlcFormat;
182 #ifdef MODULE_NAME_IS_direct3d9
183 bool allow_hw_yuv; /* Should we use hardware YUV->RGB conversions */
184 /* show video on desktop window ? */
191 vout_display_cfg_t cfg_saved; /* configuration used before going into desktop mode */
194 HINSTANCE hd3d9_dll; /* handle of the opened d3d9 dll */
195 HINSTANCE hd3d9x_dll; /* handle of the opened d3d9x dll */
196 IDirect3DPixelShader9* d3dx_shader;
199 LPDIRECT3DDEVICE9 d3ddev;
200 D3DPRESENT_PARAMETERS d3dpp;
203 LPDIRECT3DTEXTURE9 d3dtex;
204 LPDIRECT3DVERTEXBUFFER9 d3dvtc;
205 D3DFORMAT d3dregion_format;
207 struct d3d_region_t *d3dregion;
209 picture_sys_t *picsys;
217 /* It protects the following variables */
220 bool desktop_requested;
223 #if defined(MODULE_NAME_IS_wingdi)
226 /* Our offscreen bitmap and its framebuffer */
232 BITMAPINFO bitmapinfo;
240 /*****************************************************************************
241 * Prototypes from common.c
242 *****************************************************************************/
243 int CommonInit(vout_display_t *);
244 void CommonClean(vout_display_t *);
245 void CommonManage(vout_display_t *);
246 int CommonControl(vout_display_t *, int , va_list );
247 void CommonDisplay(vout_display_t *);
248 int CommonUpdatePicture(picture_t *, picture_t **, uint8_t *, unsigned);
250 void UpdateRects (vout_display_t *,
251 const vout_display_cfg_t *,
252 const video_format_t *,
254 void AlignRect(RECT *, int align_boundary, int align_size);
256 picture_pool_t *CommonPool(vout_display_t *, unsigned);
258 /*****************************************************************************
260 *****************************************************************************/
261 #define IDM_TOGGLE_ON_TOP WM_USER + 1
262 #define DX_POSITION_CHANGE 0x1000
263 #define DX_WALLPAPER_CHANGE 0x2000
264 #define DX_DESKTOP_CHANGE 0x4000