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