~ [ 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 /*              DirectDraw - IDirectPalette base interface
  2  *
  3  * Copyright 2006 Stefan Dösinger
  4  *
  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.
  9  *
 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.
 14  *
 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
 18  */
 19 
 20 #include "config.h"
 21 #include "winerror.h"
 22 #include "wine/debug.h"
 23 
 24 #define COBJMACROS
 25 
 26 #include <assert.h>
 27 #include <string.h>
 28 
 29 #include "ddraw_private.h"
 30 
 31 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
 32 
 33 /*****************************************************************************
 34  * IDirectDrawPalette::QueryInterface
 35  *
 36  * A usual QueryInterface implementation. Can only Query IUnknown and
 37  * IDirectDrawPalette
 38  *
 39  * Params:
 40  *  refiid: The interface id queried for
 41  *  obj: Address to return the interface pointer at
 42  *
 43  * Returns:
 44  *  S_OK on success
 45  *  E_NOINTERFACE if the requested interface wasn't found
 46  *****************************************************************************/
 47 static HRESULT WINAPI
 48 IDirectDrawPaletteImpl_QueryInterface(IDirectDrawPalette *iface,
 49                                       REFIID refiid,
 50                                       void **obj)
 51 {
 52     IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
 53     TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
 54 
 55     if (IsEqualGUID(refiid, &IID_IUnknown)
 56         || IsEqualGUID(refiid, &IID_IDirectDrawPalette))
 57     {
 58         *obj = iface;
 59         IDirectDrawPalette_AddRef(iface);
 60         return S_OK;
 61     }
 62     else
 63     {
 64         *obj = NULL;
 65         return E_NOINTERFACE;
 66     }
 67 }
 68 
 69 /*****************************************************************************
 70  * IDirectDrawPaletteImpl::AddRef
 71  *
 72  * Increases the refcount.
 73  *
 74  * Returns:
 75  *  The new refcount
 76  *
 77  *****************************************************************************/
 78 static ULONG WINAPI
 79 IDirectDrawPaletteImpl_AddRef(IDirectDrawPalette *iface)
 80 {
 81     IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
 82     ULONG ref = InterlockedIncrement(&This->ref);
 83 
 84     TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
 85 
 86     return ref;
 87 }
 88 
 89 /*****************************************************************************
 90  * IDirectDrawPaletteImpl::Release
 91  *
 92  * Reduces the refcount. If the refcount falls to 0, the object is destroyed
 93  *
 94  * Returns:
 95  *  The new refcount
 96  *
 97  *****************************************************************************/
 98 static ULONG WINAPI
 99 IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface)
100 {
101     IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
102     ULONG ref = InterlockedDecrement(&This->ref);
103 
104     TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
105 
106     if (ref == 0)
107     {
108         EnterCriticalSection(&ddraw_cs);
109         IWineD3DPalette_Release(This->wineD3DPalette);
110         if(This->ifaceToRelease)
111         {
112             IUnknown_Release(This->ifaceToRelease);
113         }
114         LeaveCriticalSection(&ddraw_cs);
115         HeapFree(GetProcessHeap(), 0, This);
116     }
117 
118     return ref;
119 }
120 
121 /*****************************************************************************
122  * IDirectDrawPalette::Initialize
123  *
124  * Initializes the palette. As we start initialized, return
125  * DDERR_ALREADYINITIALIZED
126  *
127  * Params:
128  *  DD: DirectDraw interface this palette is assigned to
129  *  Flags: Some flags, as usual
130  *  ColorTable: The startup color table
131  *
132  * Returns:
133  *  DDERR_ALREADYINITIALIZED
134  *
135  *****************************************************************************/
136 static HRESULT WINAPI
137 IDirectDrawPaletteImpl_Initialize(IDirectDrawPalette *iface,
138                                   IDirectDraw *DD,
139                                   DWORD Flags,
140                                   PALETTEENTRY *ColorTable)
141 {
142     TRACE("(%p)->(%p,%x,%p)\n", iface, DD, Flags, ColorTable);
143     return DDERR_ALREADYINITIALIZED;
144 }
145 
146 /*****************************************************************************
147  * IDirectDrawPalette::GetCaps
148  *
149  * Returns the palette description
150  *
151  * Params:
152  *  Caps: Address to store the caps at
153  *
154  * Returns:
155  *  D3D_OK on success
156  *  DDERR_INVALIDPARAMS if Caps is NULL
157  *  For more details, see IWineD3DPalette::GetCaps
158  *
159  *****************************************************************************/
160 static HRESULT WINAPI
161 IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette *iface,
162                                DWORD *Caps)
163 {
164     IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
165     HRESULT hr;
166     TRACE("(%p)->(%p): Relay\n", This, Caps);
167 
168     EnterCriticalSection(&ddraw_cs);
169     hr = IWineD3DPalette_GetCaps(This->wineD3DPalette, Caps);
170     LeaveCriticalSection(&ddraw_cs);
171     return hr;
172 }
173 
174 /*****************************************************************************
175  * IDirectDrawPalette::SetEntries
176  *
177  * Sets the palette entries from a PALETTEENTRY structure. WineD3D takes
178  * care for updating the surface.
179  *
180  * Params:
181  *  Flags: Flags, as usual
182  *  Start: First palette entry to set
183  *  Count: Number of entries to set
184  *  PalEnt: Source entries
185  *
186  * Returns:
187  *  D3D_OK on success
188  *  DDERR_INVALIDPARAMS if PalEnt is NULL
189  *  For details, see IWineD3DDevice::SetEntries
190  *
191  *****************************************************************************/
192 static HRESULT WINAPI
193 IDirectDrawPaletteImpl_SetEntries(IDirectDrawPalette *iface,
194                                   DWORD Flags,
195                                   DWORD Start,
196                                   DWORD Count,
197                                   PALETTEENTRY *PalEnt)
198 {
199     IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
200     HRESULT hr;
201     TRACE("(%p)->(%x,%d,%d,%p): Relay\n", This, Flags, Start, Count, PalEnt);
202 
203     if(!PalEnt)
204         return DDERR_INVALIDPARAMS;
205 
206     EnterCriticalSection(&ddraw_cs);
207     hr = IWineD3DPalette_SetEntries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
208     LeaveCriticalSection(&ddraw_cs);
209     return hr;
210 }
211 
212 /*****************************************************************************
213  * IDirectDrawPalette::GetEntries
214  *
215  * Returns the entries stored in this interface.
216  *
217  * Params:
218  *  Flags: Flags :)
219  *  Start: First entry to return
220  *  Count: The number of entries to return
221  *  PalEnt: PALETTEENTRY structure to write the entries to
222  *
223  * Returns:
224  *  D3D_OK on success
225  *  DDERR_INVALIDPARAMS if PalEnt is NULL
226  *  For details, see IWineD3DDevice::SetEntries
227  *
228  *****************************************************************************/
229 static HRESULT WINAPI
230 IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface,
231                                   DWORD Flags,
232                                   DWORD Start,
233                                   DWORD Count,
234                                   PALETTEENTRY *PalEnt)
235 {
236     IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
237     HRESULT hr;
238     TRACE("(%p)->(%x,%d,%d,%p): Relay\n", This, Flags, Start, Count, PalEnt);
239 
240     if(!PalEnt)
241         return DDERR_INVALIDPARAMS;
242 
243     EnterCriticalSection(&ddraw_cs);
244     hr = IWineD3DPalette_GetEntries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
245     LeaveCriticalSection(&ddraw_cs);
246     return hr;
247 }
248 
249 const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl =
250 {
251     /*** IUnknown ***/
252     IDirectDrawPaletteImpl_QueryInterface,
253     IDirectDrawPaletteImpl_AddRef,
254     IDirectDrawPaletteImpl_Release,
255     /*** IDirectDrawPalette ***/
256     IDirectDrawPaletteImpl_GetCaps,
257     IDirectDrawPaletteImpl_GetEntries,
258     IDirectDrawPaletteImpl_Initialize,
259     IDirectDrawPaletteImpl_SetEntries
260 };
261 

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