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

ddraw: Get rid of IDirectDrawPaletteImpl.

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