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
23 #include "wine/port.h"
25 #include "ddraw_private.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
29 /*****************************************************************************
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.
41 * riid: Interface id asked for
42 * ppvObj: Returns the pointer to the interface
46 * E_NOINTERFACE if the requested interface wasn't found.
48 *****************************************************************************/
49 static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface(
50 LPDIRECTDRAWCLIPPER iface, REFIID riid, LPVOID* ppvObj
52 if (IsEqualGUID(&IID_IUnknown, riid)
53 || IsEqualGUID(&IID_IDirectDrawClipper, riid))
55 IUnknown_AddRef(iface);
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);
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);
96 EnterCriticalSection(&ddraw_cs);
97 IWineD3DClipper_Release(This->wineD3DClipper);
98 HeapFree(GetProcessHeap(), 0, This);
99 LeaveCriticalSection(&ddraw_cs);
105 /*****************************************************************************
106 * IDirectDrawClipper::SetHwnd
108 * Assigns a hWnd to the clipper interface.
111 * Flags: Unsupported so far
112 * hWnd: The hWnd to set
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;
125 TRACE("(%p)->(%08x,%p)\n", This, dwFlags, hWnd);
127 EnterCriticalSection(&ddraw_cs);
128 hr = IWineD3DClipper_SetHWnd(This->wineD3DClipper,
131 LeaveCriticalSection(&ddraw_cs);
134 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
139 /*****************************************************************************
140 * IDirectDrawClipper::GetClipList
142 * Retrieve a copy of the clip list
145 * Rect: Rectangle to be used to clip the clip list or NULL for the
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
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
155 * Either DD_OK or DDERR_*
156 ************************************************************************/
157 static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(
158 LPDIRECTDRAWCLIPPER iface, LPRECT lpRect, LPRGNDATA lpClipList,
161 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
163 TRACE("(%p,%p,%p,%p)\n", This, lpRect, lpClipList, lpdwSize);
165 EnterCriticalSection(&ddraw_cs);
166 hr = IWineD3DClipper_GetClipList(This->wineD3DClipper,
170 LeaveCriticalSection(&ddraw_cs);
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
183 * lprgn Pointer to a LRGNDATA structure or NULL
184 * dwFlags not used, must be 0
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;
194 EnterCriticalSection(&ddraw_cs);
195 hr = IWineD3DClipper_SetClipList(This->wineD3DClipper,
198 LeaveCriticalSection(&ddraw_cs);
202 /*****************************************************************************
203 * IDirectDrawClipper::GetHwnd
205 * Returns the hwnd assigned with SetHwnd
208 * hWndPtr: Address to store the HWND at
211 * Always returns DD_OK;
212 *****************************************************************************/
213 static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(
214 LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr
216 IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
218 TRACE("(%p)->(%p)\n", This, hWndPtr);
220 EnterCriticalSection(&ddraw_cs);
221 hr = IWineD3DClipper_GetHWnd(This->wineD3DClipper,
223 LeaveCriticalSection(&ddraw_cs);
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.
234 * DD: Pointer to a IDirectDraw interface
235 * Flags: Unsupported by now
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);
260 /*****************************************************************************
261 * IDirectDrawClipper::IsClipListChanged
263 * This function is a stub
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? */
283 /*****************************************************************************
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