ddraw: Add a separate function for clipper initialization.

This commit is contained in:
Henri Verbeet 2010-08-18 19:26:25 +02:00 committed by Alexandre Julliard
parent 759fd517aa
commit 4b84c5e5b7
3 changed files with 23 additions and 7 deletions

View File

@ -283,7 +283,7 @@ static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged(
/*****************************************************************************
* The VTable
*****************************************************************************/
const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl =
static const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl =
{
IDirectDrawClipperImpl_QueryInterface,
IDirectDrawClipperImpl_AddRef,
@ -295,3 +295,17 @@ const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl =
IDirectDrawClipperImpl_SetClipList,
IDirectDrawClipperImpl_SetHwnd
};
HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper)
{
clipper->lpVtbl = &ddraw_clipper_vtbl;
clipper->ref = 1;
clipper->wineD3DClipper = pWineDirect3DCreateClipper((IUnknown *)clipper);
if (!clipper->wineD3DClipper)
{
WARN("Failed to create wined3d clipper.\n");
return E_OUTOFMEMORY;
}
return DD_OK;
}

View File

@ -3840,6 +3840,8 @@ DirectDrawCreateClipper(DWORD Flags,
IUnknown *UnkOuter)
{
IDirectDrawClipperImpl* object;
HRESULT hr;
TRACE("(%08x,%p,%p)\n", Flags, Clipper, UnkOuter);
EnterCriticalSection(&ddraw_cs);
@ -3863,16 +3865,16 @@ DirectDrawCreateClipper(DWORD Flags,
return E_OUTOFMEMORY;
}
object->lpVtbl = &IDirectDrawClipper_Vtbl;
object->ref = 1;
object->wineD3DClipper = pWineDirect3DCreateClipper((IUnknown *) object);
if(!object->wineD3DClipper)
hr = ddraw_clipper_init(object);
if (FAILED(hr))
{
WARN("Failed to initialize clipper, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
LeaveCriticalSection(&ddraw_cs);
return E_OUTOFMEMORY;
return hr;
}
TRACE("Created clipper %p.\n", object);
*Clipper = (IDirectDrawClipper *) object;
LeaveCriticalSection(&ddraw_cs);
return DD_OK;

View File

@ -462,7 +462,7 @@ struct IDirectDrawClipperImpl
BOOL initialized;
};
extern const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl DECLSPEC_HIDDEN;
HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper) DECLSPEC_HIDDEN;
typeof(WineDirect3DCreateClipper) *pWineDirect3DCreateClipper DECLSPEC_HIDDEN;