Michael Stefaniuc : d3d8: Use unsafe_impl_from_IDirect3DIndexBuffer8 for an app provided iface.

Alexandre Julliard julliard at winehq.org
Tue Jul 5 12:59:04 CDT 2011


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

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Tue Jul  5 00:43:50 2011 +0200

d3d8: Use unsafe_impl_from_IDirect3DIndexBuffer8 for an app provided iface.

---

 dlls/d3d8/buffer.c       |   10 ++++++++++
 dlls/d3d8/d3d8_private.h |    1 +
 dlls/d3d8/device.c       |    2 +-
 3 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/dlls/d3d8/buffer.c b/dlls/d3d8/buffer.c
index 6ca8829..cd68f6c 100644
--- a/dlls/d3d8/buffer.c
+++ b/dlls/d3d8/buffer.c
@@ -17,6 +17,7 @@
  */
 
 #include "config.h"
+#include <assert.h>
 #include "d3d8_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
@@ -571,3 +572,12 @@ HRESULT indexbuffer_init(IDirect3DIndexBuffer8Impl *buffer, IDirect3DDevice8Impl
 
     return D3D_OK;
 }
+
+IDirect3DIndexBuffer8Impl *unsafe_impl_from_IDirect3DIndexBuffer8(IDirect3DIndexBuffer8 *iface)
+{
+    if (!iface)
+        return NULL;
+    assert(iface->lpVtbl == &d3d8_indexbuffer_vtbl);
+
+    return impl_from_IDirect3DIndexBuffer8(iface);
+}
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h
index 0c0f2b1..e84b60a 100644
--- a/dlls/d3d8/d3d8_private.h
+++ b/dlls/d3d8/d3d8_private.h
@@ -298,6 +298,7 @@ struct IDirect3DIndexBuffer8Impl
 
 HRESULT indexbuffer_init(IDirect3DIndexBuffer8Impl *buffer, IDirect3DDevice8Impl *device,
         UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN;
+IDirect3DIndexBuffer8Impl *unsafe_impl_from_IDirect3DIndexBuffer8(IDirect3DIndexBuffer8 *iface) DECLSPEC_HIDDEN;
 
 /* --------------------- */
 /* IDirect3DBaseTexture8 */
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index dd45f1f..adae05e 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -2367,8 +2367,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(IDirect3DDevice8 *iface,
         IDirect3DIndexBuffer8 *pIndexData, UINT baseVertexIndex)
 {
     IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+    IDirect3DIndexBuffer8Impl *ib = unsafe_impl_from_IDirect3DIndexBuffer8(pIndexData);
     HRESULT hr;
-    IDirect3DIndexBuffer8Impl *ib = (IDirect3DIndexBuffer8Impl *)pIndexData;
 
     TRACE("iface %p, buffer %p, base_vertex_idx %u.\n", iface, pIndexData, baseVertexIndex);
 




More information about the wine-cvs mailing list