-/* DirectDraw - IDirectPalette base interface
- *
+/*
* Copyright 2006 Stefan Dösinger
*
* This library is free software; you can redistribute it and/or
*/
#include "config.h"
-#include "winerror.h"
-#include "wine/debug.h"
-
-#define COBJMACROS
-
-#include <assert.h>
-#include <string.h>
+#include "wine/port.h"
#include "ddraw_private.h"
REFIID refiid,
void **obj)
{
- IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
- TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(refiid), obj);
if (IsEqualGUID(refiid, &IID_IUnknown)
|| IsEqualGUID(refiid, &IID_IDirectDrawPalette))
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
+ TRACE("%p increasing refcount to %u.\n", This, ref);
return ref;
}
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
- TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
+ TRACE("%p decreasing refcount to %u.\n", This, ref);
if (ref == 0)
{
DWORD Flags,
PALETTEENTRY *ColorTable)
{
- TRACE("(%p)->(%p,%x,%p)\n", iface, DD, Flags, ColorTable);
+ TRACE("iface %p, ddraw %p, flags %#x, entries %p.\n",
+ iface, DD, Flags, ColorTable);
+
return DDERR_ALREADYINITIALIZED;
}
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
HRESULT hr;
- TRACE("(%p)->(%p): Relay\n", This, Caps);
+
+ TRACE("iface %p, caps %p.\n", iface, Caps);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DPalette_GetCaps(This->wineD3DPalette, Caps);
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
HRESULT hr;
- TRACE("(%p)->(%x,%d,%d,%p): Relay\n", This, Flags, Start, Count, PalEnt);
+
+ TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n",
+ iface, Flags, Start, Count, PalEnt);
if(!PalEnt)
return DDERR_INVALIDPARAMS;
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
HRESULT hr;
- TRACE("(%p)->(%x,%d,%d,%p): Relay\n", This, Flags, Start, Count, PalEnt);
+
+ TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n",
+ iface, Flags, Start, Count, PalEnt);
if(!PalEnt)
return DDERR_INVALIDPARAMS;
return hr;
}
-const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl =
+static const struct IDirectDrawPaletteVtbl ddraw_palette_vtbl =
{
/*** IUnknown ***/
IDirectDrawPaletteImpl_QueryInterface,
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, &palette->wineD3DPalette);
+ 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;
+}