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
34 #include "ddraw_private.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(ddraw
);
40 /*****************************************************************************
42 *****************************************************************************/
44 /*****************************************************************************
45 * IDirectDrawClipper::QueryInterface
47 * Can query the IUnknown and IDirectDrawClipper interface from a
48 * Clipper object. The IUnknown Interface is equal to the IDirectDrawClipper
49 * interface. Can't create other interfaces.
52 * riid: Interface id asked for
53 * ppvObj: Returns the pointer to the interface
57 * E_NOINTERFACE if the requested interface wasn't found.
59 *****************************************************************************/
60 static HRESULT WINAPI
IDirectDrawClipperImpl_QueryInterface(
61 LPDIRECTDRAWCLIPPER iface
, REFIID riid
, LPVOID
* ppvObj
63 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
65 if (IsEqualGUID(&IID_IUnknown
, riid
)
66 || IsEqualGUID(&IID_IDirectDrawClipper
, riid
))
68 *ppvObj
= ICOM_INTERFACE(This
, IDirectDrawClipper
);
69 InterlockedIncrement(&This
->ref
);
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 %lu.\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 %lu.\n", This
, ref
+ 1);
109 HeapFree(GetProcessHeap(), 0, This
);
115 /*****************************************************************************
116 * IDirectDrawClipper::SetHwnd
118 * Assigns a hWnd to the clipper interface.
121 * Flags: Unsupported so far
122 * hWnd: The hWnd to set
126 * DDERR_INVALIDPARAMS if Flags was != 0
128 *****************************************************************************/
130 static HRESULT WINAPI
IDirectDrawClipperImpl_SetHwnd(
131 LPDIRECTDRAWCLIPPER iface
, DWORD dwFlags
, HWND hWnd
133 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
135 TRACE("(%p)->(0x%08lx,0x%08lx)\n", This
, dwFlags
, (DWORD
)hWnd
);
137 FIXME("dwFlags = 0x%08lx, not supported.\n",dwFlags
);
138 return DDERR_INVALIDPARAMS
;
145 /*****************************************************************************
146 * IDirectDrawClipper::GetClipList
148 * Retrieve a copy of the clip list
151 * Rect: Rectangle to be used to clip the clip list or NULL for the
153 * ClipList: structure for the resulting copy of the clip list.
154 * If NULL, fills Size up to the number of bytes necessary to hold
156 * Size: Size of resulting clip list; size of the buffer at ClipList
157 * or, if ClipList is NULL, receives the required size of the buffer
161 * Either DD_OK or DDERR_*
162 ************************************************************************/
163 static HRESULT WINAPI
IDirectDrawClipperImpl_GetClipList(
164 LPDIRECTDRAWCLIPPER iface
, LPRECT lpRect
, LPRGNDATA lpClipList
,
167 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
169 TRACE("(%p,%p,%p,%p)\n", This
, lpRect
, lpClipList
, lpdwSize
);
173 HDC hDC
= GetDCEx(This
->hWnd
, NULL
, DCX_WINDOW
);
176 HRGN hRgn
= CreateRectRgn(0,0,0,0);
177 if (GetRandomRgn(hDC
, hRgn
, SYSRGN
))
179 if (GetVersion() & 0x80000000)
181 /* map region to screen coordinates */
183 GetDCOrgEx( hDC
, &org
);
184 OffsetRgn( hRgn
, org
.x
, org
.y
);
188 HRGN hRgnClip
= CreateRectRgn(lpRect
->left
, lpRect
->top
,
189 lpRect
->right
, lpRect
->bottom
);
190 CombineRgn(hRgn
, hRgn
, hRgnClip
, RGN_AND
);
191 DeleteObject(hRgnClip
);
193 *lpdwSize
= GetRegionData(hRgn
, *lpdwSize
, lpClipList
);
196 ReleaseDC(This
->hWnd
, hDC
);
202 static int warned
= 0;
204 FIXME("(%p,%p,%p,%p),stub!\n",This
,lpRect
,lpClipList
,lpdwSize
);
205 if (lpdwSize
) *lpdwSize
=0;
206 return DDERR_NOCLIPLIST
;
210 /*****************************************************************************
211 * IDirectDrawClipper::SetClipList
213 * Sets or deletes (if lprgn is NULL) the clip list
215 * This implementation is a stub and returns DD_OK always to make the app
219 * lprgn Pointer to a LRGNDATA structure or NULL
220 * dwFlags not used, must be 0
222 * Either DD_OK or DDERR_*
223 *****************************************************************************/
224 static HRESULT WINAPI
IDirectDrawClipperImpl_SetClipList(
225 LPDIRECTDRAWCLIPPER iface
,LPRGNDATA lprgn
,DWORD dwFlag
227 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
228 static int warned
= 0;
229 if (warned
++ < 10 || lprgn
== NULL
)
230 FIXME("(%p,%p,%ld),stub!\n",This
,lprgn
,dwFlag
);
234 /*****************************************************************************
235 * IDirectDrawClipper::GetHwnd
237 * Returns the hwnd assigned with SetHwnd
240 * hWndPtr: Address to store the HWND at
243 * Always returns DD_OK;
244 *****************************************************************************/
245 static HRESULT WINAPI
IDirectDrawClipperImpl_GetHWnd(
246 LPDIRECTDRAWCLIPPER iface
, HWND
* hWndPtr
248 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
249 TRACE("(%p)->(%p)\n", This
, hWndPtr
);
251 *hWndPtr
= This
->hWnd
;
256 /*****************************************************************************
257 * IDirectDrawClipper::Initialize
259 * Initializes the interface. Well, there isn't much to do for this
260 * implementation, but it stores the DirectDraw Interface.
263 * DD: Pointer to a IDirectDraw interface
264 * Flags: Unsupported by now
268 * DDERR_ALREADYINITIALIZED if this interface isn't initialized already
269 *****************************************************************************/
270 static HRESULT WINAPI
IDirectDrawClipperImpl_Initialize(
271 LPDIRECTDRAWCLIPPER iface
, LPDIRECTDRAW lpDD
, DWORD dwFlags
273 IDirectDrawImpl
* pOwner
;
274 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
275 TRACE("(%p)->(%p,0x%08lx)\n", This
, lpDD
, dwFlags
);
277 if (This
->ddraw_owner
!= NULL
) return DDERR_ALREADYINITIALIZED
;
279 pOwner
= ICOM_OBJECT(IDirectDrawImpl
, IDirectDraw
, lpDD
);
280 This
->ddraw_owner
= pOwner
;
285 /*****************************************************************************
286 * IDirectDrawClipper::IsClipListChanged
288 * This function is a stub
294 * DD_OK, because it's a stub
295 *****************************************************************************/
296 static HRESULT WINAPI
IDirectDrawClipperImpl_IsClipListChanged(
297 LPDIRECTDRAWCLIPPER iface
, BOOL
* lpbChanged
299 IDirectDrawClipperImpl
*This
= (IDirectDrawClipperImpl
*)iface
;
300 FIXME("(%p)->(%p),stub!\n",This
,lpbChanged
);
302 /* XXX What is safest? */
308 /*****************************************************************************
310 *****************************************************************************/
311 const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl
=
313 IDirectDrawClipperImpl_QueryInterface
,
314 IDirectDrawClipperImpl_AddRef
,
315 IDirectDrawClipperImpl_Release
,
316 IDirectDrawClipperImpl_GetClipList
,
317 IDirectDrawClipperImpl_GetHWnd
,
318 IDirectDrawClipperImpl_Initialize
,
319 IDirectDrawClipperImpl_IsClipListChanged
,
320 IDirectDrawClipperImpl_SetClipList
,
321 IDirectDrawClipperImpl_SetHwnd