Add a desktop mode to the Direct3d video output. This allow displaying video on a...
[vlc.git] / modules / video_output / msw / vout.h
index 05b4afb..be29493 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * vout.h: Windows video output header file
  *****************************************************************************
- * Copyright (C) 2001-2004 the VideoLAN team
+ * Copyright (C) 2001-2009 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
@@ -30,9 +30,46 @@ typedef struct event_thread_t
     VLC_COMMON_MEMBERS
 
     vout_thread_t * p_vout;
+    HANDLE window_ready;
 
 } event_thread_t;
 
+#ifdef MODULE_NAME_IS_wingapi
+    typedef struct GXDisplayProperties {
+        DWORD cxWidth;
+        DWORD cyHeight;
+        long cbxPitch;
+        long cbyPitch;
+        long cBPP;
+        DWORD ffFormat;
+    } GXDisplayProperties;
+
+    typedef struct GXScreenRect {
+        DWORD dwTop;
+        DWORD dwLeft;
+        DWORD dwWidth;
+        DWORD dwHeight;
+    } GXScreenRect;
+
+#   define GX_FULLSCREEN    0x01
+#   define GX_NORMALKEYS    0x02
+#   define GX_LANDSCAPEKEYS 0x03
+
+#   ifndef kfLandscape
+#       define kfLandscape      0x8
+#       define kfPalette        0x10
+#       define kfDirect         0x20
+#       define kfDirect555      0x40
+#       define kfDirect565      0x80
+#       define kfDirect888      0x100
+#       define kfDirect444      0x200
+#       define kfDirectInverted 0x400
+#   endif
+
+#endif
+
+struct vout_window_t;
+
 /*****************************************************************************
  * vout_sys_t: video output method descriptor
  *****************************************************************************
@@ -43,6 +80,7 @@ struct vout_sys_t
 {
     HWND                 hwnd;                  /* Handle of the main window */
     HWND                 hvideownd;        /* Handle of the video sub-window */
+    struct vout_window_t *parent_window;         /* Parent window VLC object */
     HWND                 hparent;             /* Handle of the parent window */
     HWND                 hfswnd;          /* Handle of the fullscreen window */
     WNDPROC              pf_wndproc;             /* Window handling callback */
@@ -70,11 +108,12 @@ struct vout_sys_t
     volatile uint16_t i_changes;        /* changes made to the video display */
 
     /* Mouse */
-    volatile vlc_bool_t b_cursor_hidden;
+    volatile bool b_cursor_hidden;
     volatile mtime_t    i_lastmoved;
+    mtime_t             i_mouse_hide_timeout;
 
     /* Misc */
-    vlc_bool_t      b_on_top_change;
+    bool      b_on_top_change;
 
 #ifndef UNDER_CE
 
@@ -91,21 +130,21 @@ struct vout_sys_t
     RECT         rect_dest;
     RECT         rect_dest_clipped;
 
-    vlc_bool_t   b_hw_yuv;    /* Should we use hardware YUV->RGB conversions */
+    bool   b_hw_yuv;    /* Should we use hardware YUV->RGB conversions */
 
 
-#ifdef MODULE_NAME_IS_vout_directx
+#ifdef MODULE_NAME_IS_directx
     /* Overlay alignment restrictions */
     int          i_align_src_boundary;
     int          i_align_src_size;
     int          i_align_dest_boundary;
     int          i_align_dest_size;
 
-    vlc_bool_t      b_wallpaper;    /* show as desktop wallpaper ? */
+    bool      b_wallpaper;    /* show as desktop wallpaper ? */
 
-    vlc_bool_t   b_using_overlay;         /* Are we using an overlay surface */
-    vlc_bool_t   b_use_sysmem;   /* Should we use system memory for surfaces */
-    vlc_bool_t   b_3buf_overlay;   /* Should we use triple buffered overlays */
+    bool   b_using_overlay;         /* Are we using an overlay surface */
+    bool   b_use_sysmem;   /* Should we use system memory for surfaces */
+    bool   b_3buf_overlay;   /* Should we use triple buffered overlays */
 
     /* DDraw capabilities */
     int          b_caps_overlay_clipping;
@@ -129,6 +168,9 @@ struct vout_sys_t
 #endif
 
 #ifdef MODULE_NAME_IS_direct3d
+    /* show video on desktop window ? */
+    bool      b_desktop;
+
     // core objects
     HINSTANCE               hd3d9_dll;       /* handle of the opened d3d9 dll */
     LPDIRECT3D9             p_d3dobj;
@@ -160,11 +202,22 @@ struct vout_sys_t
     int        i_depth;
     int        render_width;
     int        render_height;
+           /* Our offscreen bitmap and its framebuffer */
+    HDC        off_dc;
+    HBITMAP    off_bitmap;
+    uint8_t *  p_pic_buffer;
+    int        i_pic_pitch;
+    int        i_pic_pixel_pitch;
 
-    vlc_bool_t b_focus;
-    vlc_bool_t b_parent_focus;
+    BITMAPINFO bitmapinfo;
+    RGBQUAD    red;
+    RGBQUAD    green;
+    RGBQUAD    blue;
 
-    HINSTANCE  gapi_dll;                    /* handle of the opened gapi dll */
+    bool b_focus;
+    bool b_parent_focus;
+
+    HINSTANCE  gapi_dll;                   /* handle of the opened gapi dll */
 
     /* GAPI functions */
     int (*GXOpenDisplay)( HWND hWnd, DWORD dwFlags );
@@ -178,13 +231,23 @@ struct vout_sys_t
 
 #ifndef UNDER_CE
     /* suspend display */
-    vlc_bool_t   b_suspend_display;
+    bool   b_suspend_display;
 #endif
 
     event_thread_t *p_event;
     vlc_mutex_t    lock;
 };
 
+#ifdef MODULE_NAME_IS_wingapi
+#   define GXOpenDisplay p_vout->p_sys->GXOpenDisplay
+#   define GXCloseDisplay p_vout->p_sys->GXCloseDisplay
+#   define GXBeginDraw p_vout->p_sys->GXBeginDraw
+#   define GXEndDraw p_vout->p_sys->GXEndDraw
+#   define GXGetDisplayProperties p_vout->p_sys->GXGetDisplayProperties
+#   define GXSuspend p_vout->p_sys->GXSuspend
+#   define GXResume p_vout->p_sys->GXResume
+#endif
+
 /*****************************************************************************
  * Prototypes from directx.c
  *****************************************************************************/
@@ -193,9 +256,13 @@ int DirectDrawUpdateOverlay( vout_thread_t *p_vout );
 /*****************************************************************************
  * Prototypes from events.c
  *****************************************************************************/
-void E_(EventThread) ( event_thread_t *p_event );
-void E_(UpdateRects) ( vout_thread_t *p_vout, vlc_bool_t b_force );
+void* EventThread ( vlc_object_t *p_this );
+void UpdateRects ( vout_thread_t *p_vout, bool b_force );
 void Win32ToggleFullscreen ( vout_thread_t *p_vout );
+void DisableScreensaver ( vout_thread_t *p_vout );
+void RestoreScreensaver ( vout_thread_t *p_vout );
+int CreateEventThread( vout_thread_t *p_vout );
+void StopEventThread ( vout_thread_t *p_vout );
 
 /*****************************************************************************
  * Constants
@@ -206,6 +273,9 @@ void Win32ToggleFullscreen ( vout_thread_t *p_vout );
 #define IDM_TOGGLE_ON_TOP WM_USER + 1
 #define DX_POSITION_CHANGE 0x1000
 #define DX_WALLPAPER_CHANGE 0x2000
+#define DX_DESKTOP_CHANGE 0x4000
+#define EVENT_THREAD_ENDED 0x6000
+#define SWITCHING_MODE_FLAG 0x8000
 
 /*****************************************************************************
  * WinCE helpers
@@ -218,18 +288,18 @@ void Win32ToggleFullscreen ( vout_thread_t *p_vout );
 #   define GCL_HBRBACKGROUND (-10)
 #endif
 
-#define FindWindowEx(a,b,c,d) 0
+//#define FindWindowEx(a,b,c,d) 0
 
 #define GetWindowPlacement(a,b)
 #define SetWindowPlacement(a,b)
-typedef struct _WINDOWPLACEMENT {
+/*typedef struct _WINDOWPLACEMENT {
     UINT length;
     UINT flags;
     UINT showCmd;
     POINT ptMinPosition;
     POINT ptMaxPosition;
     RECT rcNormalPosition;
-} WINDOWPLACEMENT;
+} WINDOWPLACEMENT;*/
 
 #ifndef WM_NCMOUSEMOVE
 #   define WM_NCMOUSEMOVE 160
@@ -256,8 +326,8 @@ typedef struct _WINDOWPLACEMENT {
 #define WS_EX_APPWINDOW 0x40000
 #endif
 
-#define SetWindowLongPtr SetWindowLong
-#define GetWindowLongPtr GetWindowLong
-#define GWLP_USERDATA GWL_USERDATA
+//#define SetWindowLongPtr SetWindowLong
+//#define GetWindowLongPtr GetWindowLong
+//#define GWLP_USERDATA GWL_USERDATA
 
 #endif //UNDER_CE