ddraw: Remove unused / redundant includes.
[wine/wine-gecko.git] / dlls / ddraw / clipper.c
blob25e71fa6660b6b4547a404351aabb6507cf3f9ef
1 /* DirectDrawClipper implementation
3 * Copyright 2000 (c) Marcus Meissner
4 * Copyright 2000 (c) TransGaming Technologies Inc.
5 * Copyright 2006 (c) Stefan Dösinger
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
23 #include "wine/port.h"
25 #include "ddraw_private.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
29 /*****************************************************************************
30 * IUnknown methods
31 *****************************************************************************/
33 /*****************************************************************************
34 * IDirectDrawClipper::QueryInterface
36 * Can query the IUnknown and IDirectDrawClipper interface from a
37 * Clipper object. The IUnknown Interface is equal to the IDirectDrawClipper
38 * interface. Can't create other interfaces.
40 * Arguments:
41 * riid: Interface id asked for
42 * ppvObj: Returns the pointer to the interface
44 * Return values:
45 * DD_OK on success
46 * E_NOINTERFACE if the requested interface wasn't found.
48 *****************************************************************************/
49 static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface(
50 LPDIRECTDRAWCLIPPER iface, REFIID riid, LPVOID* ppvObj
51 ) {
52 if (IsEqualGUID(&IID_IUnknown, riid)
53 || IsEqualGUID(&IID_IDirectDrawClipper, riid))
55 IUnknown_AddRef(iface);
56 *ppvObj = iface;
57 return S_OK;
59 else
61 return E_NOINTERFACE;
65 /*****************************************************************************
66 * IDirectDrawClipper::AddRef
68 * Increases the reference count of the interface, returns the new count
70 *****************************************************************************/
71 static ULONG WINAPI IDirectDrawClipperImpl_AddRef( LPDIRECTDRAWCLIPPER iface )
73 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
74 ULONG ref = InterlockedIncrement(&This->ref);
76 TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
78 return ref;
81 /*****************************************************************************
82 * IDirectDrawClipper::Release
84 * Decreases the reference count of the interface, returns the new count
85 * If the refcount is decreased to 0, the interface is destroyed.
87 *****************************************************************************/
88 static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface) {
89 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
90 ULONG ref = InterlockedDecrement(&This->ref);
92 TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
94 if (ref == 0)
96 EnterCriticalSection(&ddraw_cs);
97 IWineD3DClipper_Release(This->wineD3DClipper);
98 HeapFree(GetProcessHeap(), 0, This);
99 LeaveCriticalSection(&ddraw_cs);
100 return 0;
102 else return ref;
105 /*****************************************************************************
106 * IDirectDrawClipper::SetHwnd
108 * Assigns a hWnd to the clipper interface.
110 * Arguments:
111 * Flags: Unsupported so far
112 * hWnd: The hWnd to set
114 * Return values:
115 * DD_OK on success
116 * DDERR_INVALIDPARAMS if Flags was != 0
118 *****************************************************************************/
120 static HRESULT WINAPI IDirectDrawClipperImpl_SetHwnd(
121 LPDIRECTDRAWCLIPPER iface, DWORD dwFlags, HWND hWnd
123 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
124 HRESULT hr;
125 TRACE("(%p)->(%08x,%p)\n", This, dwFlags, hWnd);
127 EnterCriticalSection(&ddraw_cs);
128 hr = IWineD3DClipper_SetHWnd(This->wineD3DClipper,
129 dwFlags,
130 hWnd);
131 LeaveCriticalSection(&ddraw_cs);
132 switch(hr)
134 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
135 default: return hr;
139 /*****************************************************************************
140 * IDirectDrawClipper::GetClipList
142 * Retrieve a copy of the clip list
144 * Arguments:
145 * Rect: Rectangle to be used to clip the clip list or NULL for the
146 * entire clip list
147 * ClipList: structure for the resulting copy of the clip list.
148 * If NULL, fills Size up to the number of bytes necessary to hold
149 * the entire clip.
150 * Size: Size of resulting clip list; size of the buffer at ClipList
151 * or, if ClipList is NULL, receives the required size of the buffer
152 * in bytes
154 * RETURNS
155 * Either DD_OK or DDERR_*
156 ************************************************************************/
157 static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(
158 LPDIRECTDRAWCLIPPER iface, LPRECT lpRect, LPRGNDATA lpClipList,
159 LPDWORD lpdwSize)
161 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
162 HRESULT hr;
163 TRACE("(%p,%p,%p,%p)\n", This, lpRect, lpClipList, lpdwSize);
165 EnterCriticalSection(&ddraw_cs);
166 hr = IWineD3DClipper_GetClipList(This->wineD3DClipper,
167 lpRect,
168 lpClipList,
169 lpdwSize);
170 LeaveCriticalSection(&ddraw_cs);
171 return hr;
174 /*****************************************************************************
175 * IDirectDrawClipper::SetClipList
177 * Sets or deletes (if lprgn is NULL) the clip list
179 * This implementation is a stub and returns DD_OK always to make the app
180 * happy.
182 * PARAMS
183 * lprgn Pointer to a LRGNDATA structure or NULL
184 * dwFlags not used, must be 0
185 * RETURNS
186 * Either DD_OK or DDERR_*
187 *****************************************************************************/
188 static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(
189 LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,DWORD dwFlag
191 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
192 HRESULT hr;
194 EnterCriticalSection(&ddraw_cs);
195 hr = IWineD3DClipper_SetClipList(This->wineD3DClipper,
196 lprgn,
197 dwFlag);
198 LeaveCriticalSection(&ddraw_cs);
199 return hr;
202 /*****************************************************************************
203 * IDirectDrawClipper::GetHwnd
205 * Returns the hwnd assigned with SetHwnd
207 * Arguments:
208 * hWndPtr: Address to store the HWND at
210 * Return values:
211 * Always returns DD_OK;
212 *****************************************************************************/
213 static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(
214 LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr
216 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
217 HRESULT hr;
218 TRACE("(%p)->(%p)\n", This, hWndPtr);
220 EnterCriticalSection(&ddraw_cs);
221 hr = IWineD3DClipper_GetHWnd(This->wineD3DClipper,
222 hWndPtr);
223 LeaveCriticalSection(&ddraw_cs);
224 return hr;
227 /*****************************************************************************
228 * IDirectDrawClipper::Initialize
230 * Initializes the interface. Well, there isn't much to do for this
231 * implementation, but it stores the DirectDraw Interface.
233 * Arguments:
234 * DD: Pointer to a IDirectDraw interface
235 * Flags: Unsupported by now
237 * Return values:
238 * DD_OK on success
239 * DDERR_ALREADYINITIALIZED if this interface isn't initialized already
240 *****************************************************************************/
241 static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(
242 LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags
244 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
245 TRACE("(%p)->(%p,0x%08x)\n", This, lpDD, dwFlags);
247 EnterCriticalSection(&ddraw_cs);
248 if (This->initialized)
250 LeaveCriticalSection(&ddraw_cs);
251 return DDERR_ALREADYINITIALIZED;
254 This->initialized = TRUE;
256 LeaveCriticalSection(&ddraw_cs);
257 return DD_OK;
260 /*****************************************************************************
261 * IDirectDrawClipper::IsClipListChanged
263 * This function is a stub
265 * Arguments:
266 * Changed:
268 * Return values:
269 * DD_OK, because it's a stub
270 *****************************************************************************/
271 static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged(
272 LPDIRECTDRAWCLIPPER iface, BOOL* lpbChanged
274 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
275 FIXME("(%p)->(%p),stub!\n",This,lpbChanged);
277 /* XXX What is safest? */
278 *lpbChanged = FALSE;
280 return DD_OK;
283 /*****************************************************************************
284 * The VTable
285 *****************************************************************************/
286 const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl =
288 IDirectDrawClipperImpl_QueryInterface,
289 IDirectDrawClipperImpl_AddRef,
290 IDirectDrawClipperImpl_Release,
291 IDirectDrawClipperImpl_GetClipList,
292 IDirectDrawClipperImpl_GetHWnd,
293 IDirectDrawClipperImpl_Initialize,
294 IDirectDrawClipperImpl_IsClipListChanged,
295 IDirectDrawClipperImpl_SetClipList,
296 IDirectDrawClipperImpl_SetHwnd