Henri Verbeet : d3d10core: Allow ID3D10Device to be aggregated.

Alexandre Julliard julliard at winehq.org
Thu Nov 13 08:51:38 CST 2008


Module: wine
Branch: master
Commit: ed418dc815120264672221a76e577b45dbf7685e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ed418dc815120264672221a76e577b45dbf7685e

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed Nov 12 15:43:46 2008 +0100

d3d10core: Allow ID3D10Device to be aggregated.

---

 dlls/d3d10core/d3d10core_private.h |    3 ++
 dlls/d3d10core/device.c            |   54 ++++++++++++++++++++++++++++++-----
 2 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h
index 0eea663..a3e2755 100644
--- a/dlls/d3d10core/d3d10core_private.h
+++ b/dlls/d3d10core/d3d10core_private.h
@@ -34,9 +34,12 @@ const char *debug_dxgi_format(DXGI_FORMAT format);
 
 /* IDirect3D10Device */
 extern const struct ID3D10DeviceVtbl d3d10_device_vtbl;
+extern const struct IUnknownVtbl d3d10_device_inner_unkown_vtbl;
 struct d3d10_device
 {
     const struct ID3D10DeviceVtbl *vtbl;
+    const struct IUnknownVtbl *inner_unknown_vtbl;
+    IUnknown *outer_unknown;
     LONG refcount;
 };
 
diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index a0cf37c..ab92c47 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -24,17 +24,24 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
 
-/* IUnknown methods */
+/* Inner IUnknown methods */
 
-static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device *iface, REFIID riid, void **object)
+static inline struct d3d10_device *d3d10_device_from_inner_unknown(IUnknown *iface)
+{
+    return (struct d3d10_device *)((char*)iface - FIELD_OFFSET(struct d3d10_device, inner_unknown_vtbl));
+}
+
+static HRESULT STDMETHODCALLTYPE d3d10_device_inner_QueryInterface(IUnknown *iface, REFIID riid, void **object)
 {
+    struct d3d10_device *This = d3d10_device_from_inner_unknown(iface);
+
     TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
 
     if (IsEqualGUID(riid, &IID_IUnknown)
             || IsEqualGUID(riid, &IID_ID3D10Device))
     {
-        IUnknown_AddRef(iface);
-        *object = iface;
+        IUnknown_AddRef((IUnknown *)This);
+        *object = This;
         return S_OK;
     }
 
@@ -44,9 +51,9 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device *iface
     return E_NOINTERFACE;
 }
 
-static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device *iface)
+static ULONG STDMETHODCALLTYPE d3d10_device_inner_AddRef(IUnknown *iface)
 {
-    struct d3d10_device *This = (struct d3d10_device *)iface;
+    struct d3d10_device *This = d3d10_device_from_inner_unknown(iface);
     ULONG refcount = InterlockedIncrement(&This->refcount);
 
     TRACE("%p increasing refcount to %u\n", This, refcount);
@@ -54,9 +61,9 @@ static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device *iface)
     return refcount;
 }
 
-static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device *iface)
+static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
 {
-    struct d3d10_device *This = (struct d3d10_device *)iface;
+    struct d3d10_device *This = d3d10_device_from_inner_unknown(iface);
     ULONG refcount = InterlockedDecrement(&This->refcount);
 
     TRACE("%p decreasing refcount to %u\n", This, refcount);
@@ -64,6 +71,29 @@ static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device *iface)
     return refcount;
 }
 
+/* IUnknown methods */
+
+static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device *iface, REFIID riid, void **object)
+{
+    struct d3d10_device *This = (struct d3d10_device *)iface;
+    TRACE("Forwarding to outer IUnknown\n");
+    return IUnknown_QueryInterface(This->outer_unknown, riid, object);
+}
+
+static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device *iface)
+{
+    struct d3d10_device *This = (struct d3d10_device *)iface;
+    TRACE("Forwarding to outer IUnknown\n");
+    return IUnknown_AddRef(This->outer_unknown);
+}
+
+static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device *iface)
+{
+    struct d3d10_device *This = (struct d3d10_device *)iface;
+    TRACE("Forwarding to outer IUnknown\n");
+    return IUnknown_Release(This->outer_unknown);
+}
+
 /* ID3D10Device methods */
 
 static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device *iface,
@@ -845,3 +875,11 @@ const struct ID3D10DeviceVtbl d3d10_device_vtbl =
     d3d10_device_SetTextFilterSize,
     d3d10_device_GetTextFilterSize,
 };
+
+const struct IUnknownVtbl d3d10_device_inner_unkown_vtbl =
+{
+    /* IUnknown methods */
+    d3d10_device_inner_QueryInterface,
+    d3d10_device_inner_AddRef,
+    d3d10_device_inner_Release,
+};




More information about the wine-cvs mailing list