mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 11:43:31 +00:00
ddraw: Get rid of IDirectDrawPaletteImpl.
This commit is contained in:
parent
9e44c4bc58
commit
d0a37cdeb5
4 changed files with 48 additions and 67 deletions
|
@ -3700,7 +3700,7 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags,
|
|||
PALETTEENTRY *ColorTable, IDirectDrawPalette **Palette, IUnknown *pUnkOuter)
|
||||
{
|
||||
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
|
||||
IDirectDrawPaletteImpl *object;
|
||||
struct ddraw_palette *object;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, flags %#x, color_table %p, palette %p, outer_unknown %p.\n",
|
||||
|
@ -3719,8 +3719,8 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags,
|
|||
return DDERR_NOCOOPERATIVELEVELSET;
|
||||
}
|
||||
|
||||
object = HeapAlloc(GetProcessHeap(), 0, sizeof(IDirectDrawPaletteImpl));
|
||||
if(!object)
|
||||
object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
|
||||
if (!object)
|
||||
{
|
||||
ERR("Out of memory when allocating memory for a palette implementation\n");
|
||||
wined3d_mutex_unlock();
|
||||
|
@ -3755,7 +3755,7 @@ static HRESULT WINAPI ddraw4_CreatePalette(IDirectDraw4 *iface, DWORD flags, PAL
|
|||
hr = ddraw7_CreatePalette(&ddraw->IDirectDraw7_iface, flags, entries, palette, outer_unknown);
|
||||
if (SUCCEEDED(hr) && *palette)
|
||||
{
|
||||
IDirectDrawPaletteImpl *impl = impl_from_IDirectDrawPalette(*palette);
|
||||
struct ddraw_palette *impl = impl_from_IDirectDrawPalette(*palette);
|
||||
IDirectDraw7_Release(&ddraw->IDirectDraw7_iface);
|
||||
IDirectDraw4_AddRef(iface);
|
||||
impl->ifaceToRelease = (IUnknown *)iface;
|
||||
|
@ -3775,7 +3775,7 @@ static HRESULT WINAPI ddraw2_CreatePalette(IDirectDraw2 *iface, DWORD flags,
|
|||
hr = ddraw7_CreatePalette(&ddraw->IDirectDraw7_iface, flags, entries, palette, outer_unknown);
|
||||
if (SUCCEEDED(hr) && *palette)
|
||||
{
|
||||
IDirectDrawPaletteImpl *impl = impl_from_IDirectDrawPalette(*palette);
|
||||
struct ddraw_palette *impl = impl_from_IDirectDrawPalette(*palette);
|
||||
IDirectDraw7_Release(&ddraw->IDirectDraw7_iface);
|
||||
impl->ifaceToRelease = NULL;
|
||||
}
|
||||
|
@ -3795,7 +3795,7 @@ static HRESULT WINAPI ddraw1_CreatePalette(IDirectDraw *iface, DWORD flags,
|
|||
hr = ddraw7_CreatePalette(&ddraw->IDirectDraw7_iface, flags, entries, palette, outer_unknown);
|
||||
if (SUCCEEDED(hr) && *palette)
|
||||
{
|
||||
IDirectDrawPaletteImpl *impl = impl_from_IDirectDrawPalette(*palette);
|
||||
struct ddraw_palette *impl = impl_from_IDirectDrawPalette(*palette);
|
||||
IDirectDraw7_Release(&ddraw->IDirectDraw7_iface);
|
||||
impl->ifaceToRelease = NULL;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ extern const struct wined3d_parent_ops ddraw_surface_wined3d_parent_ops DECLSPEC
|
|||
extern const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops DECLSPEC_HIDDEN;
|
||||
|
||||
/* Typdef the interfaces */
|
||||
typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl;
|
||||
typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl;
|
||||
typedef struct IDirect3DLightImpl IDirect3DLightImpl;
|
||||
typedef struct IDirect3DViewportImpl IDirect3DViewportImpl;
|
||||
|
@ -370,7 +369,7 @@ struct ddraw_clipper *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *if
|
|||
/*****************************************************************************
|
||||
* IDirectDrawPalette implementation structure
|
||||
*****************************************************************************/
|
||||
struct IDirectDrawPaletteImpl
|
||||
struct ddraw_palette
|
||||
{
|
||||
/* IUnknown fields */
|
||||
IDirectDrawPalette IDirectDrawPalette_iface;
|
||||
|
@ -382,14 +381,14 @@ struct IDirectDrawPaletteImpl
|
|||
IUnknown *ifaceToRelease;
|
||||
};
|
||||
|
||||
static inline IDirectDrawPaletteImpl *impl_from_IDirectDrawPalette(IDirectDrawPalette *iface)
|
||||
static inline struct ddraw_palette *impl_from_IDirectDrawPalette(IDirectDrawPalette *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, IDirectDrawPaletteImpl, IDirectDrawPalette_iface);
|
||||
return CONTAINING_RECORD(iface, struct ddraw_palette, IDirectDrawPalette_iface);
|
||||
}
|
||||
|
||||
IDirectDrawPaletteImpl *unsafe_impl_from_IDirectDrawPalette(IDirectDrawPalette *iface) DECLSPEC_HIDDEN;
|
||||
struct ddraw_palette *unsafe_impl_from_IDirectDrawPalette(IDirectDrawPalette *iface) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT ddraw_palette_init(IDirectDrawPaletteImpl *palette,
|
||||
HRESULT ddraw_palette_init(struct ddraw_palette *palette,
|
||||
struct ddraw *ddraw, DWORD flags, PALETTEENTRY *entries) DECLSPEC_HIDDEN;
|
||||
|
||||
/* Helper structures */
|
||||
|
|
|
@ -37,10 +37,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
|
|||
* S_OK on success
|
||||
* E_NOINTERFACE if the requested interface wasn't found
|
||||
*****************************************************************************/
|
||||
static HRESULT WINAPI
|
||||
IDirectDrawPaletteImpl_QueryInterface(IDirectDrawPalette *iface,
|
||||
REFIID refiid,
|
||||
void **obj)
|
||||
static HRESULT WINAPI ddraw_palette_QueryInterface(IDirectDrawPalette *iface, REFIID refiid, void **obj)
|
||||
{
|
||||
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(refiid), obj);
|
||||
|
||||
|
@ -67,10 +64,9 @@ IDirectDrawPaletteImpl_QueryInterface(IDirectDrawPalette *iface,
|
|||
* The new refcount
|
||||
*
|
||||
*****************************************************************************/
|
||||
static ULONG WINAPI
|
||||
IDirectDrawPaletteImpl_AddRef(IDirectDrawPalette *iface)
|
||||
static ULONG WINAPI ddraw_palette_AddRef(IDirectDrawPalette *iface)
|
||||
{
|
||||
IDirectDrawPaletteImpl *This = impl_from_IDirectDrawPalette(iface);
|
||||
struct ddraw_palette *This = impl_from_IDirectDrawPalette(iface);
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
|
||||
TRACE("%p increasing refcount to %u.\n", This, ref);
|
||||
|
@ -87,10 +83,9 @@ IDirectDrawPaletteImpl_AddRef(IDirectDrawPalette *iface)
|
|||
* The new refcount
|
||||
*
|
||||
*****************************************************************************/
|
||||
static ULONG WINAPI
|
||||
IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface)
|
||||
static ULONG WINAPI ddraw_palette_Release(IDirectDrawPalette *iface)
|
||||
{
|
||||
IDirectDrawPaletteImpl *This = impl_from_IDirectDrawPalette(iface);
|
||||
struct ddraw_palette *This = impl_from_IDirectDrawPalette(iface);
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
TRACE("%p decreasing refcount to %u.\n", This, ref);
|
||||
|
@ -126,14 +121,11 @@ IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface)
|
|||
* DDERR_ALREADYINITIALIZED
|
||||
*
|
||||
*****************************************************************************/
|
||||
static HRESULT WINAPI
|
||||
IDirectDrawPaletteImpl_Initialize(IDirectDrawPalette *iface,
|
||||
IDirectDraw *DD,
|
||||
DWORD Flags,
|
||||
PALETTEENTRY *ColorTable)
|
||||
static HRESULT WINAPI ddraw_palette_Initialize(IDirectDrawPalette *iface,
|
||||
IDirectDraw *ddraw, DWORD flags, PALETTEENTRY *entries)
|
||||
{
|
||||
TRACE("iface %p, ddraw %p, flags %#x, entries %p.\n",
|
||||
iface, DD, Flags, ColorTable);
|
||||
iface, ddraw, flags, entries);
|
||||
|
||||
return DDERR_ALREADYINITIALIZED;
|
||||
}
|
||||
|
@ -152,16 +144,14 @@ IDirectDrawPaletteImpl_Initialize(IDirectDrawPalette *iface,
|
|||
* For more details, see IWineD3DPalette::GetCaps
|
||||
*
|
||||
*****************************************************************************/
|
||||
static HRESULT WINAPI
|
||||
IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette *iface,
|
||||
DWORD *Caps)
|
||||
static HRESULT WINAPI ddraw_palette_GetCaps(IDirectDrawPalette *iface, DWORD *caps)
|
||||
{
|
||||
IDirectDrawPaletteImpl *This = impl_from_IDirectDrawPalette(iface);
|
||||
struct ddraw_palette *palette = impl_from_IDirectDrawPalette(iface);
|
||||
|
||||
TRACE("iface %p, caps %p.\n", iface, Caps);
|
||||
TRACE("iface %p, caps %p.\n", iface, caps);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
*Caps = wined3d_palette_get_flags(This->wineD3DPalette);
|
||||
*caps = wined3d_palette_get_flags(palette->wineD3DPalette);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return D3D_OK;
|
||||
|
@ -185,24 +175,20 @@ IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette *iface,
|
|||
* For details, see IWineD3DDevice::SetEntries
|
||||
*
|
||||
*****************************************************************************/
|
||||
static HRESULT WINAPI
|
||||
IDirectDrawPaletteImpl_SetEntries(IDirectDrawPalette *iface,
|
||||
DWORD Flags,
|
||||
DWORD Start,
|
||||
DWORD Count,
|
||||
PALETTEENTRY *PalEnt)
|
||||
static HRESULT WINAPI ddraw_palette_SetEntries(IDirectDrawPalette *iface,
|
||||
DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries)
|
||||
{
|
||||
IDirectDrawPaletteImpl *This = impl_from_IDirectDrawPalette(iface);
|
||||
struct ddraw_palette *palette = impl_from_IDirectDrawPalette(iface);
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n",
|
||||
iface, Flags, Start, Count, PalEnt);
|
||||
iface, flags, start, count, entries);
|
||||
|
||||
if(!PalEnt)
|
||||
if (!entries)
|
||||
return DDERR_INVALIDPARAMS;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
hr = wined3d_palette_set_entries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
|
||||
hr = wined3d_palette_set_entries(palette->wineD3DPalette, flags, start, count, entries);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return hr;
|
||||
|
@ -225,24 +211,20 @@ IDirectDrawPaletteImpl_SetEntries(IDirectDrawPalette *iface,
|
|||
* For details, see IWineD3DDevice::SetEntries
|
||||
*
|
||||
*****************************************************************************/
|
||||
static HRESULT WINAPI
|
||||
IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface,
|
||||
DWORD Flags,
|
||||
DWORD Start,
|
||||
DWORD Count,
|
||||
PALETTEENTRY *PalEnt)
|
||||
static HRESULT WINAPI ddraw_palette_GetEntries(IDirectDrawPalette *iface,
|
||||
DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries)
|
||||
{
|
||||
IDirectDrawPaletteImpl *This = impl_from_IDirectDrawPalette(iface);
|
||||
struct ddraw_palette *palette = impl_from_IDirectDrawPalette(iface);
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n",
|
||||
iface, Flags, Start, Count, PalEnt);
|
||||
iface, flags, start, count, entries);
|
||||
|
||||
if(!PalEnt)
|
||||
if (!entries)
|
||||
return DDERR_INVALIDPARAMS;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
hr = wined3d_palette_get_entries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
|
||||
hr = wined3d_palette_get_entries(palette->wineD3DPalette, flags, start, count, entries);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return hr;
|
||||
|
@ -251,24 +233,24 @@ IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface,
|
|||
static const struct IDirectDrawPaletteVtbl ddraw_palette_vtbl =
|
||||
{
|
||||
/*** IUnknown ***/
|
||||
IDirectDrawPaletteImpl_QueryInterface,
|
||||
IDirectDrawPaletteImpl_AddRef,
|
||||
IDirectDrawPaletteImpl_Release,
|
||||
ddraw_palette_QueryInterface,
|
||||
ddraw_palette_AddRef,
|
||||
ddraw_palette_Release,
|
||||
/*** IDirectDrawPalette ***/
|
||||
IDirectDrawPaletteImpl_GetCaps,
|
||||
IDirectDrawPaletteImpl_GetEntries,
|
||||
IDirectDrawPaletteImpl_Initialize,
|
||||
IDirectDrawPaletteImpl_SetEntries
|
||||
ddraw_palette_GetCaps,
|
||||
ddraw_palette_GetEntries,
|
||||
ddraw_palette_Initialize,
|
||||
ddraw_palette_SetEntries
|
||||
};
|
||||
|
||||
IDirectDrawPaletteImpl *unsafe_impl_from_IDirectDrawPalette(IDirectDrawPalette *iface)
|
||||
struct ddraw_palette *unsafe_impl_from_IDirectDrawPalette(IDirectDrawPalette *iface)
|
||||
{
|
||||
if (!iface) return NULL;
|
||||
assert(iface->lpVtbl == &ddraw_palette_vtbl);
|
||||
return CONTAINING_RECORD(iface, IDirectDrawPaletteImpl, IDirectDrawPalette_iface);
|
||||
return CONTAINING_RECORD(iface, struct ddraw_palette, IDirectDrawPalette_iface);
|
||||
}
|
||||
|
||||
HRESULT ddraw_palette_init(IDirectDrawPaletteImpl *palette,
|
||||
HRESULT ddraw_palette_init(struct ddraw_palette *palette,
|
||||
struct ddraw *ddraw, DWORD flags, PALETTEENTRY *entries)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
|
|
@ -4685,9 +4685,9 @@ static HRESULT WINAPI ddraw_surface1_SetColorKey(IDirectDrawSurface *iface, DWOR
|
|||
static HRESULT WINAPI ddraw_surface7_SetPalette(IDirectDrawSurface7 *iface, IDirectDrawPalette *Pal)
|
||||
{
|
||||
struct ddraw_surface *This = impl_from_IDirectDrawSurface7(iface);
|
||||
struct ddraw_palette *palette_impl = unsafe_impl_from_IDirectDrawPalette(Pal);
|
||||
IDirectDrawPalette *oldPal;
|
||||
struct ddraw_surface *surf;
|
||||
IDirectDrawPaletteImpl *PalImpl = unsafe_impl_from_IDirectDrawPalette(Pal);
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, palette %p.\n", iface, Pal);
|
||||
|
@ -4713,7 +4713,7 @@ static HRESULT WINAPI ddraw_surface7_SetPalette(IDirectDrawSurface7 *iface, IDir
|
|||
if(oldPal) IDirectDrawPalette_Release(oldPal); /* For the GetPalette */
|
||||
|
||||
/* Set the new Palette */
|
||||
wined3d_surface_set_palette(This->wined3d_surface, PalImpl ? PalImpl->wineD3DPalette : NULL);
|
||||
wined3d_surface_set_palette(This->wined3d_surface, palette_impl ? palette_impl->wineD3DPalette : NULL);
|
||||
/* AddRef the Palette */
|
||||
if(Pal) IDirectDrawPalette_AddRef(Pal);
|
||||
|
||||
|
@ -4723,7 +4723,7 @@ static HRESULT WINAPI ddraw_surface7_SetPalette(IDirectDrawSurface7 *iface, IDir
|
|||
/* Update the wined3d frontbuffer if this is the frontbuffer. */
|
||||
if ((This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER) && This->ddraw->wined3d_frontbuffer)
|
||||
{
|
||||
hr = wined3d_surface_set_palette(This->ddraw->wined3d_frontbuffer, PalImpl ? PalImpl->wineD3DPalette : NULL);
|
||||
hr = wined3d_surface_set_palette(This->ddraw->wined3d_frontbuffer, palette_impl ? palette_impl->wineD3DPalette : NULL);
|
||||
if (FAILED(hr))
|
||||
ERR("Failed to set frontbuffer palette, hr %#x.\n", hr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue