wined3d: read_from_framebuffer_texture() isn't suitable for readback of onscreen...
[wine/testsucceed.git] / dlls / sti / sti_main.c
blob711c17f14eb6b519565a89ece612c741d869d685
1 /*
2 * Copyright (C) 2002 Aric Stewart for CodeWeavers
3 * Copyright (C) 2009 Damjan Jovanovic
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winreg.h"
27 #include "winerror.h"
28 #include "objbase.h"
29 #include "sti.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(sti);
35 extern HRESULT WINAPI STI_DllGetClassObject(REFCLSID, REFIID, LPVOID *) DECLSPEC_HIDDEN;
36 extern BOOL WINAPI STI_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN;
38 typedef HRESULT (*fnCreateInstance)(REFIID riid, IUnknown *pUnkOuter, LPVOID *ppObj);
40 typedef struct
42 const struct IClassFactoryVtbl *vtbl;
43 fnCreateInstance pfnCreateInstance;
44 } sti_cf;
46 static inline sti_cf *impl_from_IClassFactory( IClassFactory *iface )
48 return (sti_cf *)((char *)iface - FIELD_OFFSET( sti_cf, vtbl ));
51 static HRESULT sti_create( REFIID riid, IUnknown *pUnkOuter, LPVOID *ppObj )
53 if (pUnkOuter != NULL && !IsEqualIID(riid, &IID_IUnknown))
54 return CLASS_E_NOAGGREGATION;
56 if (IsEqualGUID(riid, &IID_IUnknown))
57 return StiCreateInstanceW(GetCurrentProcess(), STI_VERSION_REAL | STI_VERSION_FLAG_UNICODE, (PSTIW*) ppObj, pUnkOuter);
58 else if (IsEqualGUID(riid, &IID_IStillImageW))
59 return StiCreateInstanceW(GetCurrentProcess(), STI_VERSION_REAL | STI_VERSION_FLAG_UNICODE, (PSTIW*) ppObj, NULL);
60 else if (IsEqualGUID(riid, &IID_IStillImageA))
61 return StiCreateInstanceA(GetCurrentProcess(), STI_VERSION_REAL, (PSTIA*) ppObj, NULL);
62 else
64 FIXME("no interface %s\n", debugstr_guid(riid));
65 return E_NOINTERFACE;
69 static HRESULT WINAPI sti_cf_QueryInterface( IClassFactory *iface, REFIID riid, LPVOID *ppobj )
71 if (IsEqualGUID(riid, &IID_IUnknown) ||
72 IsEqualGUID(riid, &IID_IClassFactory))
74 IClassFactory_AddRef( iface );
75 *ppobj = iface;
76 return S_OK;
78 FIXME("interface %s not implemented\n", debugstr_guid(riid));
79 return E_NOINTERFACE;
82 static ULONG WINAPI sti_cf_AddRef( IClassFactory *iface )
84 return 2;
87 static ULONG WINAPI sti_cf_Release( IClassFactory *iface )
89 return 1;
92 static HRESULT WINAPI sti_cf_CreateInstance( IClassFactory *iface, LPUNKNOWN pOuter,
93 REFIID riid, LPVOID *ppobj )
95 sti_cf *This = impl_from_IClassFactory( iface );
96 HRESULT r;
97 IUnknown *punk;
99 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj);
101 *ppobj = NULL;
103 r = This->pfnCreateInstance( riid, pOuter, (LPVOID *)&punk );
104 if (FAILED(r))
105 return r;
107 r = IUnknown_QueryInterface( punk, riid, ppobj );
108 if (FAILED(r))
109 return r;
111 IUnknown_Release( punk );
112 return r;
115 static HRESULT WINAPI sti_cf_LockServer( IClassFactory *iface, BOOL dolock )
117 FIXME("(%p)->(%d)\n", iface, dolock);
118 return S_OK;
121 static const struct IClassFactoryVtbl sti_cf_vtbl =
123 sti_cf_QueryInterface,
124 sti_cf_AddRef,
125 sti_cf_Release,
126 sti_cf_CreateInstance,
127 sti_cf_LockServer
130 static sti_cf the_sti_cf = { &sti_cf_vtbl, sti_create };
132 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
134 TRACE("(0x%p, %d, %p)\n",hInstDLL,fdwReason,lpvReserved);
136 if (fdwReason == DLL_WINE_PREATTACH)
137 return FALSE;
138 return STI_DllMain(hInstDLL, fdwReason, lpvReserved);
141 /******************************************************************************
142 * DllGetClassObject (STI.@)
144 HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv )
146 IClassFactory *cf = NULL;
148 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
150 if (IsEqualGUID( rclsid, &CLSID_Sti ))
152 cf = (IClassFactory *)&the_sti_cf.vtbl;
155 if (cf)
156 return IClassFactory_QueryInterface( cf, iid, ppv );
157 return STI_DllGetClassObject( rclsid, iid, ppv );
160 /******************************************************************************
161 * DllCanUnloadNow (STI.@)
163 HRESULT WINAPI DllCanUnloadNow( void )
165 return S_FALSE;