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
53 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), ppvObj
);
55 if (IsEqualGUID(&IID_IUnknown
, riid
)
56 || IsEqualGUID(&IID_IDirectDrawClipper
, riid
))
58 IUnknown_AddRef(iface
);
68 /*****************************************************************************
69 * IDirectDrawClipper::AddRef
71 * Increases the reference count of the interface, returns the new count
73 *****************************************************************************/
74 static ULONG WINAPI
IDirectDrawClipperImpl_AddRef( LPDIRECTDRAWCLIPPER iface
)
76 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
77 ULONG ref
= InterlockedIncrement(&This
->ref
);
79 TRACE("%p increasing refcount to %u.\n", This
, ref
);
84 /*****************************************************************************
85 * IDirectDrawClipper::Release
87 * Decreases the reference count of the interface, returns the new count
88 * If the refcount is decreased to 0, the interface is destroyed.
90 *****************************************************************************/
91 static ULONG WINAPI
IDirectDrawClipperImpl_Release(IDirectDrawClipper
*iface
) {
92 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
93 ULONG ref
= InterlockedDecrement(&This
->ref
);
95 TRACE("%p decreasing refcount to %u.\n", This
, ref
);
99 EnterCriticalSection(&ddraw_cs
);
100 IWineD3DClipper_Release(This
->wineD3DClipper
);
101 HeapFree(GetProcessHeap(), 0, This
);
102 LeaveCriticalSection(&ddraw_cs
);
108 /*****************************************************************************
109 * IDirectDrawClipper::SetHwnd
111 * Assigns a hWnd to the clipper interface.
114 * Flags: Unsupported so far
115 * hWnd: The hWnd to set
119 * DDERR_INVALIDPARAMS if Flags was != 0
121 *****************************************************************************/
123 static HRESULT WINAPI
IDirectDrawClipperImpl_SetHwnd(
124 LPDIRECTDRAWCLIPPER iface
, DWORD dwFlags
, HWND hWnd
126 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
129 TRACE("iface %p, flags %#x, window %p.\n", iface
, dwFlags
, hWnd
);
131 EnterCriticalSection(&ddraw_cs
);
132 hr
= IWineD3DClipper_SetHWnd(This
->wineD3DClipper
,
135 LeaveCriticalSection(&ddraw_cs
);
138 case WINED3DERR_INVALIDCALL
: return DDERR_INVALIDPARAMS
;
143 /*****************************************************************************
144 * IDirectDrawClipper::GetClipList
146 * Retrieve a copy of the clip list
149 * Rect: Rectangle to be used to clip the clip list or NULL for the
151 * ClipList: structure for the resulting copy of the clip list.
152 * If NULL, fills Size up to the number of bytes necessary to hold
154 * Size: Size of resulting clip list; size of the buffer at ClipList
155 * or, if ClipList is NULL, receives the required size of the buffer
159 * Either DD_OK or DDERR_*
160 ************************************************************************/
161 static HRESULT WINAPI
IDirectDrawClipperImpl_GetClipList(
162 LPDIRECTDRAWCLIPPER iface
, LPRECT lpRect
, LPRGNDATA lpClipList
,
165 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
168 TRACE("iface %p, rect %s, clip_list %p, clip_list_size %p.\n",
169 iface
, wine_dbgstr_rect(lpRect
), lpClipList
, lpdwSize
);
171 EnterCriticalSection(&ddraw_cs
);
172 hr
= IWineD3DClipper_GetClipList(This
->wineD3DClipper
,
176 LeaveCriticalSection(&ddraw_cs
);
180 /*****************************************************************************
181 * IDirectDrawClipper::SetClipList
183 * Sets or deletes (if lprgn is NULL) the clip list
185 * This implementation is a stub and returns DD_OK always to make the app
189 * lprgn Pointer to a LRGNDATA structure or NULL
190 * dwFlags not used, must be 0
192 * Either DD_OK or DDERR_*
193 *****************************************************************************/
194 static HRESULT WINAPI
IDirectDrawClipperImpl_SetClipList(
195 LPDIRECTDRAWCLIPPER iface
,LPRGNDATA lprgn
,DWORD dwFlag
197 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
200 TRACE("iface %p, clip_list %p, flags %#x.\n", iface
, lprgn
, dwFlag
);
202 EnterCriticalSection(&ddraw_cs
);
203 hr
= IWineD3DClipper_SetClipList(This
->wineD3DClipper
,
206 LeaveCriticalSection(&ddraw_cs
);
210 /*****************************************************************************
211 * IDirectDrawClipper::GetHwnd
213 * Returns the hwnd assigned with SetHwnd
216 * hWndPtr: Address to store the HWND at
219 * Always returns DD_OK;
220 *****************************************************************************/
221 static HRESULT WINAPI
IDirectDrawClipperImpl_GetHWnd(
222 LPDIRECTDRAWCLIPPER iface
, HWND
* hWndPtr
224 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
227 TRACE("iface %p, window %p.\n", iface
, hWndPtr
);
229 EnterCriticalSection(&ddraw_cs
);
230 hr
= IWineD3DClipper_GetHWnd(This
->wineD3DClipper
,
232 LeaveCriticalSection(&ddraw_cs
);
236 /*****************************************************************************
237 * IDirectDrawClipper::Initialize
239 * Initializes the interface. Well, there isn't much to do for this
240 * implementation, but it stores the DirectDraw Interface.
243 * DD: Pointer to a IDirectDraw interface
244 * Flags: Unsupported by now
248 * DDERR_ALREADYINITIALIZED if this interface isn't initialized already
249 *****************************************************************************/
250 static HRESULT WINAPI
IDirectDrawClipperImpl_Initialize(
251 LPDIRECTDRAWCLIPPER iface
, LPDIRECTDRAW lpDD
, DWORD dwFlags
253 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
255 TRACE("iface %p, ddraw %p, flags %#x.\n", iface
, lpDD
, dwFlags
);
257 EnterCriticalSection(&ddraw_cs
);
258 if (This
->initialized
)
260 LeaveCriticalSection(&ddraw_cs
);
261 return DDERR_ALREADYINITIALIZED
;
264 This
->initialized
= TRUE
;
266 LeaveCriticalSection(&ddraw_cs
);
270 /*****************************************************************************
271 * IDirectDrawClipper::IsClipListChanged
273 * This function is a stub
279 * DD_OK, because it's a stub
280 *****************************************************************************/
281 static HRESULT WINAPI
IDirectDrawClipperImpl_IsClipListChanged(
282 LPDIRECTDRAWCLIPPER iface
, BOOL
* lpbChanged
284 FIXME("iface %p, changed %p stub!\n", iface
, lpbChanged
);
286 /* XXX What is safest? */
292 /*****************************************************************************
294 *****************************************************************************/
295 static const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl
=
297 IDirectDrawClipperImpl_QueryInterface
,
298 IDirectDrawClipperImpl_AddRef
,
299 IDirectDrawClipperImpl_Release
,
300 IDirectDrawClipperImpl_GetClipList
,
301 IDirectDrawClipperImpl_GetHWnd
,
302 IDirectDrawClipperImpl_Initialize
,
303 IDirectDrawClipperImpl_IsClipListChanged
,
304 IDirectDrawClipperImpl_SetClipList
,
305 IDirectDrawClipperImpl_SetHwnd
308 HRESULT
ddraw_clipper_init(IDirectDrawClipperImpl
*clipper
)
310 clipper
->lpVtbl
= &ddraw_clipper_vtbl
;
312 clipper
->wineD3DClipper
= pWineDirect3DCreateClipper((IUnknown
*)clipper
);
313 if (!clipper
->wineD3DClipper
)
315 WARN("Failed to create wined3d clipper.\n");
316 return E_OUTOFMEMORY
;