1 /* DirectDrawClipper implementation
3 * Copyright 2000 Marcus Meissner
4 * Copyright 2000 TransGaming Technologies Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #include "ddraw_private.h"
34 #include "dclipper/main.h"
35 #include "ddraw/main.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(ddraw
);
41 /******************************************************************************
42 * DirectDrawCreateClipper (DDRAW.@)
45 static IDirectDrawClipperVtbl DDRAW_Clipper_VTable
;
47 HRESULT WINAPI
DirectDrawCreateClipper(
48 DWORD dwFlags
, LPDIRECTDRAWCLIPPER
*lplpDDClipper
, LPUNKNOWN pUnkOuter
50 IDirectDrawClipperImpl
* This
;
51 TRACE("(%08lx,%p,%p)\n", dwFlags
, lplpDDClipper
, pUnkOuter
);
53 if (pUnkOuter
!= NULL
) return CLASS_E_NOAGGREGATION
;
55 This
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
56 sizeof(IDirectDrawClipperImpl
));
57 if (This
== NULL
) return E_OUTOFMEMORY
;
59 ICOM_INIT_INTERFACE(This
, IDirectDrawClipper
, DDRAW_Clipper_VTable
);
62 This
->ddraw_owner
= NULL
;
64 *lplpDDClipper
= ICOM_INTERFACE(This
, IDirectDrawClipper
);
68 /* This is the classfactory implementation. */
69 HRESULT
DDRAW_CreateDirectDrawClipper(IUnknown
* pUnkOuter
, REFIID riid
,
73 LPDIRECTDRAWCLIPPER pClip
;
75 hr
= DirectDrawCreateClipper(0, &pClip
, pUnkOuter
);
76 if (FAILED(hr
)) return hr
;
78 hr
= IDirectDrawClipper_QueryInterface(pClip
, riid
, ppObj
);
79 IDirectDrawClipper_Release(pClip
);
83 /******************************************************************************
86 HRESULT WINAPI
Main_DirectDrawClipper_SetHwnd(
87 LPDIRECTDRAWCLIPPER iface
, DWORD dwFlags
, HWND hWnd
89 ICOM_THIS(IDirectDrawClipperImpl
,iface
);
91 TRACE("(%p)->SetHwnd(0x%08lx,0x%08lx)\n",This
,dwFlags
,(DWORD
)hWnd
);
93 FIXME("dwFlags = 0x%08lx, not supported.\n",dwFlags
);
94 return DDERR_INVALIDPARAMS
;
101 static void Main_DirectDrawClipper_Destroy(IDirectDrawClipperImpl
* This
)
103 if (This
->ddraw_owner
!= NULL
)
104 Main_DirectDraw_RemoveClipper(This
->ddraw_owner
, This
);
106 HeapFree(GetProcessHeap(), 0 ,This
);
109 void Main_DirectDrawClipper_ForceDestroy(IDirectDrawClipperImpl
* This
)
111 WARN("deleting clipper %p with refcnt %lu\n", This
, This
->ref
);
112 Main_DirectDrawClipper_Destroy(This
);
115 ULONG WINAPI
Main_DirectDrawClipper_Release(LPDIRECTDRAWCLIPPER iface
) {
116 ICOM_THIS(IDirectDrawClipperImpl
,iface
);
117 TRACE("(%p)->() decrementing from %lu.\n", This
, This
->ref
);
119 if (--This
->ref
== 0)
121 Main_DirectDrawClipper_Destroy(This
);
124 else return This
->ref
;
127 /***********************************************************************
128 * IDirectDrawClipper::GetClipList
130 * Retrieve a copy of the clip list
133 * lpRect Rectangle to be used to clip the clip list or NULL for the
135 * lpClipList structure for the resulting copy of the clip list.
136 If NULL, fills lpdwSize up to the number of bytes necessary to hold
138 * lpdwSize Size of resulting clip list; size of the buffer at lpClipList
139 or, if lpClipList is NULL, receives the required size of the buffer
142 * Either DD_OK or DDERR_*
144 HRESULT WINAPI
Main_DirectDrawClipper_GetClipList(
145 LPDIRECTDRAWCLIPPER iface
, LPRECT lpRect
, LPRGNDATA lpClipList
,
148 ICOM_THIS(IDirectDrawClipperImpl
,iface
);
149 static int warned
= 0;
151 FIXME("(%p,%p,%p,%p),stub!\n",This
,lpRect
,lpClipList
,lpdwSize
);
152 if (lpdwSize
) *lpdwSize
=0;
153 return DDERR_NOCLIPLIST
;
156 /***********************************************************************
157 * IDirectDrawClipper::SetClipList
159 * Sets or deletes (if lprgn is NULL) the clip list
162 * lprgn Pointer to a LRGNDATA structure or NULL
163 * dwFlags not used, must be 0
165 * Either DD_OK or DDERR_*
167 HRESULT WINAPI
Main_DirectDrawClipper_SetClipList(
168 LPDIRECTDRAWCLIPPER iface
,LPRGNDATA lprgn
,DWORD dwFlag
170 ICOM_THIS(IDirectDrawClipperImpl
,iface
);
171 static int warned
= 0;
172 if (warned
++ < 10 || lprgn
== NULL
)
173 FIXME("(%p,%p,%ld),stub!\n",This
,lprgn
,dwFlag
);
177 HRESULT WINAPI
Main_DirectDrawClipper_QueryInterface(
178 LPDIRECTDRAWCLIPPER iface
, REFIID riid
, LPVOID
* ppvObj
180 ICOM_THIS(IDirectDrawClipperImpl
,iface
);
182 if (IsEqualGUID(&IID_IUnknown
, riid
)
183 || IsEqualGUID(&IID_IDirectDrawClipper
, riid
))
185 *ppvObj
= ICOM_INTERFACE(This
, IDirectDrawClipper
);
191 return E_NOINTERFACE
;
195 ULONG WINAPI
Main_DirectDrawClipper_AddRef( LPDIRECTDRAWCLIPPER iface
)
197 ICOM_THIS(IDirectDrawClipperImpl
,iface
);
198 TRACE("(%p)->() incrementing from %lu.\n", This
, This
->ref
);
202 HRESULT WINAPI
Main_DirectDrawClipper_GetHWnd(
203 LPDIRECTDRAWCLIPPER iface
, HWND
* hWndPtr
205 ICOM_THIS(IDirectDrawClipperImpl
,iface
);
206 FIXME("(%p)->(%p),stub!\n",This
,hWndPtr
);
208 *hWndPtr
= This
->hWnd
;
213 HRESULT WINAPI
Main_DirectDrawClipper_Initialize(
214 LPDIRECTDRAWCLIPPER iface
, LPDIRECTDRAW lpDD
, DWORD dwFlags
216 IDirectDrawImpl
* pOwner
;
217 ICOM_THIS(IDirectDrawClipperImpl
,iface
);
218 FIXME("(%p)->(%p,0x%08lx),stub!\n",This
,lpDD
,dwFlags
);
220 if (This
->ddraw_owner
!= NULL
) return DDERR_ALREADYINITIALIZED
;
222 pOwner
= ICOM_OBJECT(IDirectDrawImpl
, IDirectDraw
, lpDD
);
223 This
->ddraw_owner
= pOwner
;
224 Main_DirectDraw_AddClipper(pOwner
, This
);
229 HRESULT WINAPI
Main_DirectDrawClipper_IsClipListChanged(
230 LPDIRECTDRAWCLIPPER iface
, BOOL
* lpbChanged
232 ICOM_THIS(IDirectDrawClipperImpl
,iface
);
233 FIXME("(%p)->(%p),stub!\n",This
,lpbChanged
);
235 /* XXX What is safest? */
241 static IDirectDrawClipperVtbl DDRAW_Clipper_VTable
=
243 Main_DirectDrawClipper_QueryInterface
,
244 Main_DirectDrawClipper_AddRef
,
245 Main_DirectDrawClipper_Release
,
246 Main_DirectDrawClipper_GetClipList
,
247 Main_DirectDrawClipper_GetHWnd
,
248 Main_DirectDrawClipper_Initialize
,
249 Main_DirectDrawClipper_IsClipListChanged
,
250 Main_DirectDrawClipper_SetClipList
,
251 Main_DirectDrawClipper_SetHwnd