~ [ 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 ddraw_palette_QueryInterface(IDirectDrawPalette *iface, REFIID refiid, void **obj)
 41 {
 42     TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(refiid), obj);
 43 
 44     if (IsEqualGUID(refiid, &IID_IUnknown)
 45         || IsEqualGUID(refiid, &IID_IDirectDrawPalette))
 46     {
 47         *obj = iface;
 48         IDirectDrawPalette_AddRef(iface);
 49         return S_OK;
 50     }
 51     else
 52     {
 53         *obj = NULL;
 54         return E_NOINTERFACE;
 55     }
 56 }
 57 
 58 /*****************************************************************************
 59  * IDirectDrawPaletteImpl::AddRef
 60  *
 61  * Increases the refcount.
 62  *
 63  * Returns:
 64  *  The new refcount
 65  *
 66  *****************************************************************************/
 67 static ULONG WINAPI ddraw_palette_AddRef(IDirectDrawPalette *iface)
 68 {
 69     struct ddraw_palette *This = impl_from_IDirectDrawPalette(iface);
 70     ULONG ref = InterlockedIncrement(&This->ref);
 71 
 72     TRACE("%p increasing refcount to %u.\n", This, ref);
 73 
 74     return ref;
 75 }
 76 
 77 /*****************************************************************************
 78  * IDirectDrawPaletteImpl::Release
 79  *
 80  * Reduces the refcount. If the refcount falls to 0, the object is destroyed
 81  *
 82  * Returns:
 83  *  The new refcount
 84  *
 85  *****************************************************************************/
 86 static ULONG WINAPI ddraw_palette_Release(IDirectDrawPalette *iface)
 87 {
 88     struct ddraw_palette *This = impl_from_IDirectDrawPalette(iface);
 89     ULONG ref = InterlockedDecrement(&This->ref);
 90 
 91     TRACE("%p decreasing refcount to %u.\n", This, ref);
 92 
 93     if (ref == 0)
 94     {
 95         wined3d_mutex_lock();
 96         wined3d_palette_decref(This->wineD3DPalette);
 97         if(This->ifaceToRelease)
 98         {
 99             IUnknown_Release(This->ifaceToRelease);
100         }
101         wined3d_mutex_unlock();
102 
103         HeapFree(GetProcessHeap(), 0, This);
104     }
105 
106     return ref;
107 }
108 
109 /*****************************************************************************
110  * IDirectDrawPalette::Initialize
111  *
112  * Initializes the palette. As we start initialized, return
113  * DDERR_ALREADYINITIALIZED
114  *
115  * Params:
116  *  DD: DirectDraw interface this palette is assigned to
117  *  Flags: Some flags, as usual
118  *  ColorTable: The startup color table
119  *
120  * Returns:
121  *  DDERR_ALREADYINITIALIZED
122  *
123  *****************************************************************************/
124 static HRESULT WINAPI ddraw_palette_Initialize(IDirectDrawPalette *iface,
125         IDirectDraw *ddraw, DWORD flags, PALETTEENTRY *entries)
126 {
127     TRACE("iface %p, ddraw %p, flags %#x, entries %p.\n",
128             iface, ddraw, flags, entries);
129 
130     return DDERR_ALREADYINITIALIZED;
131 }
132 
133 /*****************************************************************************
134  * IDirectDrawPalette::GetCaps
135  *
136  * Returns the palette description
137  *
138  * Params:
139  *  Caps: Address to store the caps at
140  *
141  * Returns:
142  *  D3D_OK on success
143  *  DDERR_INVALIDPARAMS if Caps is NULL
144  *  For more details, see IWineD3DPalette::GetCaps
145  *
146  *****************************************************************************/
147 static HRESULT WINAPI ddraw_palette_GetCaps(IDirectDrawPalette *iface, DWORD *caps)
148 {
149     struct ddraw_palette *palette = impl_from_IDirectDrawPalette(iface);
150 
151     TRACE("iface %p, caps %p.\n", iface, caps);
152 
153     wined3d_mutex_lock();
154     *caps = wined3d_palette_get_flags(palette->wineD3DPalette);
155     wined3d_mutex_unlock();
156 
157     return D3D_OK;
158 }
159 
160 /*****************************************************************************
161  * IDirectDrawPalette::SetEntries
162  *
163  * Sets the palette entries from a PALETTEENTRY structure. WineD3D takes
164  * care for updating the surface.
165  *
166  * Params:
167  *  Flags: Flags, as usual
168  *  Start: First palette entry to set
169  *  Count: Number of entries to set
170  *  PalEnt: Source entries
171  *
172  * Returns:
173  *  D3D_OK on success
174  *  DDERR_INVALIDPARAMS if PalEnt is NULL
175  *  For details, see IWineD3DDevice::SetEntries
176  *
177  *****************************************************************************/
178 static HRESULT WINAPI ddraw_palette_SetEntries(IDirectDrawPalette *iface,
179         DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries)
180 {
181     struct ddraw_palette *palette = impl_from_IDirectDrawPalette(iface);
182     HRESULT hr;
183 
184     TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n",
185             iface, flags, start, count, entries);
186 
187     if (!entries)
188         return DDERR_INVALIDPARAMS;
189 
190     wined3d_mutex_lock();
191     hr = wined3d_palette_set_entries(palette->wineD3DPalette, flags, start, count, entries);
192     wined3d_mutex_unlock();
193 
194     return hr;
195 }
196 
197 /*****************************************************************************
198  * IDirectDrawPalette::GetEntries
199  *
200  * Returns the entries stored in this interface.
201  *
202  * Params:
203  *  Flags: Flags :)
204  *  Start: First entry to return
205  *  Count: The number of entries to return
206  *  PalEnt: PALETTEENTRY structure to write the entries to
207  *
208  * Returns:
209  *  D3D_OK on success
210  *  DDERR_INVALIDPARAMS if PalEnt is NULL
211  *  For details, see IWineD3DDevice::SetEntries
212  *
213  *****************************************************************************/
214 static HRESULT WINAPI ddraw_palette_GetEntries(IDirectDrawPalette *iface,
215         DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries)
216 {
217     struct ddraw_palette *palette = impl_from_IDirectDrawPalette(iface);
218     HRESULT hr;
219 
220     TRACE("iface %p, flags %#x, start %u, count %u, entries %p.\n",
221             iface, flags, start, count, entries);
222 
223     if (!entries)
224         return DDERR_INVALIDPARAMS;
225 
226     wined3d_mutex_lock();
227     hr = wined3d_palette_get_entries(palette->wineD3DPalette, flags, start, count, entries);
228     wined3d_mutex_unlock();
229 
230     return hr;
231 }
232 
233 static const struct IDirectDrawPaletteVtbl ddraw_palette_vtbl =
234 {
235     /*** IUnknown ***/
236     ddraw_palette_QueryInterface,
237     ddraw_palette_AddRef,
238     ddraw_palette_Release,
239     /*** IDirectDrawPalette ***/
240     ddraw_palette_GetCaps,
241     ddraw_palette_GetEntries,
242     ddraw_palette_Initialize,
243     ddraw_palette_SetEntries
244 };
245 
246 struct ddraw_palette *unsafe_impl_from_IDirectDrawPalette(IDirectDrawPalette *iface)
247 {
248     if (!iface) return NULL;
249     assert(iface->lpVtbl == &ddraw_palette_vtbl);
250     return CONTAINING_RECORD(iface, struct ddraw_palette, IDirectDrawPalette_iface);
251 }
252 
253 HRESULT ddraw_palette_init(struct ddraw_palette *palette,
254         struct ddraw *ddraw, DWORD flags, PALETTEENTRY *entries)
255 {
256     HRESULT hr;
257 
258     palette->IDirectDrawPalette_iface.lpVtbl = &ddraw_palette_vtbl;
259     palette->ref = 1;
260 
261     hr = wined3d_palette_create(ddraw->wined3d_device, flags,
262             entries, palette, &palette->wineD3DPalette);
263     if (FAILED(hr))
264     {
265         WARN("Failed to create wined3d palette, hr %#x.\n", hr);
266         return hr;
267     }
268 
269     palette->ifaceToRelease = (IUnknown *)&ddraw->IDirectDraw7_iface;
270     IUnknown_AddRef(palette->ifaceToRelease);
271 
272     return DD_OK;
273 }
274 

~ [ 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.