[PATCH 3/4] ddraw: Just pass NULL as swapchain parent.

Henri Verbeet hverbeet at codeweavers.com
Mon Mar 7 14:45:26 CST 2011


The swapchain was the last place using IParent, so this allows us to kill
IParent completely.
---
 dlls/ddraw/Makefile.in     |    1 -
 dlls/ddraw/ddraw.c         |   24 +-------
 dlls/ddraw/ddraw_private.h |   45 ---------------
 dlls/ddraw/parent.c        |  135 --------------------------------------------
 4 files changed, 4 insertions(+), 201 deletions(-)
 delete mode 100644 dlls/ddraw/parent.c

diff --git a/dlls/ddraw/Makefile.in b/dlls/ddraw/Makefile.in
index 1d49e79..bc232f0 100644
--- a/dlls/ddraw/Makefile.in
+++ b/dlls/ddraw/Makefile.in
@@ -11,7 +11,6 @@ C_SRCS = \
 	main.c \
 	material.c \
 	palette.c \
-	parent.c \
 	surface.c \
 	utils.c \
 	vertexbuffer.c \
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index e1d5c62..aeabe59 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -2628,14 +2628,11 @@ static HRESULT ddraw_recreate_surfaces(IDirectDrawImpl *This)
             ddraw_recreate_surfaces_cb);
 }
 
-ULONG WINAPI D3D7CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain)
+ULONG WINAPI D3D7CB_DestroySwapChain(IWineD3DSwapChain *swapchain)
 {
-    IUnknown *swapChainParent;
+    TRACE("swapchain %p.\n", swapchain);
 
-    TRACE("swapchain %p.\n", pSwapChain);
-
-    swapChainParent = IWineD3DSwapChain_GetParent(pSwapChain);
-    return IUnknown_Release(swapChainParent);
+    return IWineD3DSwapChain_Release(swapchain);
 }
 
 /*****************************************************************************
@@ -5919,32 +5916,19 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
 {
     struct IDirectDrawImpl *This = ddraw_from_device_parent(iface);
     IDirectDrawSurfaceImpl *iterator;
-    IParentImpl *object;
     HRESULT hr;
 
     TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
 
-    object = HeapAlloc(GetProcessHeap(),  HEAP_ZERO_MEMORY, sizeof(IParentImpl));
-    if (!object)
-    {
-        FIXME("Allocation of memory failed\n");
-        *swapchain = NULL;
-        return DDERR_OUTOFVIDEOMEMORY;
-    }
-
-    ddraw_parent_init(object);
-
     hr = IWineD3DDevice_CreateSwapChain(This->wineD3DDevice, present_parameters,
-            This->ImplType, object, swapchain);
+            This->ImplType, NULL, swapchain);
     if (FAILED(hr))
     {
         FIXME("(%p) CreateSwapChain failed, returning %#x\n", iface, hr);
-        HeapFree(GetProcessHeap(), 0 , object);
         *swapchain = NULL;
         return hr;
     }
 
-    object->child = (IUnknown *)*swapchain;
     This->d3d_target->wineD3DSwapChain = *swapchain;
     iterator = This->d3d_target->complex_array[0];
     while (iterator)
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index 7899deb..7df059f 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -39,30 +39,6 @@
 
 extern const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops DECLSPEC_HIDDEN;
 
-/*****************************************************************************
- * IParent - a helper interface
- *****************************************************************************/
-DEFINE_GUID(IID_IParent, 0xc20e4c88, 0x74e7, 0x4940, 0xba, 0x9f, 0x2e, 0x32, 0x3f, 0x9d, 0xc9, 0x81);
-typedef struct IParent *LPPARENT, *PPARENT;
-
-#define INTERFACE IParent
-DECLARE_INTERFACE_(IParent,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-};
-#undef INTERFACE
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IParent_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IParent_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IParent_Release(p)            (p)->lpVtbl->Release(p)
-#endif
-
-
 /* Typdef the interfaces */
 typedef struct IDirectDrawImpl            IDirectDrawImpl;
 typedef struct IDirectDrawSurfaceImpl     IDirectDrawSurfaceImpl;
@@ -74,7 +50,6 @@ typedef struct IDirect3DViewportImpl      IDirect3DViewportImpl;
 typedef struct IDirect3DMaterialImpl      IDirect3DMaterialImpl;
 typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
 typedef struct IDirect3DVertexBufferImpl  IDirect3DVertexBufferImpl;
-typedef struct IParentImpl                IParentImpl;
 
 /* Callbacks for implicit object destruction */
 extern ULONG WINAPI D3D7CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) DECLSPEC_HIDDEN;
@@ -270,26 +245,6 @@ static inline IDirectDrawSurfaceImpl *surface_from_surface3(IDirectDrawSurface3
 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.dwRGBBitCount+7)/8))
 #define GET_BPP(desc) PFGET_BPP(desc.ddpfPixelFormat)
 
-/*****************************************************************************
- * IParent Implementation
- *****************************************************************************/
-struct IParentImpl
-{
-    /* IUnknown fields */
-    const IParentVtbl *lpVtbl;
-    LONG                    ref;
-
-    /* IParentImpl fields */
-    IUnknown      *child;
-
-};
-
-void ddraw_parent_init(IParentImpl *parent) DECLSPEC_HIDDEN;
-
-/*****************************************************************************
- * IDirect3DDevice implementation
- *****************************************************************************/
-
 #define DDRAW_INVALID_HANDLE ~0U
 
 enum ddraw_handle_type
diff --git a/dlls/ddraw/parent.c b/dlls/ddraw/parent.c
deleted file mode 100644
index 871f066..0000000
--- a/dlls/ddraw/parent.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * IParent implementation
- *
- * Copyright (c) 2006 Stefan Dösinger
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- *
- * A universal parent interface for everything in WineD3D that doesn't have
- * a DDraw counterpart
- */
-
-#include "config.h"
-#include "wine/port.h"
-
-#include "ddraw_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
-
-/*****************************************************************************
- * IUnknown methods
- *****************************************************************************/
-
-/*****************************************************************************
- * IParent::Queryinterface
- *
- * It can't query any interfaces, and it's not used for anything. So
- * it just returns E_NOINTERFACE
- *
- * Params:
- *  riid: guid of queried interface
- *  obj: returns a pointer to the interface
- *
- * Return values
- *  This implementation always returns E_NOINTERFACE and NULL
- *
- *****************************************************************************/
-static HRESULT WINAPI
-IParentImpl_QueryInterface(IParent *iface,
-                           REFIID riid,
-                           void **obj)
-{
-    TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obj);
-
-    *obj = NULL;
-    if ( IsEqualGUID( &IID_IUnknown, riid ) ||
-         IsEqualGUID( &IID_IParent, riid ) )
-    {
-        *obj = iface;
-        IParent_AddRef(iface);
-        return DD_OK;
-    }
-    return E_NOINTERFACE;
-}
-
-/*****************************************************************************
- * IParent::AddRef
- *
- * Increases the refcount
- *
- * Params:
- *
- * Return values
- *  The new refcount
- *
- *****************************************************************************/
-static ULONG WINAPI
-IParentImpl_AddRef(IParent *iface)
-{
-    IParentImpl *This = (IParentImpl *)iface;
-    ULONG ref = InterlockedIncrement(&This->ref);
-
-    TRACE("%p increasing refcount to %u.\n", This, ref);
-
-    return ref;
-}
-
-
-/*****************************************************************************
- * IParent::Release
- *
- * Releases the refcount, and destroys the object if the refcount falls to 0
- * Also releases the child object, if destroyed. That's almost the whole sense
- * of this interface.
- *
- * Params:
- *
- * Return values
- *  The new refcount
- *
- *****************************************************************************/
-static ULONG WINAPI IParentImpl_Release(IParent *iface)
-{
-    IParentImpl *This = (IParentImpl *)iface;
-    ULONG ref = InterlockedDecrement(&This->ref);
-
-    TRACE("%p decreasing refcount to %u.\n", This, ref);
-
-    if (ref == 0)
-    {
-        TRACE("(%p) Releasing child at %p\n", This, This->child);
-        if(This->child)
-            IUnknown_Release(This->child);
-        HeapFree(GetProcessHeap(), 0, This);
-        TRACE("Released\n");
-    }
-    return ref;
-}
-
-/*****************************************************************************
- * The VTable
- *****************************************************************************/
-static const struct IParentVtbl ddraw_parent_vtbl =
-{
-     IParentImpl_QueryInterface,
-     IParentImpl_AddRef,
-     IParentImpl_Release,
-};
-
-void ddraw_parent_init(IParentImpl *parent)
-{
-    parent->lpVtbl = &ddraw_parent_vtbl;
-    parent->ref = 1;
-}
-- 
1.7.3.4




More information about the wine-patches mailing list