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