[vlc-commits] d3d9: add a way to create d3d9_handle_t and d3d9_device_t from external resources

Steve Lhomme git at videolan.org
Thu Nov 15 14:20:02 CET 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Nov 15 11:39:07 2018 +0100| [c59315fdce976a266bf4c18b4b4c2b328a53502a] | committer: Steve Lhomme

d3d9: add a way to create d3d9_handle_t and d3d9_device_t from external resources

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

 modules/video_chroma/d3d9_fmt.c | 26 ++++++++++++++++++++++++++
 modules/video_chroma/d3d9_fmt.h |  4 ++++
 2 files changed, 30 insertions(+)

diff --git a/modules/video_chroma/d3d9_fmt.c b/modules/video_chroma/d3d9_fmt.c
index 553479e2e8..7ba9c108f9 100644
--- a/modules/video_chroma/d3d9_fmt.c
+++ b/modules/video_chroma/d3d9_fmt.c
@@ -130,6 +130,21 @@ HRESULT D3D9_CreateDevice(vlc_object_t *o, d3d9_handle_t *hd3d, HWND hwnd,
     return hr;
 }
 
+HRESULT D3D9_CreateDeviceExternal(IDirect3DDevice9 *dev, d3d9_handle_t *hd3d, HWND hwnd,
+                                  const video_format_t *source, d3d9_device_t *out)
+{
+
+    out->dev   = dev;
+    out->owner = false;
+    out->hwnd  = hwnd;
+    if (D3D9_FillPresentationParameters(hd3d, source, out))
+    {
+        return E_FAIL;
+    }
+    IDirect3DDevice9_AddRef(out->dev);
+    return S_OK;
+}
+
 void D3D9_ReleaseDevice(d3d9_device_t *d3d_dev)
 {
     if (d3d_dev->dev)
@@ -249,3 +264,14 @@ error:
     D3D9_Destroy( hd3d );
     return VLC_EGENERIC;
 }
+
+#undef D3D9_CreateExternal
+int D3D9_CreateExternal(vlc_object_t *o, d3d9_handle_t *hd3d, IDirect3DDevice9 *d3d9dev)
+{
+    HRESULT hr = IDirect3DDevice9_GetDirect3D(d3d9dev, &hd3d->obj);
+    if (FAILED(hr))
+        return VLC_EGENERIC;
+    hd3d->hdll = NULL;
+    hd3d->use_ex = false; /* we don't care */
+    return VLC_SUCCESS;
+}
diff --git a/modules/video_chroma/d3d9_fmt.h b/modules/video_chroma/d3d9_fmt.h
index 36336d4156..36231b27e5 100644
--- a/modules/video_chroma/d3d9_fmt.h
+++ b/modules/video_chroma/d3d9_fmt.h
@@ -94,10 +94,14 @@ static inline void ReleasePictureSys(picture_sys_t *p_sys)
 HRESULT D3D9_CreateDevice(vlc_object_t *, d3d9_handle_t *, HWND,
                           const video_format_t *, d3d9_device_t *out);
 #define D3D9_CreateDevice(a,b,c,d,e) D3D9_CreateDevice( VLC_OBJECT(a), b, c, d, e )
+HRESULT D3D9_CreateDeviceExternal(IDirect3DDevice9 *, d3d9_handle_t *, HWND,
+                                  const video_format_t *, d3d9_device_t *out);
 
 void D3D9_ReleaseDevice(d3d9_device_t *);
 int D3D9_Create(vlc_object_t *, d3d9_handle_t *);
 #define D3D9_Create(a,b) D3D9_Create( VLC_OBJECT(a), b )
+int D3D9_CreateExternal(vlc_object_t *, d3d9_handle_t *, IDirect3DDevice9 *);
+#define D3D9_CreateExternal(a,b,c) D3D9_CreateExternal( VLC_OBJECT(a), b, c )
 
 void D3D9_Destroy(d3d9_handle_t *);
 



More information about the vlc-commits mailing list