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
36 #include "ddraw_private.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
42 /*****************************************************************************
44 *****************************************************************************/
46 /*****************************************************************************
47 * IDirectDrawClipper::QueryInterface
49 * Can query the IUnknown and IDirectDrawClipper interface from a
50 * Clipper object. The IUnknown Interface is equal to the IDirectDrawClipper
51 * interface. Can't create other interfaces.
54 * riid: Interface id asked for
55 * ppvObj: Returns the pointer to the interface
59 * E_NOINTERFACE if the requested interface wasn't found.
61 *****************************************************************************/
62 static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface(
63 LPDIRECTDRAWCLIPPER iface, REFIID riid, LPVOID* ppvObj
65 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
67 if (IsEqualGUID(&IID_IUnknown, riid)
68 || IsEqualGUID(&IID_IDirectDrawClipper, riid))
70 *ppvObj = ICOM_INTERFACE(This, IDirectDrawClipper);
71 InterlockedIncrement(&This->ref);
80 /*****************************************************************************
81 * IDirectDrawClipper::AddRef
83 * Increases the reference count of the interface, returns the new count
85 *****************************************************************************/
86 static ULONG WINAPI IDirectDrawClipperImpl_AddRef( LPDIRECTDRAWCLIPPER iface )
88 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
89 ULONG ref = InterlockedIncrement(&This->ref);
91 TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
96 /*****************************************************************************
97 * IDirectDrawClipper::Release
99 * Decreases the reference count of the interface, returns the new count
100 * If the refcount is decreased to 0, the interface is destroyed.
102 *****************************************************************************/
103 static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface) {
104 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
105 ULONG ref = InterlockedDecrement(&This->ref);
107 TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
111 EnterCriticalSection(&ddraw_cs);
112 IWineD3DClipper_Release(This->wineD3DClipper);
113 HeapFree(GetProcessHeap(), 0, This);
114 LeaveCriticalSection(&ddraw_cs);
120 /*****************************************************************************
121 * IDirectDrawClipper::SetHwnd
123 * Assigns a hWnd to the clipper interface.
126 * Flags: Unsupported so far
127 * hWnd: The hWnd to set
131 * DDERR_INVALIDPARAMS if Flags was != 0
133 *****************************************************************************/
135 static HRESULT WINAPI IDirectDrawClipperImpl_SetHwnd(
136 LPDIRECTDRAWCLIPPER iface, DWORD dwFlags, HWND hWnd
138 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
140 TRACE("(%p)->(%08x,%p)\n", This, dwFlags, hWnd);
142 EnterCriticalSection(&ddraw_cs);
143 hr = IWineD3DClipper_SetHWnd(This->wineD3DClipper,
146 LeaveCriticalSection(&ddraw_cs);
149 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
154 /*****************************************************************************
155 * IDirectDrawClipper::GetClipList
157 * Retrieve a copy of the clip list
160 * Rect: Rectangle to be used to clip the clip list or NULL for the
162 * ClipList: structure for the resulting copy of the clip list.
163 * If NULL, fills Size up to the number of bytes necessary to hold
165 * Size: Size of resulting clip list; size of the buffer at ClipList
166 * or, if ClipList is NULL, receives the required size of the buffer
170 * Either DD_OK or DDERR_*
171 ************************************************************************/
172 static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(
173 LPDIRECTDRAWCLIPPER iface, LPRECT lpRect, LPRGNDATA lpClipList,
176 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
178 TRACE("(%p,%p,%p,%p)\n", This, lpRect, lpClipList, lpdwSize);
180 EnterCriticalSection(&ddraw_cs);
181 hr = IWineD3DClipper_GetClipList(This->wineD3DClipper,
185 LeaveCriticalSection(&ddraw_cs);
189 /*****************************************************************************
190 * IDirectDrawClipper::SetClipList
192 * Sets or deletes (if lprgn is NULL) the clip list
194 * This implementation is a stub and returns DD_OK always to make the app
198 * lprgn Pointer to a LRGNDATA structure or NULL
199 * dwFlags not used, must be 0
201 * Either DD_OK or DDERR_*
202 *****************************************************************************/
203 static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(
204 LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,DWORD dwFlag
206 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
209 EnterCriticalSection(&ddraw_cs);
210 hr = IWineD3DClipper_SetClipList(This->wineD3DClipper,
213 LeaveCriticalSection(&ddraw_cs);
217 /*****************************************************************************
218 * IDirectDrawClipper::GetHwnd
220 * Returns the hwnd assigned with SetHwnd
223 * hWndPtr: Address to store the HWND at
226 * Always returns DD_OK;
227 *****************************************************************************/
228 static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(
229 LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr
231 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
233 TRACE("(%p)->(%p)\n", This, hWndPtr);
235 EnterCriticalSection(&ddraw_cs);
236 hr = IWineD3DClipper_GetHWnd(This->wineD3DClipper,
238 LeaveCriticalSection(&ddraw_cs);
242 /*****************************************************************************
243 * IDirectDrawClipper::Initialize
245 * Initializes the interface. Well, there isn't much to do for this
246 * implementation, but it stores the DirectDraw Interface.
249 * DD: Pointer to a IDirectDraw interface
250 * Flags: Unsupported by now
254 * DDERR_ALREADYINITIALIZED if this interface isn't initialized already
255 *****************************************************************************/
256 static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(
257 LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags
259 IDirectDrawImpl* pOwner;
260 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
261 TRACE("(%p)->(%p,0x%08x)\n", This, lpDD, dwFlags);
263 EnterCriticalSection(&ddraw_cs);
264 if (This->ddraw_owner != NULL)
266 LeaveCriticalSection(&ddraw_cs);
267 return DDERR_ALREADYINITIALIZED;
270 pOwner = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, lpDD);
271 This->ddraw_owner = pOwner;
273 LeaveCriticalSection(&ddraw_cs);
277 /*****************************************************************************
278 * IDirectDrawClipper::IsClipListChanged
280 * This function is a stub
286 * DD_OK, because it's a stub
287 *****************************************************************************/
288 static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged(
289 LPDIRECTDRAWCLIPPER iface, BOOL* lpbChanged
291 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
292 FIXME("(%p)->(%p),stub!\n",This,lpbChanged);
294 /* XXX What is safest? */
300 /*****************************************************************************
302 *****************************************************************************/
303 const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl =
305 IDirectDrawClipperImpl_QueryInterface,
306 IDirectDrawClipperImpl_AddRef,
307 IDirectDrawClipperImpl_Release,
308 IDirectDrawClipperImpl_GetClipList,
309 IDirectDrawClipperImpl_GetHWnd,
310 IDirectDrawClipperImpl_Initialize,
311 IDirectDrawClipperImpl_IsClipListChanged,
312 IDirectDrawClipperImpl_SetClipList,
313 IDirectDrawClipperImpl_SetHwnd