Henri Verbeet : d3d8: Get rid of IDirect3DBaseTexture8Impl.

Alexandre Julliard julliard at winehq.org
Thu Apr 19 13:27:51 CDT 2012


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed Apr 18 20:51:26 2012 +0200

d3d8: Get rid of IDirect3DBaseTexture8Impl.

---

 dlls/d3d8/buffer.c       |    1 -
 dlls/d3d8/d3d8_private.h |   19 ++-----------------
 dlls/d3d8/device.c       |   20 +++++++++++++-------
 dlls/d3d8/surface.c      |    1 -
 dlls/d3d8/texture.c      |   10 ++++++++++
 5 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/dlls/d3d8/buffer.c b/dlls/d3d8/buffer.c
index 4ab6524..9ff787d 100644
--- a/dlls/d3d8/buffer.c
+++ b/dlls/d3d8/buffer.c
@@ -17,7 +17,6 @@
  */
 
 #include "config.h"
-#include <assert.h>
 #include "d3d8_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h
index 49f2bdd..b963abe 100644
--- a/dlls/d3d8/d3d8_private.h
+++ b/dlls/d3d8/d3d8_private.h
@@ -23,6 +23,7 @@
 #ifndef __WINE_D3D8_PRIVATE_H
 #define __WINE_D3D8_PRIVATE_H
 
+#include <assert.h>
 #include <stdarg.h>
 
 #define NONAMELESSUNION
@@ -293,21 +294,6 @@ HRESULT indexbuffer_init(IDirect3DIndexBuffer8Impl *buffer, IDirect3DDevice8Impl
         UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN;
 IDirect3DIndexBuffer8Impl *unsafe_impl_from_IDirect3DIndexBuffer8(IDirect3DIndexBuffer8 *iface) DECLSPEC_HIDDEN;
 
-/* --------------------- */
-/* IDirect3DBaseTexture8 */
-/* --------------------- */
-
-/*****************************************************************************
- * IDirect3DBaseTexture8 implementation structure
- */
-struct IDirect3DBaseTexture8Impl
-{
-    /* IUnknown fields */
-    const IDirect3DBaseTexture8Vtbl *lpVtbl;
-    LONG                   ref;
-    struct wined3d_texture *wined3d_texture;
-};
-
 struct d3d8_texture
 {
     IDirect3DBaseTexture8 IDirect3DBaseTexture8_iface;
@@ -318,12 +304,11 @@ struct d3d8_texture
 
 HRESULT cubetexture_init(struct d3d8_texture *texture, IDirect3DDevice8Impl *device,
         UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN;
-
 HRESULT texture_init(struct d3d8_texture *texture, IDirect3DDevice8Impl *device,
         UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN;
-
 HRESULT volumetexture_init(struct d3d8_texture *texture, IDirect3DDevice8Impl *device,
         UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN;
+struct d3d8_texture *unsafe_impl_from_IDirect3DBaseTexture8(IDirect3DBaseTexture8 *iface) DECLSPEC_HIDDEN;
 
 struct d3d8_vertex_declaration
 {
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index d0c85ec..ea2ce17 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -1032,14 +1032,17 @@ static HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(IDirect3DDevice8 *iface
         IDirect3DBaseTexture8 *src_texture, IDirect3DBaseTexture8 *dst_texture)
 {
     IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+    struct d3d8_texture *src_impl, *dst_impl;
     HRESULT hr;
 
     TRACE("iface %p, src_texture %p, dst_texture %p.\n", iface, src_texture, dst_texture);
 
+    src_impl = unsafe_impl_from_IDirect3DBaseTexture8(src_texture);
+    dst_impl = unsafe_impl_from_IDirect3DBaseTexture8(dst_texture);
+
     wined3d_mutex_lock();
     hr = wined3d_device_update_texture(This->wined3d_device,
-            ((IDirect3DBaseTexture8Impl *)src_texture)->wined3d_texture,
-            ((IDirect3DBaseTexture8Impl *)dst_texture)->wined3d_texture);
+            src_impl->wined3d_texture, dst_impl->wined3d_texture);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1732,17 +1735,20 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(IDirect3DDevice8 *iface,
     return D3D_OK;
 }
 
-static HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(IDirect3DDevice8 *iface, DWORD Stage,
-        IDirect3DBaseTexture8 *pTexture)
+static HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(IDirect3DDevice8 *iface, DWORD stage,
+        IDirect3DBaseTexture8 *texture)
 {
     IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+    struct d3d8_texture *texture_impl;
     HRESULT hr;
 
-    TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, pTexture);
+    TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
+
+    texture_impl = unsafe_impl_from_IDirect3DBaseTexture8(texture);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_texture(This->wined3d_device, Stage,
-            pTexture ? ((IDirect3DBaseTexture8Impl *)pTexture)->wined3d_texture : NULL);
+    hr = wined3d_device_set_texture(This->wined3d_device, stage,
+            texture_impl ? texture_impl->wined3d_texture : NULL);
     wined3d_mutex_unlock();
 
     return hr;
diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c
index 316e0b8..7b887e3 100644
--- a/dlls/d3d8/surface.c
+++ b/dlls/d3d8/surface.c
@@ -19,7 +19,6 @@
  */
 
 #include "config.h"
-#include <assert.h>
 #include "d3d8_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c
index 700ee37..2720fe2 100644
--- a/dlls/d3d8/texture.c
+++ b/dlls/d3d8/texture.c
@@ -1137,6 +1137,16 @@ static const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl =
     d3d8_texture_3d_AddDirtyBox
 };
 
+struct d3d8_texture *unsafe_impl_from_IDirect3DBaseTexture8(IDirect3DBaseTexture8 *iface)
+{
+    if (!iface)
+        return NULL;
+    assert(iface->lpVtbl == (const IDirect3DBaseTexture8Vtbl *)&Direct3DTexture8_Vtbl
+            || iface->lpVtbl == (const IDirect3DBaseTexture8Vtbl *)&Direct3DCubeTexture8_Vtbl
+            || iface->lpVtbl == (const IDirect3DBaseTexture8Vtbl *)&Direct3DVolumeTexture8_Vtbl);
+    return CONTAINING_RECORD(iface, struct d3d8_texture, IDirect3DBaseTexture8_iface);
+}
+
 static void STDMETHODCALLTYPE d3d8_texture_wined3d_object_destroyed(void *parent)
 {
     HeapFree(GetProcessHeap(), 0, parent);




More information about the wine-cvs mailing list