]> git.sesse.net Git - vlc/blob - modules/video_output/msw/common.h
Win32: include headers where needed
[vlc] / modules / video_output / msw / common.h
1 /*****************************************************************************
2  * common.h: Windows video output header file
3  *****************************************************************************
4  * Copyright (C) 2001-2009 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Gildas Bazin <gbazin@videolan.org>
8  *          Damien Fouilleul <damienf@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifdef MODULE_NAME_IS_directdraw
26 # include <ddraw.h>
27 #endif
28 #ifdef MODULE_NAME_IS_direct3d
29 # include <d3d9.h>
30 #endif
31 #ifdef MODULE_NAME_IS_glwin32
32 # include "../opengl.h"
33 #endif
34 #ifdef MODULE_NAME_IS_direct2d
35 # include <d2d1.h>
36 #endif
37
38 /*****************************************************************************
39  * event_thread_t: event thread
40  *****************************************************************************/
41 #include <vlc_picture_pool.h>
42 #include "events.h"
43
44 /*****************************************************************************
45  * vout_sys_t: video output method descriptor
46  *****************************************************************************
47  * This structure is part of the video output thread descriptor.
48  * It describes the module specific properties of an output thread.
49  *****************************************************************************/
50 struct vout_display_sys_t
51 {
52     /* */
53     event_thread_t *event;
54
55     /* */
56     HWND                 hwnd;                  /* Handle of the main window */
57     HWND                 hvideownd;        /* Handle of the video sub-window */
58     struct vout_window_t *parent_window;         /* Parent window VLC object */
59     HWND                 hparent;             /* Handle of the parent window */
60     HWND                 hfswnd;          /* Handle of the fullscreen window */
61
62     /* size of the display */
63     RECT         rect_display;
64     int          display_depth;
65
66     /* size of the overall window (including black bands) */
67     RECT         rect_parent;
68
69     unsigned changes;        /* changes made to the video display */
70
71     /* Misc */
72     bool is_first_display;
73     bool is_on_top;
74
75     /* screensaver system settings to be restored when vout is closed */
76     UINT i_spi_screensaveactive;
77
78     /* Coordinates of src and dest images (used when blitting to display) */
79     RECT         rect_src;
80     RECT         rect_src_clipped;
81     RECT         rect_dest;
82     RECT         rect_dest_clipped;
83
84     picture_pool_t *pool;
85
86 #ifdef MODULE_NAME_IS_directdraw
87     /* Multi-monitor support */
88     HMONITOR             hmonitor;          /* handle of the current monitor */
89     GUID                 *display_driver;
90
91     /* Overlay alignment restrictions */
92     int          i_align_src_boundary;
93     int          i_align_src_size;
94     int          i_align_dest_boundary;
95     int          i_align_dest_size;
96
97     bool   use_wallpaper;   /* show as desktop wallpaper ? */
98
99     bool   use_overlay;     /* Are we using an overlay surface */
100     bool   restore_overlay;
101
102     /* DDraw capabilities */
103     bool            can_blit_fourcc;
104
105     uint32_t        i_rgb_colorkey;      /* colorkey in RGB used by the overlay */
106     uint32_t        i_colorkey;                 /* colorkey used by the overlay */
107
108     COLORREF        color_bkg;
109     COLORREF        color_bkgtxt;
110
111     LPDIRECTDRAW2        ddobject;                    /* DirectDraw object */
112     LPDIRECTDRAWSURFACE2 display;                        /* Display device */
113     LPDIRECTDRAWCLIPPER  clipper;             /* clipper used for blitting */
114     HINSTANCE            hddraw_dll;       /* handle of the opened ddraw dll */
115
116     picture_sys_t        *picsys;
117
118     /* It protects the following variables */
119     vlc_mutex_t    lock;
120     bool           ch_wallpaper;
121     bool           wallpaper_requested;
122 #endif
123
124 #ifdef MODULE_NAME_IS_glwin32
125     HDC                   hGLDC;
126     HGLRC                 hGLRC;
127     vlc_gl_t              gl;
128     vout_display_opengl_t *vgl;
129 #endif
130
131 #ifdef MODULE_NAME_IS_direct2d
132     HINSTANCE              d2_dll;            /* handle of the opened d2d1 dll */
133     ID2D1Factory           *d2_factory;                         /* D2D factory */
134     ID2D1HwndRenderTarget  *d2_render_target;          /* D2D rendering target */
135     ID2D1Bitmap            *d2_bitmap;                            /* D2 bitmap */
136 #endif
137
138 #ifdef MODULE_NAME_IS_direct3d
139     bool allow_hw_yuv;    /* Should we use hardware YUV->RGB conversions */
140     /* show video on desktop window ? */
141     bool use_desktop;
142     struct {
143         bool is_fullscreen;
144         bool is_on_top;
145         RECT win;
146     } desktop_save;
147     vout_display_cfg_t cfg_saved; /* configuration used before going into desktop mode */
148
149     // core objects
150     HINSTANCE               hd3d9_dll;       /* handle of the opened d3d9 dll */
151     LPDIRECT3D9             d3dobj;
152     D3DCAPS9                d3dcaps;
153     LPDIRECT3DDEVICE9       d3ddev;
154     D3DPRESENT_PARAMETERS   d3dpp;
155     // scene objects
156     LPDIRECT3DTEXTURE9      d3dtex;
157     LPDIRECT3DVERTEXBUFFER9 d3dvtc;
158     D3DFORMAT               d3dregion_format;
159     int                     d3dregion_count;
160     struct d3d_region_t     *d3dregion;
161
162     picture_sys_t           *picsys;
163
164     /* */
165     bool                    reset_device;
166     bool                    reopen_device;
167     bool                    clear_scene;
168
169     /* It protects the following variables */
170     vlc_mutex_t    lock;
171     bool           ch_desktop;
172     bool           desktop_requested;
173 #endif
174
175 #if defined(MODULE_NAME_IS_wingdi)
176     int  i_depth;
177
178     /* Our offscreen bitmap and its framebuffer */
179     HDC        off_dc;
180     HBITMAP    off_bitmap;
181
182     struct
183     {
184         BITMAPINFO bitmapinfo;
185         RGBQUAD    red;
186         RGBQUAD    green;
187         RGBQUAD    blue;
188     };
189 #endif
190
191     HDC affinityHDC; // DC for the selected GPU
192 };
193
194 /*****************************************************************************
195  * Prototypes from common.c
196  *****************************************************************************/
197 int  CommonInit(vout_display_t *);
198 void CommonClean(vout_display_t *);
199 void CommonManage(vout_display_t *);
200 int  CommonControl(vout_display_t *, int , va_list );
201 void CommonDisplay(vout_display_t *);
202 int  CommonUpdatePicture(picture_t *, picture_t **, uint8_t *, unsigned);
203
204 void UpdateRects (vout_display_t *,
205                   const vout_display_cfg_t *,
206                   const video_format_t *,
207                   bool is_forced);
208 void AlignRect(RECT *, int align_boundary, int align_size);
209
210 /*****************************************************************************
211  * Constants
212  *****************************************************************************/
213 #define IDM_TOGGLE_ON_TOP WM_USER + 1
214 #define DX_POSITION_CHANGE 0x1000
215 #define DX_WALLPAPER_CHANGE 0x2000
216 #define DX_DESKTOP_CHANGE 0x4000