Commit 5963483f authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Remove COM from the palette.

parent fe3cfb3e
......@@ -426,8 +426,7 @@ struct IDirectDrawPaletteImpl
const IDirectDrawPaletteVtbl *lpVtbl;
LONG ref;
/* WineD3D uplink */
IWineD3DPalette *wineD3DPalette;
struct wined3d_palette *wineD3DPalette;
/* IDirectDrawPalette fields */
IUnknown *ifaceToRelease;
......
......@@ -98,7 +98,7 @@ IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface)
if (ref == 0)
{
EnterCriticalSection(&ddraw_cs);
IWineD3DPalette_Release(This->wineD3DPalette);
wined3d_palette_decref(This->wineD3DPalette);
if(This->ifaceToRelease)
{
IUnknown_Release(This->ifaceToRelease);
......@@ -156,14 +156,14 @@ IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette *iface,
DWORD *Caps)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
HRESULT hr;
TRACE("iface %p, caps %p.\n", iface, Caps);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DPalette_GetCaps(This->wineD3DPalette, Caps);
*Caps = wined3d_palette_get_flags(This->wineD3DPalette);
LeaveCriticalSection(&ddraw_cs);
return hr;
return D3D_OK;
}
/*****************************************************************************
......@@ -201,7 +201,7 @@ IDirectDrawPaletteImpl_SetEntries(IDirectDrawPalette *iface,
return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DPalette_SetEntries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
hr = wined3d_palette_set_entries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
......@@ -240,7 +240,7 @@ IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface,
return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DPalette_GetEntries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
hr = wined3d_palette_get_entries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
......
......@@ -2717,7 +2717,7 @@ static HRESULT WINAPI ddraw_surface3_SetSurfaceDesc(IDirectDrawSurface3 *iface,
static HRESULT WINAPI ddraw_surface7_GetPalette(IDirectDrawSurface7 *iface, IDirectDrawPalette **Pal)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IWineD3DPalette *wPal;
struct wined3d_palette *wined3d_palette;
HRESULT hr;
TRACE("iface %p, palette %p.\n", iface, Pal);
......@@ -2726,16 +2726,16 @@ static HRESULT WINAPI ddraw_surface7_GetPalette(IDirectDrawSurface7 *iface, IDir
return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_GetPalette(This->WineD3DSurface, &wPal);
if(hr != DD_OK)
hr = IWineD3DSurface_GetPalette(This->WineD3DSurface, &wined3d_palette);
if (FAILED(hr))
{
LeaveCriticalSection(&ddraw_cs);
return hr;
}
if(wPal)
if (wined3d_palette)
{
*Pal = IWineD3DPalette_GetParent(wPal);
*Pal = wined3d_palette_get_parent(wined3d_palette);
IDirectDrawPalette_AddRef(*Pal);
}
else
......@@ -3227,7 +3227,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
for (;;)
{
IWineD3DPalette *wined3d_dst_pal, *wined3d_src_pal;
struct wined3d_palette *wined3d_dst_pal, *wined3d_src_pal;
IDirectDrawPalette *dst_pal = NULL, *src_pal = NULL;
DDSURFACEDESC *src_desc, *dst_desc;
......@@ -3245,7 +3245,8 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
LeaveCriticalSection(&ddraw_cs);
return D3DERR_TEXTURE_LOAD_FAILED;
}
if (wined3d_dst_pal) dst_pal = IWineD3DPalette_GetParent(wined3d_dst_pal);
if (wined3d_dst_pal)
dst_pal = wined3d_palette_get_parent(wined3d_dst_pal);
hr = IWineD3DSurface_GetPalette(src_surface->WineD3DSurface, &wined3d_src_pal);
if (FAILED(hr))
......@@ -3254,7 +3255,8 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
LeaveCriticalSection(&ddraw_cs);
return D3DERR_TEXTURE_LOAD_FAILED;
}
if (wined3d_src_pal) src_pal = IWineD3DPalette_GetParent(wined3d_src_pal);
if (wined3d_src_pal)
src_pal = wined3d_palette_get_parent(wined3d_src_pal);
if (src_pal)
{
......
......@@ -30,51 +30,31 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define SIZE_BITS (WINEDDPCAPS_1BIT | WINEDDPCAPS_2BIT | WINEDDPCAPS_4BIT | WINEDDPCAPS_8BIT)
static HRESULT WINAPI IWineD3DPaletteImpl_QueryInterface(IWineD3DPalette *iface, REFIID riid, void **object)
ULONG CDECL wined3d_palette_incref(struct wined3d_palette *palette)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
ULONG refcount = InterlockedIncrement(&palette->ref);
if (IsEqualGUID(riid, &IID_IWineD3DPalette)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IUnknown))
{
IUnknown_AddRef(iface);
*object = iface;
return S_OK;
}
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*object = NULL;
return E_NOINTERFACE;
}
TRACE("%p increasing refcount to %u.\n", palette, refcount);
static ULONG WINAPI IWineD3DPaletteImpl_AddRef(IWineD3DPalette *iface) {
IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
return ref;
return refcount;
}
static ULONG WINAPI IWineD3DPaletteImpl_Release(IWineD3DPalette *iface) {
IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
ULONG CDECL wined3d_palette_decref(struct wined3d_palette *palette)
{
ULONG refcount = InterlockedDecrement(&palette->ref);
TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
TRACE("%p decreasing refcount to %u.\n", palette, refcount);
if (!ref) {
DeleteObject(This->hpal);
HeapFree(GetProcessHeap(), 0, This);
return 0;
if (!refcount)
{
DeleteObject(palette->hpal);
HeapFree(GetProcessHeap(), 0, palette);
}
return ref;
return refcount;
}
/* Not called from the vtable */
static WORD IWineD3DPaletteImpl_Size(DWORD flags)
static WORD wined3d_palette_size(DWORD flags)
{
switch (flags & SIZE_BITS)
{
......@@ -88,85 +68,75 @@ static WORD IWineD3DPaletteImpl_Size(DWORD flags)
}
}
static HRESULT WINAPI IWineD3DPaletteImpl_GetEntries(IWineD3DPalette *iface,
DWORD flags, DWORD Start, DWORD Count, PALETTEENTRY *PalEnt)
HRESULT CDECL wined3d_palette_get_entries(const struct wined3d_palette *palette,
DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries)
{
IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface;
TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n",
iface, flags, Start, Count, PalEnt);
TRACE("palette %p, flags %#x, start %u, count %u, entries %p.\n",
palette, flags, start, count, entries);
if (flags) return WINED3DERR_INVALIDCALL; /* unchecked */
if (Start + Count > IWineD3DPaletteImpl_Size(This->flags))
if (start + count > wined3d_palette_size(palette->flags))
return WINED3DERR_INVALIDCALL;
if (This->flags & WINEDDPCAPS_8BITENTRIES)
if (palette->flags & WINEDDPCAPS_8BITENTRIES)
{
BYTE *entry = (BYTE *)entries;
unsigned int i;
LPBYTE entry = (LPBYTE)PalEnt;
for (i=Start; i < Count+Start; i++)
*entry++ = This->palents[i].peRed;
for (i = start; i < count + start; ++i)
*entry++ = palette->palents[i].peRed;
}
else
memcpy(PalEnt, This->palents+Start, Count * sizeof(PALETTEENTRY));
memcpy(entries, palette->palents + start, count * sizeof(*entries));
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface,
DWORD flags, DWORD Start, DWORD Count, const PALETTEENTRY *PalEnt)
HRESULT CDECL wined3d_palette_set_entries(struct wined3d_palette *palette,
DWORD flags, DWORD start, DWORD count, const PALETTEENTRY *entries)
{
IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface;
IWineD3DResourceImpl *res;
TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n",
iface, flags, Start, Count, PalEnt);
TRACE("Palette flags: %#x.\n", This->flags);
TRACE("palette %p, flags %#x, start %u, count %u, entries %p.\n",
palette, flags, start, count, entries);
TRACE("Palette flags: %#x.\n", palette->flags);
if (This->flags & WINEDDPCAPS_8BITENTRIES)
if (palette->flags & WINEDDPCAPS_8BITENTRIES)
{
const BYTE *entry = (const BYTE *)entries;
unsigned int i;
const BYTE* entry = (const BYTE*)PalEnt;
for (i=Start; i < Count+Start; i++)
This->palents[i].peRed = *entry++;
for (i = start; i < count + start; ++i)
palette->palents[i].peRed = *entry++;
}
else {
memcpy(This->palents+Start, PalEnt, Count * sizeof(PALETTEENTRY));
else
{
memcpy(palette->palents + start, entries, count * sizeof(*palette->palents));
/* When WINEDDCAPS_ALLOW256 isn't set we need to override entry 0 with black and 255 with white */
if (!(This->flags & WINEDDPCAPS_ALLOW256))
if (!(palette->flags & WINEDDPCAPS_ALLOW256))
{
TRACE("WINEDDPCAPS_ALLOW256 set, overriding palette entry 0 with black and 255 with white\n");
This->palents[0].peRed = 0;
This->palents[0].peGreen = 0;
This->palents[0].peBlue = 0;
palette->palents[0].peRed = 0;
palette->palents[0].peGreen = 0;
palette->palents[0].peBlue = 0;
This->palents[255].peRed = 255;
This->palents[255].peGreen = 255;
This->palents[255].peBlue = 255;
palette->palents[255].peRed = 255;
palette->palents[255].peGreen = 255;
palette->palents[255].peBlue = 255;
}
if (This->hpal)
SetPaletteEntries(This->hpal, Start, Count, This->palents+Start);
if (palette->hpal)
SetPaletteEntries(palette->hpal, start, count, palette->palents + start);
}
#if 0
/* Now, if we are in 'depth conversion mode', update the screen palette */
/* FIXME: we need to update the image or we won't get palette fading. */
if (This->ddraw->d->palette_convert)
This->ddraw->d->palette_convert(palent,This->screen_palents,start,count);
#endif
/* If the palette is attached to the render target, update all render targets */
LIST_FOR_EACH_ENTRY(res, &This->device->resources, IWineD3DResourceImpl, resource.resource_list_entry)
LIST_FOR_EACH_ENTRY(res, &palette->device->resources, IWineD3DResourceImpl, resource.resource_list_entry)
{
if (IWineD3DResource_GetType((IWineD3DResource *)res) == WINED3DRTYPE_SURFACE)
{
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)res;
if (surface->palette == This)
if (surface->palette == palette)
surface->surface_ops->surface_realize_palette(surface);
}
}
......@@ -174,46 +144,31 @@ static HRESULT WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface,
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DPaletteImpl_GetCaps(IWineD3DPalette *iface, DWORD *Caps) {
IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface;
TRACE("(%p)->(%p)\n", This, Caps);
DWORD CDECL wined3d_palette_get_flags(const struct wined3d_palette *palette)
{
TRACE("palette %p.\n", palette);
*Caps = This->flags;
return WINED3D_OK;
return palette->flags;
}
static void * WINAPI IWineD3DPaletteImpl_GetParent(IWineD3DPalette *iface)
void * CDECL wined3d_palette_get_parent(const struct wined3d_palette *palette)
{
TRACE("iface %p.\n", iface);
TRACE("palette %p.\n", palette);
return ((IWineD3DPaletteImpl *)iface)->parent;
return palette->parent;
}
static const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl =
{
/*** IUnknown ***/
IWineD3DPaletteImpl_QueryInterface,
IWineD3DPaletteImpl_AddRef,
IWineD3DPaletteImpl_Release,
/*** IWineD3DPalette ***/
IWineD3DPaletteImpl_GetParent,
IWineD3DPaletteImpl_GetEntries,
IWineD3DPaletteImpl_GetCaps,
IWineD3DPaletteImpl_SetEntries
};
HRESULT wined3d_palette_init(IWineD3DPaletteImpl *palette, IWineD3DDeviceImpl *device,
DWORD flags, const PALETTEENTRY *entries, void *parent)
{
HRESULT hr;
palette->lpVtbl = &IWineD3DPalette_Vtbl;
palette->ref = 1;
palette->parent = parent;
palette->device = device;
palette->flags = flags;
palette->palNumEntries = IWineD3DPaletteImpl_Size(flags);
palette->palNumEntries = wined3d_palette_size(flags);
palette->hpal = CreatePalette((const LOGPALETTE *)&palette->palVersion);
if (!palette->hpal)
{
......@@ -221,7 +176,7 @@ HRESULT wined3d_palette_init(IWineD3DPaletteImpl *palette, IWineD3DDeviceImpl *d
return E_FAIL;
}
hr = IWineD3DPalette_SetEntries((IWineD3DPalette *)palette, 0, 0, IWineD3DPaletteImpl_Size(flags), entries);
hr = wined3d_palette_set_entries(palette, 0, 0, wined3d_palette_size(flags), entries);
if (FAILED(hr))
{
WARN("Failed to set palette entries, hr %#x.\n", hr);
......
......@@ -22,6 +22,13 @@
@ cdecl wined3d_device_create(ptr long long ptr long ptr ptr)
@ cdecl wined3d_palette_decref(ptr)
@ cdecl wined3d_palette_get_entries(ptr long long long ptr)
@ cdecl wined3d_palette_get_flags(ptr)
@ cdecl wined3d_palette_get_parent(ptr)
@ cdecl wined3d_palette_incref(ptr)
@ cdecl wined3d_palette_set_entries(ptr long long long ptr)
@ cdecl wined3d_stateblock_apply(ptr)
@ cdecl wined3d_stateblock_capture(ptr)
@ cdecl wined3d_stateblock_decref(ptr)
......
......@@ -53,12 +53,13 @@
#define WINED3D_QUIRK_FBO_TEX_UPDATE 0x00000020
typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
typedef struct IWineD3DPaletteImpl IWineD3DPaletteImpl;
typedef struct IWineD3DDeviceImpl IWineD3DDeviceImpl;
typedef struct IWineD3DSwapChainImpl IWineD3DSwapChainImpl;
struct IWineD3DBaseShaderImpl;
struct IWineD3DBaseTextureImpl;
struct IWineD3DResourceImpl;
typedef struct wined3d_palette IWineD3DPaletteImpl;
typedef struct wined3d_palette IWineD3DPalette;
/* Texture format fixups */
......@@ -2941,18 +2942,12 @@ static const float srgb_pow = 0.41666f;
static const float srgb_mul_high = 1.055f;
static const float srgb_sub_high = 0.055f;
/*****************************************************************************
* IWineD3DPalette implementation structure
*/
struct IWineD3DPaletteImpl {
/* IUnknown parts */
const IWineD3DPaletteVtbl *lpVtbl;
struct wined3d_palette
{
LONG ref;
void *parent;
IWineD3DDeviceImpl *device;
/* IWineD3DPalette */
HPALETTE hpal;
WORD palVersion; /*| */
WORD palNumEntries; /*| LOGPALETTE */
......
......@@ -2111,6 +2111,7 @@ interface IWineD3DVolume;
interface IWineD3DSwapChain;
interface IWineD3DDevice;
struct wined3d;
struct wined3d_palette;
struct wined3d_stateblock;
struct wined3d_vertex_declaration;
......@@ -2237,30 +2238,6 @@ interface IWineD3DRendertargetView : IWineD3DBase
[
object,
local,
uuid(f756720c-32b9-4439-b5a3-1d6c97037d9e)
]
interface IWineD3DPalette : IWineD3DBase
{
HRESULT GetEntries(
[in] DWORD flags,
[in] DWORD start,
[in] DWORD count,
[out] PALETTEENTRY *entries
);
HRESULT GetCaps(
[out] DWORD *caps
);
HRESULT SetEntries(
[in] DWORD flags,
[in] DWORD start,
[in] DWORD count,
[in] const PALETTEENTRY *entries
);
}
[
object,
local,
uuid(8f2bceb1-d338-488c-ab7f-0ec980bf5d2d)
]
interface IWineD3DClipper : IUnknown
......@@ -2339,10 +2316,10 @@ interface IWineD3DSurface : IWineD3DResource
[in] DWORD trans
);
HRESULT GetPalette(
[out] IWineD3DPalette **palette
[out] struct wined3d_palette **palette
);
HRESULT SetPalette(
[in] IWineD3DPalette *palette
[in] struct wined3d_palette *palette
);
HRESULT SetColorKey(
[in] DWORD flags,
......@@ -2800,7 +2777,7 @@ interface IWineD3DDevice : IUnknown
[in] DWORD flags,
[in] const PALETTEENTRY *palette_entry,
[in] void *parent,
[out] IWineD3DPalette **palette
[out] struct wined3d_palette **palette
);
HRESULT Init3D(
[in] WINED3DPRESENT_PARAMETERS *present_parameters
......@@ -3298,6 +3275,15 @@ HRESULT __cdecl wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx,
WINED3DDEVTYPE device_type, HWND focus_window, DWORD behaviour_flags,
IWineD3DDeviceParent *device_parent, IWineD3DDevice **device);
ULONG __cdecl wined3d_palette_decref(struct wined3d_palette *palette);
HRESULT __cdecl wined3d_palette_get_entries(const struct wined3d_palette *palette,
DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries);
DWORD __cdecl wined3d_palette_get_flags(const struct wined3d_palette *palette);
void * __cdecl wined3d_palette_get_parent(const struct wined3d_palette *palette);
ULONG __cdecl wined3d_palette_incref(struct wined3d_palette *palette);
HRESULT __cdecl wined3d_palette_set_entries(struct wined3d_palette *palette,
DWORD flags, DWORD start, DWORD count, const PALETTEENTRY *entries);
HRESULT __cdecl wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock);
HRESULT __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);
......
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