Markus Amsler : d3d8: Handle surface container in d3d8.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Dec 18 05:34:41 CST 2006


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

Author: Markus Amsler <markus.amsler at oribi.org>
Date:   Mon Dec 18 00:17:38 2006 +0100

d3d8: Handle surface container in d3d8.

---

 dlls/d3d8/d3d8_private.h |    3 +++
 dlls/d3d8/device.c       |    1 +
 dlls/d3d8/directx.c      |    2 ++
 dlls/d3d8/surface.c      |   39 ++++-----------------------------------
 dlls/d3d8/tests/device.c |    4 ++--
 5 files changed, 12 insertions(+), 37 deletions(-)

diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h
index fd07053..be27401 100644
--- a/dlls/d3d8/d3d8_private.h
+++ b/dlls/d3d8/d3d8_private.h
@@ -253,6 +253,9 @@ struct IDirect3DSurface8Impl
     /* Parent reference */
     LPDIRECT3DDEVICE8                  parentDevice;
 
+    /* The surface container */
+    IUnknown                    *container;
+
     /* If set forward refcounting to this object */
     IUnknown                    *forwardReference;
 
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 78c469b..3faf807 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -1624,6 +1624,7 @@ HRESULT WINAPI D3D8CB_CreateSurface(IUnk
 
     if (SUCCEEDED(res)) {
         *ppSurface = d3dSurface->wineD3DSurface;
+        d3dSurface->container = pSuperior;
         IUnknown_Release(d3dSurface->parentDevice);
         d3dSurface->parentDevice = NULL;
         d3dSurface->forwardReference = pSuperior;
diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c
index 410107e..c3d0679 100644
--- a/dlls/d3d8/directx.c
+++ b/dlls/d3d8/directx.c
@@ -200,6 +200,7 @@ HRESULT WINAPI D3D8CB_CreateRenderTarget
 
     if (SUCCEEDED(res)) {
         *ppSurface = d3dSurface->wineD3DSurface;
+        d3dSurface->container = device;
         d3dSurface->isImplicit = TRUE;
         /* Implicit surfaces are created with an refcount of 0 */
         IUnknown_Release((IUnknown *)d3dSurface);
@@ -299,6 +300,7 @@ HRESULT WINAPI D3D8CB_CreateDepthStencil
                                          (D3DFORMAT)Format, MultiSample, (IDirect3DSurface8 **)&d3dSurface);
     if (SUCCEEDED(res)) {
         *ppSurface = d3dSurface->wineD3DSurface;
+        d3dSurface->container = device;
         d3dSurface->isImplicit = TRUE;
         /* Implicit surfaces are created with an refcount of 0 */
         IUnknown_Release((IUnknown *)d3dSurface);
diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c
index d834460..93ea2f5 100644
--- a/dlls/d3d8/surface.c
+++ b/dlls/d3d8/surface.c
@@ -113,45 +113,14 @@ static HRESULT WINAPI IDirect3DSurface8I
 static HRESULT WINAPI IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface, REFIID riid, void **ppContainer) {
     IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
     HRESULT res;
-    IUnknown *IWineContainer = NULL;
 
     TRACE("(%p) Relay\n", This);
 
-    /* The container returned from IWineD3DSurface_GetContainer is either an IWineD3DDevice,
-       one of the subclasses of IWineD3DBaseTexture or an IWineD3DSwapChain  */
-    /* Get the IUnknown container. */
-    res = IWineD3DSurface_GetContainer(This->wineD3DSurface, &IID_IUnknown, (void **)&IWineContainer);
-    if (res == D3D_OK && IWineContainer != NULL) {
-
-        /* Now find out what kind of container it is (so that we can get its parent)*/
-        IUnknown  *IUnknownParent = NULL;
-        IUnknown  *myContainer    = NULL;
-        if (D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DDevice, (void **)&myContainer)) {
-            IWineD3DDevice_GetParent((IWineD3DDevice *)IWineContainer, &IUnknownParent);
-            IUnknown_Release(myContainer);
-        } else 
-        if (D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DBaseTexture, (void **)&myContainer)) {
-            IWineD3DBaseTexture_GetParent((IWineD3DBaseTexture *)IWineContainer, &IUnknownParent);
-            IUnknown_Release(myContainer);
-        } else
-        if (D3D_OK == IUnknown_QueryInterface(IWineContainer, &IID_IWineD3DSwapChain, (void **)&myContainer)) {
-            IWineD3DSwapChain_GetParent((IWineD3DSwapChain *)IWineContainer, &IUnknownParent);
-            IUnknown_Release(myContainer);
-        } else {
-            FIXME("Container is of unknown interface\n");
-        }
-        /* Tidy up.. */
-        IUnknown_Release((IWineD3DDevice *)IWineContainer);
-
-        /* Now, query the interface of the parent for the riid */
-        if (IUnknownParent != NULL) {
-            res = IUnknown_QueryInterface(IUnknownParent, riid, ppContainer);
-            /* Tidy up.. */
-            IUnknown_Release(IUnknownParent);
-        }
-    }
+    if (!This->container) return E_NOINTERFACE;
+
+    res = IUnknown_QueryInterface(This->container, riid, ppContainer);
 
-    TRACE("(%p) : returning %p\n", This, *ppContainer);    
+    TRACE("(%p) : returning %p\n", This, *ppContainer);
     return res;
 }
 
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index 1ad56b7..2d3b376 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -332,7 +332,7 @@ static void test_refcount(void)
     CHECK_CALL( hr, "GetRenderTarget", pDevice, ++refcount);
     if(pRenderTarget)
     {
-        todo_wine CHECK_SURFACE_CONTAINER( pRenderTarget, IID_IDirect3DDevice8, pDevice);
+        CHECK_SURFACE_CONTAINER( pRenderTarget, IID_IDirect3DDevice8, pDevice);
         CHECK_REFCOUNT( pRenderTarget, 1);
 
         CHECK_ADDREF_REFCOUNT(pRenderTarget, 2);
@@ -496,7 +496,7 @@ static void test_refcount(void)
         CHECK_REFCOUNT( pSwapChain, 1);
         if(pBackBuffer)
         {
-            todo_wine CHECK_SURFACE_CONTAINER( pBackBuffer, IID_IDirect3DDevice8, pDevice);
+            CHECK_SURFACE_CONTAINER( pBackBuffer, IID_IDirect3DDevice8, pDevice);
             CHECK_REFCOUNT( pBackBuffer, 1);
             CHECK_RELEASE_REFCOUNT( pBackBuffer, 0);
             CHECK_REFCOUNT( pDevice, --refcount);




More information about the wine-cvs mailing list