mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-01 07:37:02 +00:00
ddraw: Add a separate function for palette initialization.
This commit is contained in:
parent
584cb331a9
commit
e2021722fc
3 changed files with 32 additions and 11 deletions
|
@ -3952,7 +3952,8 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags,
|
|||
{
|
||||
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
|
||||
IDirectDrawPaletteImpl *object;
|
||||
HRESULT hr = DDERR_GENERIC;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p)->(%x,%p,%p,%p)\n", This, Flags, ColorTable, Palette, pUnkOuter);
|
||||
|
||||
EnterCriticalSection(&ddraw_cs);
|
||||
|
@ -3979,20 +3980,16 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags,
|
|||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
object->lpVtbl = &IDirectDrawPalette_Vtbl;
|
||||
object->ref = 1;
|
||||
|
||||
hr = IWineD3DDevice_CreatePalette(This->wineD3DDevice, Flags,
|
||||
ColorTable, &object->wineD3DPalette, (IUnknown *)object);
|
||||
if(hr != DD_OK)
|
||||
hr = ddraw_palette_init(object, This, Flags, ColorTable);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to initialize palette, hr %#x.\n", hr);
|
||||
HeapFree(GetProcessHeap(), 0, object);
|
||||
LeaveCriticalSection(&ddraw_cs);
|
||||
return hr;
|
||||
}
|
||||
|
||||
IDirectDraw7_AddRef(iface);
|
||||
object->ifaceToRelease = (IUnknown *) iface;
|
||||
TRACE("Created palette %p.\n", object);
|
||||
*Palette = (IDirectDrawPalette *)object;
|
||||
LeaveCriticalSection(&ddraw_cs);
|
||||
return DD_OK;
|
||||
|
|
|
@ -477,7 +477,9 @@ struct IDirectDrawPaletteImpl
|
|||
/* IDirectDrawPalette fields */
|
||||
IUnknown *ifaceToRelease;
|
||||
};
|
||||
extern const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT ddraw_palette_init(IDirectDrawPaletteImpl *palette,
|
||||
IDirectDrawImpl *ddraw, DWORD flags, PALETTEENTRY *entries) DECLSPEC_HIDDEN;
|
||||
|
||||
/******************************************************************************
|
||||
* DirectDraw ClassFactory implementation - incomplete
|
||||
|
|
|
@ -240,7 +240,7 @@ IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface,
|
|||
return hr;
|
||||
}
|
||||
|
||||
const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl =
|
||||
static const struct IDirectDrawPaletteVtbl ddraw_palette_vtbl =
|
||||
{
|
||||
/*** IUnknown ***/
|
||||
IDirectDrawPaletteImpl_QueryInterface,
|
||||
|
@ -252,3 +252,25 @@ const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl =
|
|||
IDirectDrawPaletteImpl_Initialize,
|
||||
IDirectDrawPaletteImpl_SetEntries
|
||||
};
|
||||
|
||||
HRESULT ddraw_palette_init(IDirectDrawPaletteImpl *palette,
|
||||
IDirectDrawImpl *ddraw, DWORD flags, PALETTEENTRY *entries)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
palette->lpVtbl = &ddraw_palette_vtbl;
|
||||
palette->ref = 1;
|
||||
|
||||
hr = IWineD3DDevice_CreatePalette(ddraw->wineD3DDevice, flags,
|
||||
entries, &palette->wineD3DPalette, (IUnknown *)palette);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to create wined3d palette, hr %#x.\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
palette->ifaceToRelease = (IUnknown *)ddraw;
|
||||
IUnknown_AddRef(palette->ifaceToRelease);
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue