Commit b9e1bcb7 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddrawex: Get rid of the IDirectDrawFactoryImpl typedef.

parent ec37ac6f
...@@ -1276,17 +1276,8 @@ static const IDirectDraw4Vtbl IDirectDraw4_Vtbl = ...@@ -1276,17 +1276,8 @@ static const IDirectDraw4Vtbl IDirectDraw4_Vtbl =
IDirectDraw4Impl_GetDeviceIdentifier IDirectDraw4Impl_GetDeviceIdentifier
}; };
/******************************************************************************* HRESULT WINAPI ddrawex_factory_CreateDirectDraw(IDirectDrawFactory *iface, GUID * pGUID, HWND hWnd,
* IDirectDrawFactoryImpl_CreateDirectDraw DWORD dwCoopLevelFlags, DWORD dwReserved, IUnknown *pUnkOuter, IDirectDraw **ppDirectDraw)
*******************************************************************************/
HRESULT WINAPI
IDirectDrawFactoryImpl_CreateDirectDraw(IDirectDrawFactory* iface,
GUID * pGUID,
HWND hWnd,
DWORD dwCoopLevelFlags,
DWORD dwReserved,
IUnknown *pUnkOuter,
IDirectDraw **ppDirectDraw)
{ {
HRESULT hr; HRESULT hr;
IDirectDrawImpl *object = NULL; IDirectDrawImpl *object = NULL;
......
...@@ -44,9 +44,9 @@ DECLARE_INTERFACE_(IDirectDrawFactory, IUnknown) ...@@ -44,9 +44,9 @@ DECLARE_INTERFACE_(IDirectDrawFactory, IUnknown)
#endif #endif
HRESULT WINAPI IDirectDrawFactoryImpl_CreateDirectDraw(IDirectDrawFactory* iface, HRESULT WINAPI ddrawex_factory_CreateDirectDraw(IDirectDrawFactory *iface,
GUID * pGUID, HWND hWnd, DWORD dwCoopLevelFlags, DWORD dwReserved, IUnknown *pUnkOuter, GUID *guid, HWND window, DWORD coop_level, DWORD reserved, IUnknown *outer_unknown,
IDirectDraw **ppDirectDraw) DECLSPEC_HIDDEN; IDirectDraw **ddraw) DECLSPEC_HIDDEN;
void DDSD_to_DDSD2(const DDSURFACEDESC *in, DDSURFACEDESC2 *out) DECLSPEC_HIDDEN; void DDSD_to_DDSD2(const DDSURFACEDESC *in, DDSURFACEDESC2 *out) DECLSPEC_HIDDEN;
void DDSD2_to_DDSD(const DDSURFACEDESC2 *in, DDSURFACEDESC *out) DECLSPEC_HIDDEN; void DDSD2_to_DDSD(const DDSURFACEDESC2 *in, DDSURFACEDESC *out) DECLSPEC_HIDDEN;
......
...@@ -116,129 +116,96 @@ static const IClassFactoryVtbl ddrawex_class_factory_vtbl = ...@@ -116,129 +116,96 @@ static const IClassFactoryVtbl ddrawex_class_factory_vtbl =
ddrawex_class_factory_LockServer, ddrawex_class_factory_LockServer,
}; };
struct ddrawex_factory
/******************************************************************************
* DirectDrawFactory implementation
******************************************************************************/
typedef struct
{ {
IDirectDrawFactory IDirectDrawFactory_iface; IDirectDrawFactory IDirectDrawFactory_iface;
LONG ref; LONG ref;
} IDirectDrawFactoryImpl; };
static inline IDirectDrawFactoryImpl *impl_from_IDirectDrawFactory(IDirectDrawFactory *iface) static inline struct ddrawex_factory *impl_from_IDirectDrawFactory(IDirectDrawFactory *iface)
{ {
return CONTAINING_RECORD(iface, IDirectDrawFactoryImpl, IDirectDrawFactory_iface); return CONTAINING_RECORD(iface, struct ddrawex_factory, IDirectDrawFactory_iface);
} }
/******************************************************************************* static HRESULT WINAPI ddrawex_factory_QueryInterface(IDirectDrawFactory *iface, REFIID riid, void **out)
* IDirectDrawFactory::QueryInterface
*
*******************************************************************************/
static HRESULT WINAPI IDirectDrawFactoryImpl_QueryInterface(IDirectDrawFactory *iface, REFIID riid,
void **obj)
{ {
TRACE("(%p)->(%s,%p)\n", iface, debugstr_guid(riid), obj); TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
if (IsEqualGUID(riid, &IID_IUnknown) if (IsEqualGUID(riid, &IID_IDirectDrawFactory)
|| IsEqualGUID(riid, &IID_IDirectDrawFactory)) || IsEqualGUID(riid, &IID_IUnknown))
{ {
IDirectDrawFactory_AddRef(iface); IDirectDrawFactory_AddRef(iface);
*obj = iface; *out = iface;
return S_OK; return S_OK;
} }
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*obj = NULL; *out = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
/******************************************************************************* static ULONG WINAPI ddrawex_factory_AddRef(IDirectDrawFactory *iface)
* IDirectDrawFactory::AddRef
*
*******************************************************************************/
static ULONG WINAPI IDirectDrawFactoryImpl_AddRef(IDirectDrawFactory *iface)
{ {
IDirectDrawFactoryImpl *This = impl_from_IDirectDrawFactory(iface); struct ddrawex_factory *factory = impl_from_IDirectDrawFactory(iface);
ULONG ref = InterlockedIncrement(&This->ref); ULONG refcount = InterlockedIncrement(&factory->ref);
TRACE("(%p)->() incrementing from %d.\n", This, ref - 1); TRACE("%p increasing refcount to %u.\n", iface, refcount);
return ref; return refcount;
} }
/******************************************************************************* static ULONG WINAPI ddrawex_factory_Release(IDirectDrawFactory *iface)
* IDirectDrawFactory::Release
*
*******************************************************************************/
static ULONG WINAPI IDirectDrawFactoryImpl_Release(IDirectDrawFactory *iface)
{ {
IDirectDrawFactoryImpl *This = impl_from_IDirectDrawFactory(iface); struct ddrawex_factory *factory = impl_from_IDirectDrawFactory(iface);
ULONG ref = InterlockedDecrement(&This->ref); ULONG refcount = InterlockedDecrement(&factory->ref);
TRACE("(%p)->() decrementing from %d.\n", This, ref+1); TRACE("%p decreasing refcount to %u.\n", iface, refcount);
if (ref == 0) if (!refcount)
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, factory);
return ref; return refcount;
} }
static HRESULT WINAPI IDirectDrawFactoryImpl_DirectDrawEnumerate(IDirectDrawFactory *iface, static HRESULT WINAPI ddrawex_factory_DirectDrawEnumerate(IDirectDrawFactory *iface,
LPDDENUMCALLBACKW cb, void *ctx) LPDDENUMCALLBACKW cb, void *ctx)
{ {
FIXME("Stub!\n"); FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
return E_FAIL; return E_FAIL;
} }
static const IDirectDrawFactoryVtbl ddrawex_factory_vtbl =
/*******************************************************************************
* Direct Draw Factory VTable
*******************************************************************************/
static const IDirectDrawFactoryVtbl IDirectDrawFactory_Vtbl =
{ {
IDirectDrawFactoryImpl_QueryInterface, ddrawex_factory_QueryInterface,
IDirectDrawFactoryImpl_AddRef, ddrawex_factory_AddRef,
IDirectDrawFactoryImpl_Release, ddrawex_factory_Release,
IDirectDrawFactoryImpl_CreateDirectDraw, ddrawex_factory_CreateDirectDraw,
IDirectDrawFactoryImpl_DirectDrawEnumerate, ddrawex_factory_DirectDrawEnumerate,
}; };
/*********************************************************************** static HRESULT ddrawex_factory_create(IUnknown *outer_unknown, REFIID riid, void **out)
* CreateDirectDrawFactory
*
***********************************************************************/
static HRESULT
CreateDirectDrawFactory(IUnknown* UnkOuter, REFIID iid, void **obj)
{ {
struct ddrawex_factory *factory;
HRESULT hr; HRESULT hr;
IDirectDrawFactoryImpl *This = NULL;
TRACE("(%p,%s,%p)\n", UnkOuter, debugstr_guid(iid), obj); TRACE("outer_unknown %p, riid %s, out %p.\n", outer_unknown, debugstr_guid(riid), out);
if (UnkOuter != NULL) if (outer_unknown)
return CLASS_E_NOAGGREGATION; return CLASS_E_NOAGGREGATION;
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawFactoryImpl)); if (!(factory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*factory))))
if(!This)
{
ERR("Out of memory when creating DirectDraw\n");
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
}
This->IDirectDrawFactory_iface.lpVtbl = &IDirectDrawFactory_Vtbl; factory->IDirectDrawFactory_iface.lpVtbl = &ddrawex_factory_vtbl;
hr = IDirectDrawFactory_QueryInterface(&This->IDirectDrawFactory_iface, iid, obj); if (FAILED(hr = ddrawex_factory_QueryInterface(&factory->IDirectDrawFactory_iface, riid, out)))
HeapFree(GetProcessHeap(), 0, factory);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);
return hr; return hr;
} }
/******************************************************************************* /*******************************************************************************
* DllCanUnloadNow [DDRAWEX.@] Determines whether the DLL is in use. * DllCanUnloadNow [DDRAWEX.@] Determines whether the DLL is in use.
*/ */
...@@ -273,7 +240,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **out) ...@@ -273,7 +240,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **out)
factory->IClassFactory_iface.lpVtbl = &ddrawex_class_factory_vtbl; factory->IClassFactory_iface.lpVtbl = &ddrawex_class_factory_vtbl;
factory->ref = 1; factory->ref = 1;
factory->pfnCreateInstance = CreateDirectDrawFactory; factory->pfnCreateInstance = ddrawex_factory_create;
*out = factory; *out = factory;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment