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"
29 #include "ddraw_private.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(ddraw
);
33 /*****************************************************************************
34 * IDirectDrawPalette::QueryInterface
36 * A usual QueryInterface implementation. Can only Query IUnknown and
40 * refiid: The interface id queried for
41 * obj: Address to return the interface pointer at
45 * E_NOINTERFACE if the requested interface wasn't found
46 *****************************************************************************/
48 IDirectDrawPaletteImpl_QueryInterface(IDirectDrawPalette
*iface
,
52 ICOM_THIS_FROM(IDirectDrawPaletteImpl
, IDirectDrawPalette
, iface
);
53 TRACE("(%p)->(%s,%p)\n",This
,debugstr_guid(refiid
),obj
);
55 if (IsEqualGUID(refiid
, &IID_IUnknown
)
56 || IsEqualGUID(refiid
, &IID_IDirectDrawPalette
))
59 IDirectDrawPalette_AddRef(iface
);
69 /*****************************************************************************
70 * IDirectDrawPaletteImpl::AddRef
72 * Increases the refcount.
77 *****************************************************************************/
79 IDirectDrawPaletteImpl_AddRef(IDirectDrawPalette
*iface
)
81 ICOM_THIS_FROM(IDirectDrawPaletteImpl
, IDirectDrawPalette
, iface
);
82 ULONG ref
= InterlockedIncrement(&This
->ref
);
84 TRACE("(%p)->() incrementing from %u.\n", This
, ref
- 1);
89 /*****************************************************************************
90 * IDirectDrawPaletteImpl::Release
92 * Reduces the refcount. If the refcount falls to 0, the object is destroyed
97 *****************************************************************************/
99 IDirectDrawPaletteImpl_Release(IDirectDrawPalette
*iface
)
101 ICOM_THIS_FROM(IDirectDrawPaletteImpl
, IDirectDrawPalette
, iface
);
102 ULONG ref
= InterlockedDecrement(&This
->ref
);
104 TRACE("(%p)->() decrementing from %u.\n", This
, ref
+ 1);
108 EnterCriticalSection(&ddraw_cs
);
109 IWineD3DPalette_Release(This
->wineD3DPalette
);
110 if(This
->ifaceToRelease
)
112 IUnknown_Release(This
->ifaceToRelease
);
114 LeaveCriticalSection(&ddraw_cs
);
115 HeapFree(GetProcessHeap(), 0, This
);
121 /*****************************************************************************
122 * IDirectDrawPalette::Initialize
124 * Initializes the palette. As we start initialized, return
125 * DDERR_ALREADYINITIALIZED
128 * DD: DirectDraw interface this palette is asigned to
129 * Flags: Some flags, as usual
130 * ColorTable: The startup color table
133 * DDERR_ALREADYINITIALIZED
135 *****************************************************************************/
136 static HRESULT WINAPI
137 IDirectDrawPaletteImpl_Initialize(IDirectDrawPalette
*iface
,
140 PALETTEENTRY
*ColorTable
)
142 TRACE("(%p)->(%p,%x,%p)\n", iface
, DD
, Flags
, ColorTable
);
143 return DDERR_ALREADYINITIALIZED
;
146 /*****************************************************************************
147 * IDirectDrawPalette::GetCaps
149 * Returns the palette description
152 * Caps: Address to store the caps at
156 * DDERR_INVALIDPARAMS if Caps is NULL
157 * For more details, see IWineD3DPalette::GetCaps
159 *****************************************************************************/
160 static HRESULT WINAPI
161 IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette
*iface
,
164 ICOM_THIS_FROM(IDirectDrawPaletteImpl
, IDirectDrawPalette
, iface
);
166 TRACE("(%p)->(%p): Relay\n", This
, Caps
);
168 EnterCriticalSection(&ddraw_cs
);
169 hr
= IWineD3DPalette_GetCaps(This
->wineD3DPalette
, Caps
);
170 LeaveCriticalSection(&ddraw_cs
);
174 /*****************************************************************************
175 * IDirectDrawPalette::SetEntries
177 * Sets the palette entries from a PALETTEENTRY structure. WineD3D takes
178 * care for updating the surface.
181 * Flags: Flags, as usual
182 * Start: First palette entry to set
183 * Count: Number of entries to set
184 * PalEnt: Source entries
188 * DDERR_INVALIDPARAMS if PalEnt is NULL
189 * For details, see IWineD3DDevice::SetEntries
191 *****************************************************************************/
192 static HRESULT WINAPI
193 IDirectDrawPaletteImpl_SetEntries(IDirectDrawPalette
*iface
,
197 PALETTEENTRY
*PalEnt
)
199 ICOM_THIS_FROM(IDirectDrawPaletteImpl
, IDirectDrawPalette
, iface
);
201 TRACE("(%p)->(%x,%d,%d,%p): Relay\n", This
, Flags
, Start
, Count
, PalEnt
);
204 return DDERR_INVALIDPARAMS
;
206 EnterCriticalSection(&ddraw_cs
);
207 hr
= IWineD3DPalette_SetEntries(This
->wineD3DPalette
, Flags
, Start
, Count
, PalEnt
);
208 LeaveCriticalSection(&ddraw_cs
);
212 /*****************************************************************************
213 * IDirectDrawPalette::GetEntries
215 * Returns the entries stored in this interface.
219 * Start: First entry to return
220 * Count: The number of entries to return
221 * PalEnt: PALETTEENTRY structure to write the entries to
225 * DDERR_INVALIDPARAMS if PalEnt is NULL
226 * For details, see IWineD3DDevice::SetEntries
228 *****************************************************************************/
229 static HRESULT WINAPI
230 IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette
*iface
,
234 PALETTEENTRY
*PalEnt
)
236 ICOM_THIS_FROM(IDirectDrawPaletteImpl
, IDirectDrawPalette
, iface
);
238 TRACE("(%p)->(%x,%d,%d,%p): Relay\n", This
, Flags
, Start
, Count
, PalEnt
);
241 return DDERR_INVALIDPARAMS
;
243 EnterCriticalSection(&ddraw_cs
);
244 hr
= IWineD3DPalette_GetEntries(This
->wineD3DPalette
, Flags
, Start
, Count
, PalEnt
);
245 LeaveCriticalSection(&ddraw_cs
);
249 const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl
=
252 IDirectDrawPaletteImpl_QueryInterface
,
253 IDirectDrawPaletteImpl_AddRef
,
254 IDirectDrawPaletteImpl_Release
,
255 /*** IDirectDrawPalette ***/
256 IDirectDrawPaletteImpl_GetCaps
,
257 IDirectDrawPaletteImpl_GetEntries
,
258 IDirectDrawPaletteImpl_Initialize
,
259 IDirectDrawPaletteImpl_SetEntries