]> git.sesse.net Git - vlc/blob - modules/video_output/msw/vout.h
Add a desktop mode to the Direct3d video output. This allow displaying video on a...
[vlc] / modules / video_output / msw / vout.h
1 /*****************************************************************************
2  * vout.h: Windows video output header file
3  *****************************************************************************
4  * Copyright (C) 2001-2009 the VideoLAN team
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
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 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 General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * event_thread_t: event thread
27  *****************************************************************************/
28 typedef struct event_thread_t
29 {
30     VLC_COMMON_MEMBERS
31
32     vout_thread_t * p_vout;
33     HANDLE window_ready;
34
35 } event_thread_t;
36
37 #ifdef MODULE_NAME_IS_wingapi
38     typedef struct GXDisplayProperties {
39         DWORD cxWidth;
40         DWORD cyHeight;
41         long cbxPitch;
42         long cbyPitch;
43         long cBPP;
44         DWORD ffFormat;
45     } GXDisplayProperties;
46
47     typedef struct GXScreenRect {
48         DWORD dwTop;
49         DWORD dwLeft;
50         DWORD dwWidth;
51         DWORD dwHeight;
52     } GXScreenRect;
53
54 #   define GX_FULLSCREEN    0x01
55 #   define GX_NORMALKEYS    0x02
56 #   define GX_LANDSCAPEKEYS 0x03
57
58 #   ifndef kfLandscape
59 #       define kfLandscape      0x8
60 #       define kfPalette        0x10
61 #       define kfDirect         0x20
62 #       define kfDirect555      0x40
63 #       define kfDirect565      0x80
64 #       define kfDirect888      0x100
65 #       define kfDirect444      0x200
66 #       define kfDirectInverted 0x400
67 #   endif
68
69 #endif
70
71 struct vout_window_t;
72
73 /*****************************************************************************
74  * vout_sys_t: video output method descriptor
75  *****************************************************************************
76  * This structure is part of the video output thread descriptor.
77  * It describes the module specific properties of an output thread.
78  *****************************************************************************/
79 struct vout_sys_t
80 {
81     HWND                 hwnd;                  /* Handle of the main window */
82     HWND                 hvideownd;        /* Handle of the video sub-window */
83     struct vout_window_t *parent_window;         /* Parent window VLC object */
84     HWND                 hparent;             /* Handle of the parent window */
85     HWND                 hfswnd;          /* Handle of the fullscreen window */
86     WNDPROC              pf_wndproc;             /* Window handling callback */
87
88     /* Multi-monitor support */
89     HMONITOR             hmonitor;          /* handle of the current monitor */
90     GUID                 *p_display_driver;
91     HMONITOR             (WINAPI* MonitorFromWindow)( HWND, DWORD );
92     BOOL                 (WINAPI* GetMonitorInfo)( HMONITOR, LPMONITORINFO );
93
94     /* size of the display */
95     RECT         rect_display;
96     int          i_display_depth;
97
98     /* size of the overall window (including black bands) */
99     RECT         rect_parent;
100
101     /* Window position and size */
102     int          i_window_x;
103     int          i_window_y;
104     int          i_window_width;
105     int          i_window_height;
106     int          i_window_style;
107
108     volatile uint16_t i_changes;        /* changes made to the video display */
109
110     /* Mouse */
111     volatile bool b_cursor_hidden;
112     volatile mtime_t    i_lastmoved;
113     mtime_t             i_mouse_hide_timeout;
114
115     /* Misc */
116     bool      b_on_top_change;
117
118 #ifndef UNDER_CE
119
120     /* screensaver system settings to be restored when vout is closed */
121     UINT i_spi_lowpowertimeout;
122     UINT i_spi_powerofftimeout;
123     UINT i_spi_screensavetimeout;
124
125 #endif
126
127     /* Coordinates of src and dest images (used when blitting to display) */
128     RECT         rect_src;
129     RECT         rect_src_clipped;
130     RECT         rect_dest;
131     RECT         rect_dest_clipped;
132
133     bool   b_hw_yuv;    /* Should we use hardware YUV->RGB conversions */
134
135
136 #ifdef MODULE_NAME_IS_directx
137     /* Overlay alignment restrictions */
138     int          i_align_src_boundary;
139     int          i_align_src_size;
140     int          i_align_dest_boundary;
141     int          i_align_dest_size;
142
143     bool      b_wallpaper;    /* show as desktop wallpaper ? */
144
145     bool   b_using_overlay;         /* Are we using an overlay surface */
146     bool   b_use_sysmem;   /* Should we use system memory for surfaces */
147     bool   b_3buf_overlay;   /* Should we use triple buffered overlays */
148
149     /* DDraw capabilities */
150     int          b_caps_overlay_clipping;
151
152     int          i_rgb_colorkey;      /* colorkey in RGB used by the overlay */
153     int          i_colorkey;                 /* colorkey used by the overlay */
154
155     COLORREF        color_bkg;
156     COLORREF        color_bkgtxt;
157
158     LPDIRECTDRAW2        p_ddobject;                    /* DirectDraw object */
159     LPDIRECTDRAWSURFACE2 p_display;                        /* Display device */
160     LPDIRECTDRAWSURFACE2 p_current_surface;   /* surface currently displayed */
161     LPDIRECTDRAWCLIPPER  p_clipper;             /* clipper used for blitting */
162     HINSTANCE            hddraw_dll;       /* handle of the opened ddraw dll */
163 #endif
164
165 #ifdef MODULE_NAME_IS_glwin32
166     HDC hGLDC;
167     HGLRC hGLRC;
168 #endif
169
170 #ifdef MODULE_NAME_IS_direct3d
171     /* show video on desktop window ? */
172     bool      b_desktop;
173
174     // core objects
175     HINSTANCE               hd3d9_dll;       /* handle of the opened d3d9 dll */
176     LPDIRECT3D9             p_d3dobj;
177     LPDIRECT3DDEVICE9       p_d3ddev;
178     D3DFORMAT               bbFormat;
179     // scene objects
180     LPDIRECT3DTEXTURE9      p_d3dtex;
181     LPDIRECT3DVERTEXBUFFER9 p_d3dvtc;
182 #endif
183
184 #ifdef MODULE_NAME_IS_wingdi
185
186     int  i_depth;
187
188     /* Our offscreen bitmap and its framebuffer */
189     HDC        off_dc;
190     HBITMAP    off_bitmap;
191     uint8_t *  p_pic_buffer;
192     int        i_pic_pitch;
193     int        i_pic_pixel_pitch;
194
195     BITMAPINFO bitmapinfo;
196     RGBQUAD    red;
197     RGBQUAD    green;
198     RGBQUAD    blue;
199 #endif
200
201 #ifdef MODULE_NAME_IS_wingapi
202     int        i_depth;
203     int        render_width;
204     int        render_height;
205             /* Our offscreen bitmap and its framebuffer */
206     HDC        off_dc;
207     HBITMAP    off_bitmap;
208     uint8_t *  p_pic_buffer;
209     int        i_pic_pitch;
210     int        i_pic_pixel_pitch;
211
212     BITMAPINFO bitmapinfo;
213     RGBQUAD    red;
214     RGBQUAD    green;
215     RGBQUAD    blue;
216
217     bool b_focus;
218     bool b_parent_focus;
219
220     HINSTANCE  gapi_dll;                   /* handle of the opened gapi dll */
221
222     /* GAPI functions */
223     int (*GXOpenDisplay)( HWND hWnd, DWORD dwFlags );
224     int (*GXCloseDisplay)();
225     void *(*GXBeginDraw)();
226     int (*GXEndDraw)();
227     GXDisplayProperties (*GXGetDisplayProperties)();
228     int (*GXSuspend)();
229     int (*GXResume)();
230 #endif
231
232 #ifndef UNDER_CE
233     /* suspend display */
234     bool   b_suspend_display;
235 #endif
236
237     event_thread_t *p_event;
238     vlc_mutex_t    lock;
239 };
240
241 #ifdef MODULE_NAME_IS_wingapi
242 #   define GXOpenDisplay p_vout->p_sys->GXOpenDisplay
243 #   define GXCloseDisplay p_vout->p_sys->GXCloseDisplay
244 #   define GXBeginDraw p_vout->p_sys->GXBeginDraw
245 #   define GXEndDraw p_vout->p_sys->GXEndDraw
246 #   define GXGetDisplayProperties p_vout->p_sys->GXGetDisplayProperties
247 #   define GXSuspend p_vout->p_sys->GXSuspend
248 #   define GXResume p_vout->p_sys->GXResume
249 #endif
250
251 /*****************************************************************************
252  * Prototypes from directx.c
253  *****************************************************************************/
254 int DirectDrawUpdateOverlay( vout_thread_t *p_vout );
255
256 /*****************************************************************************
257  * Prototypes from events.c
258  *****************************************************************************/
259 void* EventThread ( vlc_object_t *p_this );
260 void UpdateRects ( vout_thread_t *p_vout, bool b_force );
261 void Win32ToggleFullscreen ( vout_thread_t *p_vout );
262 void DisableScreensaver ( vout_thread_t *p_vout );
263 void RestoreScreensaver ( vout_thread_t *p_vout );
264 int CreateEventThread( vout_thread_t *p_vout );
265 void StopEventThread ( vout_thread_t *p_vout );
266
267 /*****************************************************************************
268  * Constants
269  *****************************************************************************/
270 #define WM_VLC_HIDE_MOUSE WM_APP
271 #define WM_VLC_SHOW_MOUSE WM_APP + 1
272 #define WM_VLC_CHANGE_TEXT WM_APP + 2
273 #define IDM_TOGGLE_ON_TOP WM_USER + 1
274 #define DX_POSITION_CHANGE 0x1000
275 #define DX_WALLPAPER_CHANGE 0x2000
276 #define DX_DESKTOP_CHANGE 0x4000
277 #define EVENT_THREAD_ENDED 0x6000
278 #define SWITCHING_MODE_FLAG 0x8000
279
280 /*****************************************************************************
281  * WinCE helpers
282  *****************************************************************************/
283 #ifdef UNDER_CE
284
285 #define AdjustWindowRect(a,b,c)
286
287 #ifndef GCL_HBRBACKGROUND
288 #   define GCL_HBRBACKGROUND (-10)
289 #endif
290
291 //#define FindWindowEx(a,b,c,d) 0
292
293 #define GetWindowPlacement(a,b)
294 #define SetWindowPlacement(a,b)
295 /*typedef struct _WINDOWPLACEMENT {
296     UINT length;
297     UINT flags;
298     UINT showCmd;
299     POINT ptMinPosition;
300     POINT ptMaxPosition;
301     RECT rcNormalPosition;
302 } WINDOWPLACEMENT;*/
303
304 #ifndef WM_NCMOUSEMOVE
305 #   define WM_NCMOUSEMOVE 160
306 #endif
307 #ifndef CS_OWNDC
308 #   define CS_OWNDC 32
309 #endif
310 #ifndef SC_SCREENSAVE
311 #   define SC_SCREENSAVE 0xF140
312 #endif
313 #ifndef SC_MONITORPOWER
314 #   define SC_MONITORPOWER 0xF170
315 #endif
316 #ifndef WM_NCPAINT
317 #   define WM_NCPAINT 133
318 #endif
319 #ifndef WS_OVERLAPPEDWINDOW
320 #   define WS_OVERLAPPEDWINDOW 0xcf0000
321 #endif
322 #ifndef WS_EX_NOPARENTNOTIFY
323 #   define WS_EX_NOPARENTNOTIFY 4
324 #endif
325 #ifndef WS_EX_APPWINDOW
326 #define WS_EX_APPWINDOW 0x40000
327 #endif
328
329 //#define SetWindowLongPtr SetWindowLong
330 //#define GetWindowLongPtr GetWindowLong
331 //#define GWLP_USERDATA GWL_USERDATA
332
333 #endif //UNDER_CE