~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/ddraw/palette.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Copyright 2006 Stefan Dösinger
  3  *
  4  * This library is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2.1 of the License, or (at your option) any later version.
  8  *
  9  * This library is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with this library; if not, write to the Free Software
 16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 17  */
 18 
 19 #include "config.h"
 20 #include "wine/port.h"
 21 
 22 #include "ddraw_private.h"
 23 
 24 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
 25 
 26 /*****************************************************************************
 27  * IDirectDrawPalette::QueryInterface
 28  *
 29  * A usual QueryInterface implementation. Can only Query IUnknown and
 30  * IDirectDrawPalette
 31  *
 32  * Params:
 33  *  refiid: The interface id queried for
 34  *  obj: Address to return the interface pointer at
 35  *
 36  * Returns:
 37  *  S_OK on success
 38  *  E_NOINTERFACE if the requested interface wasn't found
 39  *****************************************************************************/
 40 static HRESULT WINAPI
 41 IDirectDrawPaletteImpl_QueryInterface(IDirectDrawPalette *iface,
 42                                       REFIID refiid,
 43                                       void **obj)
 44 {
 45     TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(refiid), obj);
 46 
 47     if (IsEqualGUID(refiid, &IID_IUnknown)
 48         || IsEqualGUID(refiid, &IID_IDirectDrawPalette))
 49     {
 50         *obj = iface;
 51         IDirectDrawPalette_AddRef(iface);
 52         return S_OK;
 53     }
 54     else
 55     {
 56         *obj = NULL;
 57         return E_NOINTERFACE;
 58     }
 59 }
 60 
 61 /*****************************************************************************
 62  * IDirectDrawPaletteImpl::AddRef
 63  *
 64  * Increases the refcount.
 65  *
 66  * Returns:
 67  *  The new refcount
 68  *
 69  *****************************************************************************/
 70 static ULONG WINAPI
 71 IDirectDrawPaletteImpl_AddRef(IDirectDrawPalette *iface)
 72 {
 73     IDirectDrawPaletteImpl *This = impl_from_IDirectDrawPalette(iface);
 74     ULONG ref = InterlockedIncrement(&This->ref);
 75 
 76     TRACE("%p increasing refcount to %u.\n", This, ref);
 77 
 78     return ref;
 79 }
 80 
 81 /*****************************************************************************
 82  * IDirectDrawPaletteImpl::Release
 83  *
 84  * Reduces the refcount. If the refcount falls to 0, the object is destroyed
 85  *
 86  * Returns:
 87  *  The new refcount
 88  *
 89  *****************************************************************************/
 90 static ULONG WINAPI
 91 IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface)
 92 {
 93     IDirectDrawPaletteImpl *This = impl_from_IDirectDrawPalette(iface);
 94     ULONG ref = InterlockedDecrement(&This->ref);
 95 
 96     TRACE("%p decreasing refcount to %u.\n", This, ref);
 97 
 98     if (ref == 0)
 99     {
100         EnterCriticalSection(&ddraw_cs);
101         wined3d_palette_decref(This->wineD3DPalette);
102         if(This->ifaceToRelease)
103         {
104             IUnknown_Release(This->ifaceToRelease);
105         }
106         LeaveCriticalSection(&ddraw_cs);
107         HeapFree(GetProcessHeap(), 0, This);
108     }
109 
110     return ref;
111 }
112 
113 /*****************************************************************************
114  * IDirectDrawPalette::Initialize
115  *
116  * Initializes the palette. As we start initialized, return
117  * DDERR_ALREADYINITIALIZED
118  *
119  * Params:
120  *  DD: DirectDraw interface this palette is assigned to
121  *  Flags: Some flags, as usual
122  *  ColorTable: The startup color table
123  *
124  * Returns:
125  *  DDERR_ALREADYINITIALIZED
126  *
127  *****************************************************************************/
128 static HRESULT WINAPI
129 IDirectDrawPaletteImpl_Initialize(IDirectDrawPalette *iface,
130                                   IDirectDraw *DD,
131                                   DWORD Flags,
132                                   PALETTEENTRY *ColorTable)
133 {
134     TRACE("iface %p, ddraw %p, flags %#x, entries %p.\n",
135             iface, DD, Flags, ColorTable);
136 
137     return DDERR_ALREADYINITIALIZED;
138 }
139 
140 /*****************************************************************************
141  * IDirectDrawPalette::GetCaps
142  *
143  * Returns the palette description
144  *
145  * Params:
146  *  Caps: Address to store the caps at
147  *
148  * Returns:
149  *  D3D_OK on success
150  *  DDERR_INVALIDPARAMS if Caps is NULL
151  *  For more details, see IWineD3DPalette::GetCaps
152  *
153  *****************************************************************************/
154 static HRESULT WINAPI
155 IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette *iface,
156                                DWORD *Caps)
157 {
158     IDirectDrawPaletteImpl *This = impl_from_IDirectDrawPalette(iface);
159 
160     TRACE("iface %p, caps %p.\n", iface, Caps);
161 
162     EnterCriticalSection(&ddraw_cs);
163     *Caps = wined3d_palette_get_flags(This->wineD3DPalette);
164     LeaveCriticalSection(&ddraw_cs);
165 
166     return D3D_OK;
167 }
168 
169 /*****************************************************************************
170  * IDirectDrawPalette::SetEntries
171  *
172  * Sets the palette entries from a PALETTEENTRY structure. WineD3D takes
173  * care for updating the surface.
174  *
175  * Params:
176  *  Flags: Flags, as usual
177  *  Start: First palette entry to set
178  *  Count: Number of entries to set
179  *  PalEnt: Source entries
180  *
181  * Returns:
182  *  D3D_OK on success
183  *  DDERR_INVALIDPARAMS if PalEnt is NULL
184  *  For details, see IWineD3DDevice::SetEntries
185  *
186  *****************************************************************************/
187 static HRESULT WINAPI
188 IDirectDrawPaletteImpl_SetEntries(IDirectDrawPalette *iface,
189                                   DWORD Flags,
190                                   DWORD Start,
191                                   DWORD Count,
192                                   PALETTEENTRY *PalEnt)
193 {
194     IDirectDrawPaletteImpl *This = impl_from_IDirectDrawPalette(iface);
195     HRESULT hr;
196 
197     TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n",
198             iface, Flags, Start, Count, PalEnt);
199 
200     if(!PalEnt)
201         return DDERR_INVALIDPARAMS;
202 
203     EnterCriticalSection(&ddraw_cs);
204     hr = wined3d_palette_set_entries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
205     LeaveCriticalSection(&ddraw_cs);
206     return hr;
207 }
208 
209 /*****************************************************************************
210  * IDirectDrawPalette::GetEntries
211  *
212  * Returns the entries stored in this interface.
213  *
214  * Params:
215  *  Flags: Flags :)
216  *  Start: First entry to return
217  *  Count: The number of entries to return
218  *  PalEnt: PALETTEENTRY structure to write the entries to
219  *
220  * Returns:
221  *  D3D_OK on success
222  *  DDERR_INVALIDPARAMS if PalEnt is NULL
223  *  For details, see IWineD3DDevice::SetEntries
224  *
225  *****************************************************************************/
226 static HRESULT WINAPI
227 IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface,
228                                   DWORD Flags,
229                                   DWORD Start,
230                                   DWORD Count,
231                                   PALETTEENTRY *PalEnt)
232 {
233     IDirectDrawPaletteImpl *This = impl_from_IDirectDrawPalette(iface);
234     HRESULT hr;
235 
236     TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n",
237             iface, Flags, Start, Count, PalEnt);
238 
239     if(!PalEnt)
240         return DDERR_INVALIDPARAMS;
241 
242     EnterCriticalSection(&ddraw_cs);
243     hr = wined3d_palette_get_entries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
244     LeaveCriticalSection(&ddraw_cs);
245     return hr;
246 }
247 
248 static const struct IDirectDrawPaletteVtbl ddraw_palette_vtbl =
249 {
250     /*** IUnknown ***/
251     IDirectDrawPaletteImpl_QueryInterface,
252     IDirectDrawPaletteImpl_AddRef,
253     IDirectDrawPaletteImpl_Release,
254     /*** IDirectDrawPalette ***/
255     IDirectDrawPaletteImpl_GetCaps,
256     IDirectDrawPaletteImpl_GetEntries,
257     IDirectDrawPaletteImpl_Initialize,
258     IDirectDrawPaletteImpl_SetEntries
259 };
260 
261 IDirectDrawPaletteImpl *unsafe_impl_from_IDirectDrawPalette(IDirectDrawPalette *iface)
262 {
263     if (!iface) return NULL;
264     assert(iface->lpVtbl == &ddraw_palette_vtbl);
265     return CONTAINING_RECORD(iface, IDirectDrawPaletteImpl, IDirectDrawPalette_iface);
266 }
267 
268 HRESULT ddraw_palette_init(IDirectDrawPaletteImpl *palette,
269         IDirectDrawImpl *ddraw, DWORD flags, PALETTEENTRY *entries)
270 {
271     HRESULT hr;
272 
273     palette->IDirectDrawPalette_iface.lpVtbl = &ddraw_palette_vtbl;
274     palette->ref = 1;
275 
276     hr = wined3d_palette_create(ddraw->wined3d_device, flags,
277             entries, palette, &palette->wineD3DPalette);
278     if (FAILED(hr))
279     {
280         WARN("Failed to create wined3d palette, hr %#x.\n", hr);
281         return hr;
282     }
283 
284     palette->ifaceToRelease = (IUnknown *)&ddraw->IDirectDraw7_iface;
285     IUnknown_AddRef(palette->ifaceToRelease);
286 
287     return DD_OK;
288 }
289 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.