Michael Stefaniuc : d3d10core: COM cleanup for the ID3D10Texture2D iface.

Alexandre Julliard julliard at winehq.org
Wed Jun 1 12:11:06 CDT 2011


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

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Wed Jun  1 10:12:44 2011 +0200

d3d10core: COM cleanup for the ID3D10Texture2D iface.

---

 dlls/d3d10core/d3d10core_private.h |    2 +-
 dlls/d3d10core/device.c            |    8 ++++----
 dlls/d3d10core/texture.c           |   17 +++++++++++------
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h
index 8e3f490..0ddf7f3 100644
--- a/dlls/d3d10core/d3d10core_private.h
+++ b/dlls/d3d10core/d3d10core_private.h
@@ -84,7 +84,7 @@ void d3d10_device_init(struct d3d10_device *device, void *outer_unknown) DECLSPE
 /* ID3D10Texture2D */
 struct d3d10_texture2d
 {
-    const struct ID3D10Texture2DVtbl *vtbl;
+    ID3D10Texture2D ID3D10Texture2D_iface;
     LONG refcount;
 
     IUnknown *dxgi_surface;
diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index 379ad7d..9ac8638 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -681,7 +681,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *ifac
         return hr;
     }
 
-    *texture = (ID3D10Texture2D *)object;
+    *texture = &object->ID3D10Texture2D_iface;
 
     TRACE("Created ID3D10Texture2D %p\n", object);
 
@@ -1380,7 +1380,7 @@ static HRESULT CDECL device_parent_create_surface(struct wined3d_device_parent *
 
     *surface = texture->wined3d_surface;
     wined3d_surface_incref(*surface);
-    ID3D10Texture2D_Release((ID3D10Texture2D *)texture);
+    ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
 
     return S_OK;
 }
@@ -1423,7 +1423,7 @@ static HRESULT CDECL device_parent_create_rendertarget(struct wined3d_device_par
 
     *surface = texture->wined3d_surface;
     wined3d_surface_incref(*surface);
-    ID3D10Texture2D_Release((ID3D10Texture2D *)texture);
+    ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
 
     return S_OK;
 }
@@ -1464,7 +1464,7 @@ static HRESULT CDECL device_parent_create_depth_stencil(struct wined3d_device_pa
 
     *surface = texture->wined3d_surface;
     wined3d_surface_incref(*surface);
-    ID3D10Texture2D_Release((ID3D10Texture2D *)texture);
+    ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
 
     return S_OK;
 }
diff --git a/dlls/d3d10core/texture.c b/dlls/d3d10core/texture.c
index 191df00..0f8d750 100644
--- a/dlls/d3d10core/texture.c
+++ b/dlls/d3d10core/texture.c
@@ -24,11 +24,16 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
 
+static inline struct d3d10_texture2d *impl_from_ID3D10Texture2D(ID3D10Texture2D *iface)
+{
+    return CONTAINING_RECORD(iface, struct d3d10_texture2d, ID3D10Texture2D_iface);
+}
+
 /* IUnknown methods */
 
 static HRESULT STDMETHODCALLTYPE d3d10_texture2d_QueryInterface(ID3D10Texture2D *iface, REFIID riid, void **object)
 {
-    struct d3d10_texture2d *This = (struct d3d10_texture2d *)iface;
+    struct d3d10_texture2d *This = impl_from_ID3D10Texture2D(iface);
 
     TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
 
@@ -56,7 +61,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture2d_QueryInterface(ID3D10Texture2D
 
 static ULONG STDMETHODCALLTYPE d3d10_texture2d_AddRef(ID3D10Texture2D *iface)
 {
-    struct d3d10_texture2d *This = (struct d3d10_texture2d *)iface;
+    struct d3d10_texture2d *This = impl_from_ID3D10Texture2D(iface);
     ULONG refcount = InterlockedIncrement(&This->refcount);
 
     TRACE("%p increasing refcount to %u\n", This, refcount);
@@ -77,7 +82,7 @@ static void STDMETHODCALLTYPE d3d10_texture2d_wined3d_object_released(void *pare
 
 static ULONG STDMETHODCALLTYPE d3d10_texture2d_Release(ID3D10Texture2D *iface)
 {
-    struct d3d10_texture2d *This = (struct d3d10_texture2d *)iface;
+    struct d3d10_texture2d *This = impl_from_ID3D10Texture2D(iface);
     ULONG refcount = InterlockedDecrement(&This->refcount);
 
     TRACE("%p decreasing refcount to %u\n", This, refcount);
@@ -166,7 +171,7 @@ static void STDMETHODCALLTYPE d3d10_texture2d_Unmap(ID3D10Texture2D *iface, UINT
 
 static void STDMETHODCALLTYPE d3d10_texture2d_GetDesc(ID3D10Texture2D *iface, D3D10_TEXTURE2D_DESC *desc)
 {
-    struct d3d10_texture2d *This = (struct d3d10_texture2d *)iface;
+    struct d3d10_texture2d *This = impl_from_ID3D10Texture2D(iface);
 
     TRACE("iface %p, desc %p\n", iface, desc);
 
@@ -204,7 +209,7 @@ HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_devic
 {
     HRESULT hr;
 
-    texture->vtbl = &d3d10_texture2d_vtbl;
+    texture->ID3D10Texture2D_iface.lpVtbl = &d3d10_texture2d_vtbl;
     texture->refcount = 1;
     texture->desc = *desc;
 
@@ -220,7 +225,7 @@ HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_devic
         }
 
         hr = IWineDXGIDevice_create_surface(wine_device, NULL, 0, NULL,
-                (IUnknown *)texture, (void **)&texture->dxgi_surface);
+                (IUnknown *)&texture->ID3D10Texture2D_iface, (void **)&texture->dxgi_surface);
         IWineDXGIDevice_Release(wine_device);
         if (FAILED(hr))
         {




More information about the wine-cvs mailing list