~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/ddrawex/main.c

Version: ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*        DirectDrawEx
  2  *
  3  * Copyright 2006 Ulrich Czekalla
  4  *
  5  * This file contains the (internal) driver registration functions,
  6  * driver enumeration APIs and DirectDraw creation functions.
  7  *
  8  * This library is free software; you can redistribute it and/or
  9  * modify it under the terms of the GNU Lesser General Public
 10  * License as published by the Free Software Foundation; either
 11  * version 2.1 of the License, or (at your option) any later version.
 12  *
 13  * This library is distributed in the hope that it will be useful,
 14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 16  * Lesser General Public License for more details.
 17  *
 18  * You should have received a copy of the GNU Lesser General Public
 19  * License along with this library; if not, write to the Free Software
 20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 21  */
 22 
 23 
 24 #include "wine/debug.h"
 25 
 26 #define COBJMACROS
 27 
 28 #include "winbase.h"
 29 #include "wingdi.h"
 30 
 31 #include "ddraw.h"
 32 
 33 #include "initguid.h"
 34 #include "ddrawex_private.h"
 35 
 36 WINE_DEFAULT_DEBUG_CHANNEL(ddrawex);
 37 
 38 
 39 /*******************************************************************************
 40  * IDirectDrawClassFactory::QueryInterface
 41  *
 42  *******************************************************************************/
 43 static HRESULT WINAPI
 44 IDirectDrawClassFactoryImpl_QueryInterface(IClassFactory *iface,
 45                     REFIID riid,
 46                     void **obj)
 47 {
 48     IClassFactoryImpl *This = (IClassFactoryImpl*) iface;
 49 
 50     TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obj);
 51 
 52     if (IsEqualGUID(riid, &IID_IUnknown)
 53         || IsEqualGUID(riid, &IID_IClassFactory))
 54     {
 55         IClassFactory_AddRef(iface);
 56         *obj = This;
 57         return S_OK;
 58     }
 59 
 60     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),obj);
 61     return E_NOINTERFACE;
 62 }
 63 
 64 /*******************************************************************************
 65  * IDirectDrawClassFactory::AddRef
 66  *
 67  *******************************************************************************/
 68 static ULONG WINAPI
 69 IDirectDrawClassFactoryImpl_AddRef(IClassFactory *iface)
 70 {
 71     IClassFactoryImpl *This = (IClassFactoryImpl*) iface;
 72     ULONG ref = InterlockedIncrement(&This->ref);
 73 
 74     TRACE("(%p)->() incrementing from %d.\n", This, ref - 1);
 75 
 76     return ref;
 77 }
 78 
 79 /*******************************************************************************
 80  * IDirectDrawClassFactory::Release
 81  *
 82  *******************************************************************************/
 83 static ULONG WINAPI
 84 IDirectDrawClassFactoryImpl_Release(IClassFactory *iface)
 85 {
 86     IClassFactoryImpl *This = (IClassFactoryImpl*) iface;
 87     ULONG ref = InterlockedDecrement(&This->ref);
 88     TRACE("(%p)->() decrementing from %d.\n", This, ref+1);
 89 
 90     if (ref == 0)
 91         HeapFree(GetProcessHeap(), 0, This);
 92 
 93     return ref;
 94 }
 95 
 96 
 97 /*******************************************************************************
 98  * IDirectDrawClassFactory::CreateInstance
 99  *
100  *******************************************************************************/
101 static HRESULT WINAPI
102 IDirectDrawClassFactoryImpl_CreateInstance(IClassFactory *iface,
103                                            IUnknown *UnkOuter,
104                                            REFIID riid,
105                                            void **obj)
106 {
107     IClassFactoryImpl *This = (IClassFactoryImpl*) iface;
108 
109     TRACE("(%p)->(%p,%s,%p)\n",This,UnkOuter,debugstr_guid(riid),obj);
110 
111     return This->pfnCreateInstance(UnkOuter, riid, obj);
112 }
113 
114 /*******************************************************************************
115  * IDirectDrawClassFactory::LockServer
116  *
117  *******************************************************************************/
118 static HRESULT WINAPI
119 IDirectDrawClassFactoryImpl_LockServer(IClassFactory *iface,BOOL dolock)
120 {
121     IClassFactoryImpl *This = (IClassFactoryImpl*) iface;
122     FIXME("(%p)->(%d),stub!\n",This,dolock);
123     return S_OK;
124 }
125 
126 
127 /*******************************************************************************
128  * The class factory VTable
129  *******************************************************************************/
130 static const IClassFactoryVtbl IClassFactory_Vtbl =
131 {
132     IDirectDrawClassFactoryImpl_QueryInterface,
133     IDirectDrawClassFactoryImpl_AddRef,
134     IDirectDrawClassFactoryImpl_Release,
135     IDirectDrawClassFactoryImpl_CreateInstance,
136     IDirectDrawClassFactoryImpl_LockServer
137 };
138 
139 
140 /*******************************************************************************
141  * IDirectDrawFactory::QueryInterface
142  *
143  *******************************************************************************/
144 static HRESULT WINAPI
145 IDirectDrawFactoryImpl_QueryInterface(IDirectDrawFactory *iface,
146                     REFIID riid,
147                     void **obj)
148 {
149     IDirectDrawFactoryImpl *This = (IDirectDrawFactoryImpl*) iface;
150 
151     TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obj);
152 
153     if (IsEqualGUID(riid, &IID_IUnknown)
154         || IsEqualGUID(riid, &IID_IDirectDrawFactory))
155     {
156         IDirectDrawFactory_AddRef(iface);
157         *obj = This;
158         return S_OK;
159     }
160 
161     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),obj);
162     return E_NOINTERFACE;
163 }
164 
165 /*******************************************************************************
166  * IDirectDrawFactory::AddRef
167  *
168  *******************************************************************************/
169 static ULONG WINAPI
170 IDirectDrawFactoryImpl_AddRef(IDirectDrawFactory *iface)
171 {
172     IDirectDrawFactoryImpl *This = (IDirectDrawFactoryImpl*) iface;
173     ULONG ref = InterlockedIncrement(&This->ref);
174 
175     TRACE("(%p)->() incrementing from %d.\n", This, ref - 1);
176 
177     return ref;
178 }
179 
180 /*******************************************************************************
181  * IDirectDrawFactory::Release
182  *
183  *******************************************************************************/
184 static ULONG WINAPI
185 IDirectDrawFactoryImpl_Release(IDirectDrawFactory *iface)
186 {
187     IDirectDrawFactoryImpl *This = (IDirectDrawFactoryImpl*) iface;
188     ULONG ref = InterlockedDecrement(&This->ref);
189     TRACE("(%p)->() decrementing from %d.\n", This, ref+1);
190 
191     if (ref == 0)
192         HeapFree(GetProcessHeap(), 0, This);
193 
194     return ref;
195 }
196 
197 /*******************************************************************************
198  * IDirectDrawFactoryImpl_DirectDrawEnumerate
199  *******************************************************************************/
200 static HRESULT WINAPI
201 IDirectDrawFactoryImpl_DirectDrawEnumerate(IDirectDrawFactory* iface,
202                                            LPDDENUMCALLBACKW lpCallback,
203                                            LPVOID lpContext)
204 {
205     FIXME("Stub!\n");
206     return E_FAIL;
207 }
208 
209 
210 /*******************************************************************************
211  * Direct Draw Factory VTable
212  *******************************************************************************/
213 static const IDirectDrawFactoryVtbl IDirectDrawFactory_Vtbl =
214 {
215     IDirectDrawFactoryImpl_QueryInterface,
216     IDirectDrawFactoryImpl_AddRef,
217     IDirectDrawFactoryImpl_Release,
218     IDirectDrawFactoryImpl_CreateDirectDraw,
219     IDirectDrawFactoryImpl_DirectDrawEnumerate,
220 };
221 
222 /***********************************************************************
223  * CreateDirectDrawFactory
224  *
225  ***********************************************************************/
226 static HRESULT
227 CreateDirectDrawFactory(IUnknown* UnkOuter, REFIID iid, void **obj)
228 {
229     HRESULT hr;
230     IDirectDrawFactoryImpl *This = NULL;
231 
232     TRACE("(%p,%s,%p)\n", UnkOuter, debugstr_guid(iid), obj);
233 
234     if (UnkOuter != NULL)
235         return CLASS_E_NOAGGREGATION;
236 
237     This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawFactoryImpl));
238 
239     if(!This)
240     {
241         ERR("Out of memory when creating DirectDraw\n");
242         return E_OUTOFMEMORY;
243     }
244 
245     This->lpVtbl = &IDirectDrawFactory_Vtbl;
246 
247     hr = IDirectDrawFactory_QueryInterface((IDirectDrawFactory *)This, iid,  obj);
248 
249     if (FAILED(hr))
250         HeapFree(GetProcessHeap(), 0, This);
251 
252     return hr;
253 }
254 
255 
256 /*******************************************************************************
257  * DllCanUnloadNow [DDRAWEX.@]  Determines whether the DLL is in use.
258  */
259 HRESULT WINAPI DllCanUnloadNow(void)
260 {
261     FIXME("(void): stub\n");
262     return S_FALSE;
263 }
264 
265 
266 /*******************************************************************************
267  * DllGetClassObject [DDRAWEX.@]
268  */
269 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
270 {
271     IClassFactoryImpl *factory;
272 
273     TRACE("ddrawex (%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
274 
275     if (!IsEqualGUID( &IID_IClassFactory, riid)
276         && !IsEqualGUID( &IID_IUnknown, riid))
277         return E_NOINTERFACE;
278 
279     if (!IsEqualGUID(&CLSID_DirectDrawFactory, rclsid))
280     {
281         FIXME("%s: no class found.\n", debugstr_guid(rclsid));
282         return CLASS_E_CLASSNOTAVAILABLE;
283     }
284 
285     factory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*factory));
286     if (factory == NULL) return E_OUTOFMEMORY;
287 
288     factory->lpVtbl = &IClassFactory_Vtbl;
289     factory->ref = 1;
290 
291     factory->pfnCreateInstance = CreateDirectDrawFactory;
292 
293     *ppv = factory;
294 
295     return S_OK;
296 }
297 
298 
299 /***********************************************************************
300  * DllMain (DDRAWEX.0)
301  *
302  ***********************************************************************/
303 BOOL WINAPI
304 DllMain(HINSTANCE hInstDLL,
305         DWORD Reason,
306         LPVOID lpv)
307 {
308     TRACE("(%p,%x,%p)\n", hInstDLL, Reason, lpv);
309     return TRUE;
310 }
311 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.