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 if (IsEqualGUID(&IID_IUnknown
, riid
)
66 || IsEqualGUID(&IID_IDirectDrawClipper
, riid
))
68 IUnknown_AddRef(iface
);
78 /*****************************************************************************
79 * IDirectDrawClipper::AddRef
81 * Increases the reference count of the interface, returns the new count
83 *****************************************************************************/
84 static ULONG WINAPI
IDirectDrawClipperImpl_AddRef( LPDIRECTDRAWCLIPPER iface
)
86 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
87 ULONG ref
= InterlockedIncrement(&This
->ref
);
89 TRACE("(%p)->() incrementing from %u.\n", This
, ref
- 1);
94 /*****************************************************************************
95 * IDirectDrawClipper::Release
97 * Decreases the reference count of the interface, returns the new count
98 * If the refcount is decreased to 0, the interface is destroyed.
100 *****************************************************************************/
101 static ULONG WINAPI
IDirectDrawClipperImpl_Release(IDirectDrawClipper
*iface
) {
102 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
103 ULONG ref
= InterlockedDecrement(&This
->ref
);
105 TRACE("(%p)->() decrementing from %u.\n", This
, ref
+ 1);
109 EnterCriticalSection(&ddraw_cs
);
110 IWineD3DClipper_Release(This
->wineD3DClipper
);
111 HeapFree(GetProcessHeap(), 0, This
);
112 LeaveCriticalSection(&ddraw_cs
);
118 /*****************************************************************************
119 * IDirectDrawClipper::SetHwnd
121 * Assigns a hWnd to the clipper interface.
124 * Flags: Unsupported so far
125 * hWnd: The hWnd to set
129 * DDERR_INVALIDPARAMS if Flags was != 0
131 *****************************************************************************/
133 static HRESULT WINAPI
IDirectDrawClipperImpl_SetHwnd(
134 LPDIRECTDRAWCLIPPER iface
, DWORD dwFlags
, HWND hWnd
136 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
138 TRACE("(%p)->(%08x,%p)\n", This
, dwFlags
, hWnd
);
140 EnterCriticalSection(&ddraw_cs
);
141 hr
= IWineD3DClipper_SetHWnd(This
->wineD3DClipper
,
144 LeaveCriticalSection(&ddraw_cs
);
147 case WINED3DERR_INVALIDCALL
: return DDERR_INVALIDPARAMS
;
152 /*****************************************************************************
153 * IDirectDrawClipper::GetClipList
155 * Retrieve a copy of the clip list
158 * Rect: Rectangle to be used to clip the clip list or NULL for the
160 * ClipList: structure for the resulting copy of the clip list.
161 * If NULL, fills Size up to the number of bytes necessary to hold
163 * Size: Size of resulting clip list; size of the buffer at ClipList
164 * or, if ClipList is NULL, receives the required size of the buffer
168 * Either DD_OK or DDERR_*
169 ************************************************************************/
170 static HRESULT WINAPI
IDirectDrawClipperImpl_GetClipList(
171 LPDIRECTDRAWCLIPPER iface
, LPRECT lpRect
, LPRGNDATA lpClipList
,
174 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
176 TRACE("(%p,%p,%p,%p)\n", This
, lpRect
, lpClipList
, lpdwSize
);
178 EnterCriticalSection(&ddraw_cs
);
179 hr
= IWineD3DClipper_GetClipList(This
->wineD3DClipper
,
183 LeaveCriticalSection(&ddraw_cs
);
187 /*****************************************************************************
188 * IDirectDrawClipper::SetClipList
190 * Sets or deletes (if lprgn is NULL) the clip list
192 * This implementation is a stub and returns DD_OK always to make the app
196 * lprgn Pointer to a LRGNDATA structure or NULL
197 * dwFlags not used, must be 0
199 * Either DD_OK or DDERR_*
200 *****************************************************************************/
201 static HRESULT WINAPI
IDirectDrawClipperImpl_SetClipList(
202 LPDIRECTDRAWCLIPPER iface
,LPRGNDATA lprgn
,DWORD dwFlag
204 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
207 EnterCriticalSection(&ddraw_cs
);
208 hr
= IWineD3DClipper_SetClipList(This
->wineD3DClipper
,
211 LeaveCriticalSection(&ddraw_cs
);
215 /*****************************************************************************
216 * IDirectDrawClipper::GetHwnd
218 * Returns the hwnd assigned with SetHwnd
221 * hWndPtr: Address to store the HWND at
224 * Always returns DD_OK;
225 *****************************************************************************/
226 static HRESULT WINAPI
IDirectDrawClipperImpl_GetHWnd(
227 LPDIRECTDRAWCLIPPER iface
, HWND
* hWndPtr
229 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
231 TRACE("(%p)->(%p)\n", This
, hWndPtr
);
233 EnterCriticalSection(&ddraw_cs
);
234 hr
= IWineD3DClipper_GetHWnd(This
->wineD3DClipper
,
236 LeaveCriticalSection(&ddraw_cs
);
240 /*****************************************************************************
241 * IDirectDrawClipper::Initialize
243 * Initializes the interface. Well, there isn't much to do for this
244 * implementation, but it stores the DirectDraw Interface.
247 * DD: Pointer to a IDirectDraw interface
248 * Flags: Unsupported by now
252 * DDERR_ALREADYINITIALIZED if this interface isn't initialized already
253 *****************************************************************************/
254 static HRESULT WINAPI
IDirectDrawClipperImpl_Initialize(
255 LPDIRECTDRAWCLIPPER iface
, LPDIRECTDRAW lpDD
, DWORD dwFlags
257 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
258 TRACE("(%p)->(%p,0x%08x)\n", This
, lpDD
, dwFlags
);
260 EnterCriticalSection(&ddraw_cs
);
261 if (This
->initialized
)
263 LeaveCriticalSection(&ddraw_cs
);
264 return DDERR_ALREADYINITIALIZED
;
267 This
->initialized
= TRUE
;
269 LeaveCriticalSection(&ddraw_cs
);
273 /*****************************************************************************
274 * IDirectDrawClipper::IsClipListChanged
276 * This function is a stub
282 * DD_OK, because it's a stub
283 *****************************************************************************/
284 static HRESULT WINAPI
IDirectDrawClipperImpl_IsClipListChanged(
285 LPDIRECTDRAWCLIPPER iface
, BOOL
* lpbChanged
287 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
288 FIXME("(%p)->(%p),stub!\n",This
,lpbChanged
);
290 /* XXX What is safest? */
296 /*****************************************************************************
298 *****************************************************************************/
299 const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl
=
301 IDirectDrawClipperImpl_QueryInterface
,
302 IDirectDrawClipperImpl_AddRef
,
303 IDirectDrawClipperImpl_Release
,
304 IDirectDrawClipperImpl_GetClipList
,
305 IDirectDrawClipperImpl_GetHWnd
,
306 IDirectDrawClipperImpl_Initialize
,
307 IDirectDrawClipperImpl_IsClipListChanged
,
308 IDirectDrawClipperImpl_SetClipList
,
309 IDirectDrawClipperImpl_SetHwnd