mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-09 19:50:13 +02:00
Added WIC_USE_FACTORY_PROXY build option to use entry-point in WindowsCodecs.dll rather than CoCreateInstance for the WIC factory
This commit is contained in:
parent
891bcda9a7
commit
2bdd90ddfc
@ -144,7 +144,47 @@ IWICImagingFactory* _GetWIC()
|
|||||||
if ( s_Factory )
|
if ( s_Factory )
|
||||||
return s_Factory;
|
return s_Factory;
|
||||||
|
|
||||||
|
#ifdef WIC_USE_FACTORY_PROXY
|
||||||
|
HINSTANCE hInst = LoadLibraryEx( TEXT("WindowsCodecs.dll"), nullptr, 0 );
|
||||||
|
if ( !hInst )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
typedef HRESULT (WINAPI *WICCREATEFACTORY)(UINT, IWICImagingFactory**);
|
||||||
|
WICCREATEFACTORY pFactory = (WICCREATEFACTORY) GetProcAddress(hInst, "WICCreateImagingFactory_Proxy");
|
||||||
|
if ( !pFactory )
|
||||||
|
{
|
||||||
|
FreeLibrary( hInst );
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
#if(_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) || defined(_WIN7_PLATFORM_UPDATE)
|
#if(_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) || defined(_WIN7_PLATFORM_UPDATE)
|
||||||
|
HRESULT hr = pFactory( WINCODEC_SDK_VERSION2, &s_Factory );
|
||||||
|
if ( SUCCEEDED(hr) )
|
||||||
|
{
|
||||||
|
// WIC2 is available on Windows 8 and Windows 7 SP1 with KB 2670838 installed
|
||||||
|
g_WIC2 = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hr = pFactory( WINCODEC_SDK_VERSION1, &s_Factory );
|
||||||
|
if ( FAILED(hr) )
|
||||||
|
{
|
||||||
|
FreeLibrary( hInst );
|
||||||
|
s_Factory = nullptr;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
HRESULT hr = pFactory( WINCODEC_SDK_VERSION, &s_Factory );
|
||||||
|
if ( FAILED(hr) )
|
||||||
|
{
|
||||||
|
FreeLibrary( hInst );
|
||||||
|
s_Factory = nullptr;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif(_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) || defined(_WIN7_PLATFORM_UPDATE)
|
||||||
HRESULT hr = CoCreateInstance(
|
HRESULT hr = CoCreateInstance(
|
||||||
CLSID_WICImagingFactory2,
|
CLSID_WICImagingFactory2,
|
||||||
nullptr,
|
nullptr,
|
||||||
|
@ -633,7 +633,47 @@ static IWICImagingFactory* _GetWIC()
|
|||||||
if ( s_Factory )
|
if ( s_Factory )
|
||||||
return s_Factory;
|
return s_Factory;
|
||||||
|
|
||||||
|
#ifdef WIC_USE_FACTORY_PROXY
|
||||||
|
HINSTANCE hInst = LoadLibraryEx( TEXT("WindowsCodecs.dll"), nullptr, 0 );
|
||||||
|
if ( !hInst )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
typedef HRESULT (WINAPI *WICCREATEFACTORY)(UINT, IWICImagingFactory**);
|
||||||
|
WICCREATEFACTORY pFactory = (WICCREATEFACTORY) GetProcAddress(hInst, "WICCreateImagingFactory_Proxy");
|
||||||
|
if ( !pFactory )
|
||||||
|
{
|
||||||
|
FreeLibrary( hInst );
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
#if(_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) || defined(_WIN7_PLATFORM_UPDATE)
|
#if(_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) || defined(_WIN7_PLATFORM_UPDATE)
|
||||||
|
HRESULT hr = pFactory( WINCODEC_SDK_VERSION2, &s_Factory );
|
||||||
|
if ( SUCCEEDED(hr) )
|
||||||
|
{
|
||||||
|
// WIC2 is available on Windows 8 and Windows 7 SP1 with KB 2670838 installed
|
||||||
|
g_WIC2 = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hr = pFactory( WINCODEC_SDK_VERSION1, &s_Factory );
|
||||||
|
if ( FAILED(hr) )
|
||||||
|
{
|
||||||
|
FreeLibrary( hInst );
|
||||||
|
s_Factory = nullptr;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
HRESULT hr = pFactory( WINCODEC_SDK_VERSION, &s_Factory );
|
||||||
|
if ( FAILED(hr) )
|
||||||
|
{
|
||||||
|
FreeLibrary( hInst );
|
||||||
|
s_Factory = nullptr;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif(_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) || defined(_WIN7_PLATFORM_UPDATE)
|
||||||
HRESULT hr = CoCreateInstance(
|
HRESULT hr = CoCreateInstance(
|
||||||
CLSID_WICImagingFactory2,
|
CLSID_WICImagingFactory2,
|
||||||
nullptr,
|
nullptr,
|
||||||
|
@ -217,7 +217,47 @@ static IWICImagingFactory* _GetWIC()
|
|||||||
if ( s_Factory )
|
if ( s_Factory )
|
||||||
return s_Factory;
|
return s_Factory;
|
||||||
|
|
||||||
|
#ifdef WIC_USE_FACTORY_PROXY
|
||||||
|
HINSTANCE hInst = LoadLibraryEx( TEXT("WindowsCodecs.dll"), nullptr, 0 );
|
||||||
|
if ( !hInst )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
typedef HRESULT (WINAPI *WICCREATEFACTORY)(UINT, IWICImagingFactory**);
|
||||||
|
WICCREATEFACTORY pFactory = (WICCREATEFACTORY) GetProcAddress(hInst, "WICCreateImagingFactory_Proxy");
|
||||||
|
if ( !pFactory )
|
||||||
|
{
|
||||||
|
FreeLibrary( hInst );
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
#if(_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) || defined(_WIN7_PLATFORM_UPDATE)
|
#if(_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) || defined(_WIN7_PLATFORM_UPDATE)
|
||||||
|
HRESULT hr = pFactory( WINCODEC_SDK_VERSION2, &s_Factory );
|
||||||
|
if ( SUCCEEDED(hr) )
|
||||||
|
{
|
||||||
|
// WIC2 is available on Windows 8 and Windows 7 SP1 with KB 2670838 installed
|
||||||
|
g_WIC2 = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hr = pFactory( WINCODEC_SDK_VERSION1, &s_Factory );
|
||||||
|
if ( FAILED(hr) )
|
||||||
|
{
|
||||||
|
FreeLibrary( hInst );
|
||||||
|
s_Factory = nullptr;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
HRESULT hr = pFactory( WINCODEC_SDK_VERSION, &s_Factory );
|
||||||
|
if ( FAILED(hr) )
|
||||||
|
{
|
||||||
|
FreeLibrary( hInst );
|
||||||
|
s_Factory = nullptr;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif(_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/) || defined(_WIN7_PLATFORM_UPDATE)
|
||||||
HRESULT hr = CoCreateInstance(
|
HRESULT hr = CoCreateInstance(
|
||||||
CLSID_WICImagingFactory2,
|
CLSID_WICImagingFactory2,
|
||||||
nullptr,
|
nullptr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user