Documentation ordinal fixes (using winapi_fixup).
[wine] / dlls / ddraw / dclipper / main.c
1 /*              DirectDrawClipper implementation
2  *
3  * Copyright 2000 Marcus Meissner
4  * Copyright 2000 TransGaming Technologies Inc.
5  */
6
7 #include "config.h"
8
9 #include <stdlib.h>
10 #include <string.h>
11 #include "winerror.h"
12 #include "debugtools.h"
13 #include "ddraw_private.h"
14 #include "dclipper/main.h"
15 #include "ddraw/main.h"
16
17 DEFAULT_DEBUG_CHANNEL(ddraw);
18
19 /******************************************************************************
20  *                      DirectDrawCreateClipper (DDRAW.@)
21  */
22
23 static ICOM_VTABLE(IDirectDrawClipper) DDRAW_Clipper_VTable;
24
25 HRESULT WINAPI DirectDrawCreateClipper(
26     DWORD dwFlags, LPDIRECTDRAWCLIPPER *lplpDDClipper, LPUNKNOWN pUnkOuter
27 ) {
28     IDirectDrawClipperImpl* This;
29     TRACE("(%08lx,%p,%p)\n", dwFlags, lplpDDClipper, pUnkOuter);
30
31     if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
32
33     This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
34                      sizeof(IDirectDrawClipperImpl));
35     if (This == NULL) return E_OUTOFMEMORY;
36
37     ICOM_INIT_INTERFACE(This, IDirectDrawClipper, DDRAW_Clipper_VTable);
38     This->ref = 1;
39     This->hWnd = 0; 
40     This->ddraw_owner = NULL;
41
42     *lplpDDClipper = ICOM_INTERFACE(This, IDirectDrawClipper);
43     return DD_OK;
44 }
45
46 /* This is the classfactory implementation. */
47 HRESULT DDRAW_CreateDirectDrawClipper(IUnknown* pUnkOuter, REFIID riid,
48                                       LPVOID* ppObj)
49 {
50     HRESULT hr;
51     LPDIRECTDRAWCLIPPER pClip;
52
53     hr = DirectDrawCreateClipper(0, &pClip, pUnkOuter);
54     if (FAILED(hr)) return hr;
55
56     hr = IDirectDrawClipper_QueryInterface(pClip, riid, ppObj);
57     IDirectDrawClipper_Release(pClip);
58     return hr;
59 }
60
61 /******************************************************************************
62  *                      IDirectDrawClipper
63  */
64 HRESULT WINAPI Main_DirectDrawClipper_SetHwnd(
65     LPDIRECTDRAWCLIPPER iface, DWORD dwFlags, HWND hWnd
66 ) {
67     ICOM_THIS(IDirectDrawClipperImpl,iface);
68
69     TRACE("(%p)->SetHwnd(0x%08lx,0x%08lx)\n",This,dwFlags,(DWORD)hWnd);
70     if( dwFlags ) {
71         FIXME("dwFlags = 0x%08lx, not supported.\n",dwFlags);
72         return DDERR_INVALIDPARAMS; 
73     }
74
75     This->hWnd = hWnd;
76     return DD_OK;
77 }
78
79 static void Main_DirectDrawClipper_Destroy(IDirectDrawClipperImpl* This)
80 {
81     if (This->ddraw_owner != NULL)
82         Main_DirectDraw_RemoveClipper(This->ddraw_owner, This);
83
84     HeapFree(GetProcessHeap(), 0 ,This);
85 }
86
87 void Main_DirectDrawClipper_ForceDestroy(IDirectDrawClipperImpl* This)
88 {
89     WARN("deleting clipper %p with refcnt %lu\n", This, This->ref);
90     Main_DirectDrawClipper_Destroy(This);
91 }
92
93 ULONG WINAPI Main_DirectDrawClipper_Release(LPDIRECTDRAWCLIPPER iface) {
94     ICOM_THIS(IDirectDrawClipperImpl,iface);
95     TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
96
97     if (--This->ref == 0)
98     {
99         Main_DirectDrawClipper_Destroy(This);
100         return 0;
101     }
102     else return This->ref;
103 }
104
105 HRESULT WINAPI Main_DirectDrawClipper_GetClipList(
106     LPDIRECTDRAWCLIPPER iface,LPRECT prcClip,LPRGNDATA lprgn,LPDWORD pdwSize
107 ) {
108     ICOM_THIS(IDirectDrawClipperImpl,iface);
109     FIXME("(%p,%p,%p,%p),stub!\n",This,prcClip,lprgn,pdwSize);
110     abort();
111     if (pdwSize) *pdwSize=0;
112     return DD_OK;
113 }
114
115 HRESULT WINAPI Main_DirectDrawClipper_SetClipList(
116     LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,DWORD pdwSize
117 ) {
118     ICOM_THIS(IDirectDrawClipperImpl,iface);
119     FIXME("(%p,%p,%ld),stub!\n",This,lprgn,pdwSize);
120     abort();
121     return DD_OK;
122 }
123
124 HRESULT WINAPI Main_DirectDrawClipper_QueryInterface(
125     LPDIRECTDRAWCLIPPER iface, REFIID riid, LPVOID* ppvObj
126 ) {
127     ICOM_THIS(IDirectDrawClipperImpl,iface);
128
129     if (IsEqualGUID(&IID_IUnknown, riid)
130         || IsEqualGUID(&IID_IDirectDrawClipper, riid))
131     {
132         *ppvObj = ICOM_INTERFACE(This, IDirectDrawClipper);
133         ++This->ref;
134         return S_OK;
135     }
136     else
137     {
138         return E_NOINTERFACE;
139     }
140 }
141
142 ULONG WINAPI Main_DirectDrawClipper_AddRef( LPDIRECTDRAWCLIPPER iface )
143 {
144     ICOM_THIS(IDirectDrawClipperImpl,iface);
145     TRACE("(%p)->() incrementing from %lu.\n", This, This->ref );
146     return ++This->ref;
147 }
148
149 HRESULT WINAPI Main_DirectDrawClipper_GetHWnd(
150     LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr
151 ) {
152     ICOM_THIS(IDirectDrawClipperImpl,iface);
153     FIXME("(%p)->(%p),stub!\n",This,hWndPtr);
154
155     *hWndPtr = This->hWnd; 
156
157     return DD_OK;
158 }
159
160 HRESULT WINAPI Main_DirectDrawClipper_Initialize(
161      LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags
162 ) {
163     IDirectDrawImpl* pOwner;
164     ICOM_THIS(IDirectDrawClipperImpl,iface);
165     FIXME("(%p)->(%p,0x%08lx),stub!\n",This,lpDD,dwFlags);
166
167     if (This->ddraw_owner != NULL) return DDERR_ALREADYINITIALIZED;
168
169     pOwner = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, lpDD);
170     This->ddraw_owner = pOwner;
171     Main_DirectDraw_AddClipper(pOwner, This);
172
173     return DD_OK;
174 }
175
176 HRESULT WINAPI Main_DirectDrawClipper_IsClipListChanged(
177     LPDIRECTDRAWCLIPPER iface, BOOL* lpbChanged
178 ) {
179     ICOM_THIS(IDirectDrawClipperImpl,iface);
180     FIXME("(%p)->(%p),stub!\n",This,lpbChanged);
181
182     /* XXX What is safest? */
183     *lpbChanged = FALSE;
184
185     return DD_OK;
186 }
187
188 static ICOM_VTABLE(IDirectDrawClipper) DDRAW_Clipper_VTable =
189 {
190     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
191     Main_DirectDrawClipper_QueryInterface,
192     Main_DirectDrawClipper_AddRef,
193     Main_DirectDrawClipper_Release,
194     Main_DirectDrawClipper_GetClipList,
195     Main_DirectDrawClipper_GetHWnd,
196     Main_DirectDrawClipper_Initialize,
197     Main_DirectDrawClipper_IsClipListChanged,
198     Main_DirectDrawClipper_SetClipList,
199     Main_DirectDrawClipper_SetHwnd
200 };