1 /* DirectDraw - IDirectPalette base interface
3 * Copyright 2006 Stefan Dösinger
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/debug.h"
27 #include "ddraw_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
31 /*****************************************************************************
32 * IDirectDrawPalette::QueryInterface
34 * A usual QueryInterface implementation. Can only Query IUnknown and
38 * refiid: The interface id queried for
39 * obj: Address to return the interface pointer at
43 * E_NOINTERFACE if the requested interface wasn't found
44 *****************************************************************************/
46 IDirectDrawPaletteImpl_QueryInterface(IDirectDrawPalette *iface,
50 ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
51 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
53 if (IsEqualGUID(refiid, &IID_IUnknown)
54 || IsEqualGUID(refiid, &IID_IDirectDrawPalette))
57 IDirectDrawPalette_AddRef(iface);
67 /*****************************************************************************
68 * IDirectDrawPaletteImpl::AddRef
70 * Increases the refcount.
75 *****************************************************************************/
77 IDirectDrawPaletteImpl_AddRef(IDirectDrawPalette *iface)
79 ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
80 ULONG ref = InterlockedIncrement(&This->ref);
82 TRACE("(%p)->() incrementing from %lu.\n", This, ref - 1);
87 /*****************************************************************************
88 * IDirectDrawPaletteImpl::Release
90 * Reduces the refcount. If the refcount falls to 0, the object is destroyed
95 *****************************************************************************/
97 IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface)
99 ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
100 ULONG ref = InterlockedDecrement(&This->ref);
102 TRACE("(%p)->() decrementing from %lu.\n", This, ref + 1);
106 IWineD3DPalette_Release(This->wineD3DPalette);
107 IDirectDraw7_Release(ICOM_INTERFACE(This->ddraw_owner, IDirectDraw7));
108 HeapFree(GetProcessHeap(), 0, This);
114 /*****************************************************************************
115 * IDirectDrawPalette::Initialize
117 * Initializes the palette. As we start initialized, return
118 * DDERR_ALREADYINITIALIZED
121 * DD: DirectDraw interface this palette is asigned to
122 * Flags: Some flags, as usual
123 * ColorTable: The startup color table
126 * DDERR_ALREADYINITIALIZED
128 *****************************************************************************/
129 static HRESULT WINAPI
130 IDirectDrawPaletteImpl_Initialize(IDirectDrawPalette *iface,
133 PALETTEENTRY *ColorTable)
135 TRACE("(%p)->(%p,%lx,%p)\n", iface, DD, Flags, ColorTable);
136 return DDERR_ALREADYINITIALIZED;
139 /*****************************************************************************
140 * IDirectDrawPalette::GetCaps
142 * Returns the palette description
145 * Caps: Address to store the caps at
149 * DDERR_INVALIDPARAMS if Caps is NULL
150 * For more details, see IWineD3DPalette::GetCaps
152 *****************************************************************************/
153 static HRESULT WINAPI
154 IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette *iface,
157 ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
158 TRACE("(%p)->(%p): Relay\n", This, Caps);
160 return IWineD3DPalette_GetCaps(This->wineD3DPalette, Caps);
163 /*****************************************************************************
164 * IDirectDrawPalette::SetEntries
166 * Sets the palette entries from a PALETTEENTRY structure. WineD3D takes
167 * care for updating the surface.
170 * Flags: Flags, as usual
171 * Start: First palette entry to set
172 * Count: Number of entries to set
173 * PalEnt: Source entries
177 * DDERR_INVALIDPARAMS if PalEnt is NULL
178 * For details, see IWineD3DDevice::SetEntries
180 *****************************************************************************/
181 static HRESULT WINAPI
182 IDirectDrawPaletteImpl_SetEntries(IDirectDrawPalette *iface,
186 PALETTEENTRY *PalEnt)
188 ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
189 TRACE("(%p)->(%lx,%ld,%ld,%p): Relay\n", This, Flags, Start, Count, PalEnt);
192 return DDERR_INVALIDPARAMS;
194 return IWineD3DPalette_SetEntries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
197 /*****************************************************************************
198 * IDirectDrawPalette::GetEntries
200 * Returns the entries stored in this interface.
204 * Start: First entry to return
205 * Count: The number of entries to return
206 * PalEnt: PALETTEENTRY structure to write the entries to
210 * DDERR_INVALIDPARAMS if PalEnt is NULL
211 * For details, see IWineD3DDevice::SetEntries
213 *****************************************************************************/
214 static HRESULT WINAPI
215 IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface,
219 PALETTEENTRY *PalEnt)
221 ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
222 TRACE("(%p)->(%lx,%ld,%ld,%p): Relay\n", This, Flags, Start, Count, PalEnt);
225 return DDERR_INVALIDPARAMS;
227 return IWineD3DPalette_GetEntries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
230 const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl =
233 IDirectDrawPaletteImpl_QueryInterface,
234 IDirectDrawPaletteImpl_AddRef,
235 IDirectDrawPaletteImpl_Release,
236 /*** IDirectDrawPalette ***/
237 IDirectDrawPaletteImpl_GetCaps,
238 IDirectDrawPaletteImpl_GetEntries,
239 IDirectDrawPaletteImpl_Initialize,
240 IDirectDrawPaletteImpl_SetEntries