]> git.sesse.net Git - vlc/blob - modules/video_output/msw/common.h
MSW/Direct3D: retain only picture_sys_t* instead of picture_resource_t
[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 /*****************************************************************************
26  * event_thread_t: event thread
27  *****************************************************************************/
28 #include <vlc_picture_pool.h>
29 #include "events.h"
30
31 /*****************************************************************************
32  * vout_sys_t: video output method descriptor
33  *****************************************************************************
34  * This structure is part of the video output thread descriptor.
35  * It describes the module specific properties of an output thread.
36  *****************************************************************************/
37 struct vout_display_sys_t
38 {
39     /* */
40     event_thread_t *event;
41
42     /* */
43     HWND                 hwnd;                  /* Handle of the main window */
44     HWND                 hvideownd;        /* Handle of the video sub-window */
45     struct vout_window_t *parent_window;         /* Parent window VLC object */
46     HWND                 hparent;             /* Handle of the parent window */
47     HWND                 hfswnd;          /* Handle of the fullscreen window */
48
49     /* size of the display */
50     RECT         rect_display;
51     int          display_depth;
52
53     /* size of the overall window (including black bands) */
54     RECT         rect_parent;
55
56     unsigned changes;        /* changes made to the video display */
57
58     /* Misc */
59     bool is_first_display;
60     bool is_on_top;
61
62     /* screensaver system settings to be restored when vout is closed */
63     UINT i_spi_screensaveactive;
64
65     /* Coordinates of src and dest images (used when blitting to display) */
66     RECT         rect_src;
67     RECT         rect_src_clipped;
68     RECT         rect_dest;
69     RECT         rect_dest_clipped;
70
71     picture_pool_t *pool;
72
73 #ifdef MODULE_NAME_IS_directdraw
74     /* Multi-monitor support */
75     HMONITOR             hmonitor;          /* handle of the current monitor */
76     GUID                 *display_driver;
77
78     /* Overlay alignment restrictions */
79     int          i_align_src_boundary;
80     int          i_align_src_size;
81     int          i_align_dest_boundary;
82     int          i_align_dest_size;
83
84     bool   use_wallpaper;   /* show as desktop wallpaper ? */
85
86     bool   use_overlay;     /* Are we using an overlay surface */
87     bool   restore_overlay;
88
89     /* DDraw capabilities */
90     bool            can_blit_fourcc;
91
92     uint32_t        i_rgb_colorkey;      /* colorkey in RGB used by the overlay */
93     uint32_t        i_colorkey;                 /* colorkey used by the overlay */
94
95     COLORREF        color_bkg;
96     COLORREF        color_bkgtxt;
97
98     LPDIRECTDRAW2        ddobject;                    /* DirectDraw object */
99     LPDIRECTDRAWSURFACE2 display;                        /* Display device */
100     LPDIRECTDRAWCLIPPER  clipper;             /* clipper used for blitting */
101     HINSTANCE            hddraw_dll;       /* handle of the opened ddraw dll */
102
103     picture_resource_t   resource;
104
105     /* It protects the following variables */
106     vlc_mutex_t    lock;
107     bool           ch_wallpaper;
108     bool           wallpaper_requested;
109 #endif
110
111 #ifdef MODULE_NAME_IS_glwin32
112     HDC                   hGLDC;
113     HGLRC                 hGLRC;
114     vlc_gl_t              gl;
115     vout_display_opengl_t *vgl;
116 #endif
117
118 #ifdef MODULE_NAME_IS_direct2d
119     HINSTANCE              d2_dll;            /* handle of the opened d2d1 dll */
120     ID2D1Factory           *d2_factory;                         /* D2D factory */
121     ID2D1HwndRenderTarget  *d2_render_target;          /* D2D rendering target */
122     ID2D1Bitmap            *d2_bitmap;                            /* D2 bitmap */
123 #endif
124
125 #ifdef MODULE_NAME_IS_direct3d
126     bool allow_hw_yuv;    /* Should we use hardware YUV->RGB conversions */
127     /* show video on desktop window ? */
128     bool use_desktop;
129     struct {
130         bool is_fullscreen;
131         bool is_on_top;
132         RECT win;
133     } desktop_save;
134     vout_display_cfg_t cfg_saved; /* configuration used before going into desktop mode */
135
136     // core objects
137     HINSTANCE               hd3d9_dll;       /* handle of the opened d3d9 dll */
138     LPDIRECT3D9             d3dobj;
139     D3DCAPS9                d3dcaps;
140     LPDIRECT3DDEVICE9       d3ddev;
141     D3DPRESENT_PARAMETERS   d3dpp;
142     // scene objects
143     LPDIRECT3DTEXTURE9      d3dtex;
144     LPDIRECT3DVERTEXBUFFER9 d3dvtc;
145     D3DFORMAT               d3dregion_format;
146     int                     d3dregion_count;
147     struct d3d_region_t     *d3dregion;
148
149     picture_sys_t           *picsys;
150
151     /* */
152     bool                    reset_device;
153     bool                    reopen_device;
154     bool                    clear_scene;
155
156     /* It protects the following variables */
157     vlc_mutex_t    lock;
158     bool           ch_desktop;
159     bool           desktop_requested;
160 #endif
161
162 #if defined(MODULE_NAME_IS_wingdi)
163     int  i_depth;
164
165     /* Our offscreen bitmap and its framebuffer */
166     HDC        off_dc;
167     HBITMAP    off_bitmap;
168
169     struct
170     {
171         BITMAPINFO bitmapinfo;
172         RGBQUAD    red;
173         RGBQUAD    green;
174         RGBQUAD    blue;
175     };
176 #endif
177 };
178
179 /*****************************************************************************
180  * Prototypes from common.c
181  *****************************************************************************/
182 int  CommonInit(vout_display_t *);
183 void CommonClean(vout_display_t *);
184 void CommonManage(vout_display_t *);
185 int  CommonControl(vout_display_t *, int , va_list );
186 void CommonDisplay(vout_display_t *);
187 int  CommonUpdatePicture(picture_t *, picture_t **, uint8_t *, unsigned);
188
189 void UpdateRects (vout_display_t *,
190                   const vout_display_cfg_t *,
191                   const video_format_t *,
192                   bool is_forced);
193 void AlignRect(RECT *, int align_boundary, int align_size);
194
195 /*****************************************************************************
196  * Constants
197  *****************************************************************************/
198 #define IDM_TOGGLE_ON_TOP WM_USER + 1
199 #define DX_POSITION_CHANGE 0x1000
200 #define DX_WALLPAPER_CHANGE 0x2000
201 #define DX_DESKTOP_CHANGE 0x4000