ddraw: Add a separate function for palette initialization.
This commit is contained in:
parent
584cb331a9
commit
e2021722fc
|
@ -3952,7 +3952,8 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags,
|
||||||
{
|
{
|
||||||
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
|
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
|
||||||
IDirectDrawPaletteImpl *object;
|
IDirectDrawPaletteImpl *object;
|
||||||
HRESULT hr = DDERR_GENERIC;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("(%p)->(%x,%p,%p,%p)\n", This, Flags, ColorTable, Palette, pUnkOuter);
|
TRACE("(%p)->(%x,%p,%p,%p)\n", This, Flags, ColorTable, Palette, pUnkOuter);
|
||||||
|
|
||||||
EnterCriticalSection(&ddraw_cs);
|
EnterCriticalSection(&ddraw_cs);
|
||||||
|
@ -3979,20 +3980,16 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags,
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
object->lpVtbl = &IDirectDrawPalette_Vtbl;
|
hr = ddraw_palette_init(object, This, Flags, ColorTable);
|
||||||
object->ref = 1;
|
if (FAILED(hr))
|
||||||
|
|
||||||
hr = IWineD3DDevice_CreatePalette(This->wineD3DDevice, Flags,
|
|
||||||
ColorTable, &object->wineD3DPalette, (IUnknown *)object);
|
|
||||||
if(hr != DD_OK)
|
|
||||||
{
|
{
|
||||||
|
WARN("Failed to initialize palette, hr %#x.\n", hr);
|
||||||
HeapFree(GetProcessHeap(), 0, object);
|
HeapFree(GetProcessHeap(), 0, object);
|
||||||
LeaveCriticalSection(&ddraw_cs);
|
LeaveCriticalSection(&ddraw_cs);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDirectDraw7_AddRef(iface);
|
TRACE("Created palette %p.\n", object);
|
||||||
object->ifaceToRelease = (IUnknown *) iface;
|
|
||||||
*Palette = (IDirectDrawPalette *)object;
|
*Palette = (IDirectDrawPalette *)object;
|
||||||
LeaveCriticalSection(&ddraw_cs);
|
LeaveCriticalSection(&ddraw_cs);
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
|
|
|
@ -477,7 +477,9 @@ struct IDirectDrawPaletteImpl
|
||||||
/* IDirectDrawPalette fields */
|
/* IDirectDrawPalette fields */
|
||||||
IUnknown *ifaceToRelease;
|
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
|
* DirectDraw ClassFactory implementation - incomplete
|
||||||
|
|
|
@ -240,7 +240,7 @@ IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface,
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl =
|
static const struct IDirectDrawPaletteVtbl ddraw_palette_vtbl =
|
||||||
{
|
{
|
||||||
/*** IUnknown ***/
|
/*** IUnknown ***/
|
||||||
IDirectDrawPaletteImpl_QueryInterface,
|
IDirectDrawPaletteImpl_QueryInterface,
|
||||||
|
@ -252,3 +252,25 @@ const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl =
|
||||||
IDirectDrawPaletteImpl_Initialize,
|
IDirectDrawPaletteImpl_Initialize,
|
||||||
IDirectDrawPaletteImpl_SetEntries
|
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 New Issue