[vlc-commits] direct3d11: hide the local swapchain structure from the display module

Steve Lhomme git at videolan.org
Wed Jun 5 17:45:18 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jun  5 17:16:25 2019 +0200| [0e902db1f3a92c0076ca50753fe3b9952cdc9731] | committer: Steve Lhomme

direct3d11: hide the local swapchain structure from the display module

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0e902db1f3a92c0076ca50753fe3b9952cdc9731
---

 modules/video_output/win32/d3d11_swapchain.c | 37 +++++++++++++++++++++++++++-
 modules/video_output/win32/d3d11_swapchain.h | 22 +----------------
 modules/video_output/win32/direct3d11.c      | 14 +++--------
 3 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/modules/video_output/win32/d3d11_swapchain.c b/modules/video_output/win32/d3d11_swapchain.c
index 9d08fbaed6..f4c8eec607 100644
--- a/modules/video_output/win32/d3d11_swapchain.c
+++ b/modules/video_output/win32/d3d11_swapchain.c
@@ -46,13 +46,14 @@
 #endif
 
 #include "d3d11_swapchain.h"
+#include "d3d11_shaders.h"
 
 typedef enum video_color_axis {
     COLOR_AXIS_RGB,
     COLOR_AXIS_YCBCR,
 } video_color_axis;
 
-typedef struct dxgi_color_space {
+typedef struct {
     DXGI_COLOR_SPACE_TYPE   dxgi;
     const char              *name;
     video_color_axis        axis;
@@ -62,6 +63,26 @@ typedef struct dxgi_color_space {
     bool                    b_full_range;
 } dxgi_color_space;
 
+struct d3d11_local_swapchain
+{
+    vlc_object_t           *obj;
+    d3d11_handle_t         *hd3d;
+    d3d11_device_t         d3d_dev;
+
+    const d3d_format_t     *pixelFormat;
+    const dxgi_color_space *colorspace;
+
+#if !VLC_WINSTORE_APP
+    HWND                   swapchainHwnd;
+#endif /* !VLC_WINSTORE_APP */
+    IDXGISwapChain1        *dxgiswapChain;   /* DXGI 1.2 swap chain */
+    IDXGISwapChain4        *dxgiswapChain4;  /* DXGI 1.5 for HDR metadata */
+
+    ID3D11RenderTargetView *swapchainTargetView[D3D11_MAX_RENDER_TARGET];
+
+    bool                   logged_capabilities;
+};
+
 DEFINE_GUID(GUID_SWAPCHAIN_WIDTH,  0xf1b59347, 0x1643, 0x411a, 0xad, 0x6b, 0xc7, 0x80, 0x17, 0x7a, 0x06, 0xb6);
 DEFINE_GUID(GUID_SWAPCHAIN_HEIGHT, 0x6ea976a0, 0x9d60, 0x4bb7, 0xa5, 0xa9, 0x7d, 0xd1, 0x18, 0x7f, 0xc9, 0xbd);
 
@@ -539,3 +560,17 @@ bool LocalSwapchainSelectPlane( void *opaque, size_t plane )
                                             &display->swapchainTargetView[plane], NULL);
     return true;
 }
+
+void *CreateLocalSwapchainHandle(vlc_object_t *o, d3d11_handle_t *hd3d, HWND hwnd)
+{
+    struct d3d11_local_swapchain *display = vlc_obj_calloc(o, 1, sizeof(*display));
+    if (likely(display != NULL))
+    {
+        display->obj = o;
+        display->hd3d = hd3d;
+#if !VLC_WINSTORE_APP
+        display->swapchainHwnd = hwnd;
+#endif /* !VLC_WINSTORE_APP */
+    }
+    return display;
+}
diff --git a/modules/video_output/win32/d3d11_swapchain.h b/modules/video_output/win32/d3d11_swapchain.h
index 74c2fc21a0..f6a4d15201 100644
--- a/modules/video_output/win32/d3d11_swapchain.h
+++ b/modules/video_output/win32/d3d11_swapchain.h
@@ -25,29 +25,9 @@
 #define VLC_D3D11_SWAPCHAIN_H
 
 #include <vlc_common.h>
-
 #include "../../video_chroma/d3d11_fmt.h"
-#include "d3d11_shaders.h"
-
-struct d3d11_local_swapchain
-{
-    vlc_object_t           *obj;
-    d3d11_handle_t         *hd3d;
-    d3d11_device_t         d3d_dev;
-
-    const d3d_format_t     *pixelFormat;
-    const struct dxgi_color_space *colorspace;
-
-#if !VLC_WINSTORE_APP
-    HWND                   swapchainHwnd;
-#endif /* !VLC_WINSTORE_APP */
-    IDXGISwapChain1        *dxgiswapChain;   /* DXGI 1.2 swap chain */
-    IDXGISwapChain4        *dxgiswapChain4;  /* DXGI 1.5 for HDR metadata */
-
-    ID3D11RenderTargetView *swapchainTargetView[D3D11_MAX_RENDER_TARGET];
 
-    bool                   logged_capabilities;
-};
+void *CreateLocalSwapchainHandle(vlc_object_t *, d3d11_handle_t *, HWND);
 
 bool LocalSwapchainSetupDevice( void **opaque, const libvlc_video_direct3d_device_cfg_t *cfg, libvlc_video_direct3d_device_setup_t *out );
 void LocalSwapchainCleanupDevice( void *opaque );
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index a7fe0e259d..42a8e1326a 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -46,11 +46,6 @@
 #define COBJMACROS
 #include <initguid.h>
 #include <d3d11.h>
-#ifdef HAVE_DXGI1_6_H
-# include <dxgi1_6.h>
-#else
-# include <dxgi1_5.h>
-#endif
 
 /* avoided until we can pass ISwapchainPanel without c++/cx mode
 # include <windows.ui.xaml.media.dxinterop.h> */
@@ -110,8 +105,6 @@ struct vout_display_sys_t
     picture_sys_t            stagingSys;
     picture_pool_t           *pool; /* hardware decoding pool */
 
-    struct d3d11_local_swapchain internal_swapchain; /* TODO do not access fields directly */
-
     d3d_vshader_t            projectionVShader;
     d3d_vshader_t            flatVShader;
 
@@ -347,13 +340,12 @@ static int Open(vout_display_t *vd, const vout_display_cfg_t *cfg,
         if (CommonWindowInit(VLC_OBJECT(vd), &sys->area, &sys->sys,
                        vd->source.projection_mode != PROJECTION_MODE_RECTANGULAR))
             goto error;
-        sys->internal_swapchain.swapchainHwnd = sys->sys.hvideownd;
 #endif /* !VLC_WINSTORE_APP */
 
         /* use our internal swapchain callbacks */
-        sys->internal_swapchain.obj = VLC_OBJECT(vd);
-        sys->internal_swapchain.hd3d =  &sys->hd3d;
-        sys->outside_opaque = &sys->internal_swapchain;
+        sys->outside_opaque      = CreateLocalSwapchainHandle(VLC_OBJECT(vd), &sys->hd3d, sys->sys.hvideownd);
+        if (unlikely(sys->outside_opaque == NULL))
+            goto error;
         sys->setupDeviceCb       = LocalSwapchainSetupDevice;
         sys->cleanupDeviceCb     = LocalSwapchainCleanupDevice;
         sys->updateOutputCb      = LocalSwapchainUpdateOutput;



More information about the vlc-commits mailing list