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