Code review feedback
This commit is contained in:
parent
25dbe0e547
commit
0bbee8c588
@ -229,31 +229,33 @@ REFGUID GetWICCodec( WICCodecs codec )
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Singleton function for WIC factory
|
||||
//-------------------------------------------------------------------------------------
|
||||
IWICImagingFactory* GetWICFactory(bool& iswic2)
|
||||
IWICImagingFactory* GetWICFactory( bool& iswic2 )
|
||||
{
|
||||
if (g_Factory)
|
||||
if ( g_Factory )
|
||||
{
|
||||
iswic2 = g_WIC2;
|
||||
return g_Factory;
|
||||
}
|
||||
|
||||
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
||||
|
||||
InitOnceExecuteOnce(&s_initOnce,
|
||||
[](PINIT_ONCE, PVOID, PVOID *) -> BOOL
|
||||
[](PINIT_ONCE, PVOID, PVOID *factory) -> BOOL
|
||||
{
|
||||
#if(_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
|
||||
HRESULT hr = CoCreateInstance(
|
||||
CLSID_WICImagingFactory2,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWICImagingFactory2),
|
||||
(LPVOID*)&g_Factory
|
||||
);
|
||||
factory
|
||||
);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
// WIC2 is available on Windows 8 and Windows 7 SP1 with KB 2670838 installed
|
||||
// WIC2 is available on Windows 10, Windows 8.x, and Windows 7 SP1 with KB 2670838 installed
|
||||
g_WIC2 = true;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -263,33 +265,22 @@ IWICImagingFactory* GetWICFactory(bool& iswic2)
|
||||
CLSID_WICImagingFactory1,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(&g_Factory)
|
||||
);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
g_Factory = nullptr;
|
||||
return FALSE;
|
||||
}
|
||||
__uuidof(IWICImagingFactory),
|
||||
factory
|
||||
);
|
||||
return SUCCEEDED(hr) ? TRUE : FALSE;
|
||||
}
|
||||
#else
|
||||
HRESULT hr = CoCreateInstance(
|
||||
#else
|
||||
g_WIC2 = false;
|
||||
|
||||
return SUCCEEDED( CoCreateInstance(
|
||||
CLSID_WICImagingFactory,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(&g_Factory)
|
||||
);
|
||||
|
||||
g_WIC2 = false;
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
g_Factory = nullptr;
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}, nullptr, nullptr);
|
||||
__uuidof(IWICImagingFactory),
|
||||
factory) ) ? TRUE : FALSE;
|
||||
#endif
|
||||
}, nullptr, reinterpret_cast<LPVOID*>(&g_Factory) );
|
||||
|
||||
iswic2 = g_WIC2;
|
||||
return g_Factory;
|
||||
|
@ -701,15 +701,15 @@ namespace
|
||||
|
||||
IWICImagingFactory* _GetWIC()
|
||||
{
|
||||
static IWICImagingFactory* s_Factory = nullptr;
|
||||
static ComPtr<IWICImagingFactory> s_Factory;
|
||||
|
||||
if ( s_Factory )
|
||||
return s_Factory;
|
||||
return s_Factory.Get();
|
||||
|
||||
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
||||
|
||||
InitOnceExecuteOnce(&s_initOnce,
|
||||
[](PINIT_ONCE, PVOID, PVOID *) -> BOOL
|
||||
[](PINIT_ONCE, PVOID, PVOID *factory) -> BOOL
|
||||
{
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
|
||||
HRESULT hr = CoCreateInstance(
|
||||
@ -717,13 +717,14 @@ namespace
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWICImagingFactory2),
|
||||
(LPVOID*)&s_Factory
|
||||
factory
|
||||
);
|
||||
|
||||
if ( SUCCEEDED(hr) )
|
||||
{
|
||||
// WIC2 is available on Windows 10, Windows 8.x, and Windows 7 SP1 with KB 2670838 installed
|
||||
g_WIC2 = true;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -731,33 +732,22 @@ namespace
|
||||
CLSID_WICImagingFactory1,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(&s_Factory)
|
||||
__uuidof(IWICImagingFactory),
|
||||
factory
|
||||
);
|
||||
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
s_Factory = nullptr;
|
||||
return FALSE;
|
||||
}
|
||||
return SUCCEEDED(hr) ? TRUE : FALSE;
|
||||
}
|
||||
#else
|
||||
HRESULT hr = CoCreateInstance(
|
||||
return SUCCEEDED( CoCreateInstance(
|
||||
CLSID_WICImagingFactory,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(&s_Factory)
|
||||
);
|
||||
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
s_Factory = nullptr;
|
||||
return FALSE;
|
||||
}
|
||||
__uuidof(IWICImagingFactory),
|
||||
factory) ) ? TRUE : FALSE;
|
||||
#endif
|
||||
return TRUE;
|
||||
}, nullptr, nullptr);
|
||||
}, nullptr, reinterpret_cast<LPVOID*>(s_Factory.GetAddressOf()));
|
||||
|
||||
return s_Factory;
|
||||
return s_Factory.Get();
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
|
@ -781,30 +781,25 @@ namespace
|
||||
|
||||
IWICImagingFactory2* _GetWIC()
|
||||
{
|
||||
static IWICImagingFactory2* s_Factory = nullptr;
|
||||
static ComPtr<IWICImagingFactory2> s_Factory;
|
||||
|
||||
if (s_Factory)
|
||||
return s_Factory;
|
||||
if ( s_Factory )
|
||||
return s_Factory.Get();
|
||||
|
||||
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
||||
|
||||
InitOnceExecuteOnce(&s_initOnce,
|
||||
[](PINIT_ONCE, PVOID, PVOID *) -> BOOL
|
||||
(void)InitOnceExecuteOnce(&s_initOnce,
|
||||
[](PINIT_ONCE, PVOID, PVOID *factory) -> BOOL
|
||||
{
|
||||
HRESULT hr = CoCreateInstance(
|
||||
return SUCCEEDED( CoCreateInstance(
|
||||
CLSID_WICImagingFactory2,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(&s_Factory));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
s_Factory = nullptr;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}, nullptr, nullptr);
|
||||
__uuidof(IWICImagingFactory2),
|
||||
factory) ) ? TRUE : FALSE;
|
||||
}, nullptr, reinterpret_cast<LPVOID*>(s_Factory.GetAddressOf()));
|
||||
|
||||
return s_Factory;
|
||||
return s_Factory.Get();
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
|
@ -168,15 +168,15 @@ namespace
|
||||
//--------------------------------------------------------------------------------------
|
||||
IWICImagingFactory* _GetWIC()
|
||||
{
|
||||
static IWICImagingFactory* s_Factory = nullptr;
|
||||
static ComPtr<IWICImagingFactory> s_Factory;
|
||||
|
||||
if ( s_Factory )
|
||||
return s_Factory;
|
||||
return s_Factory.Get();
|
||||
|
||||
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
||||
|
||||
InitOnceExecuteOnce(&s_initOnce,
|
||||
[](PINIT_ONCE, PVOID, PVOID *) -> BOOL
|
||||
[](PINIT_ONCE, PVOID, PVOID *factory) -> BOOL
|
||||
{
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
|
||||
HRESULT hr = CoCreateInstance(
|
||||
@ -184,13 +184,14 @@ namespace
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWICImagingFactory2),
|
||||
(LPVOID*)&s_Factory
|
||||
factory
|
||||
);
|
||||
|
||||
if ( SUCCEEDED(hr) )
|
||||
{
|
||||
// WIC2 is available on Windows 10, Windows 8.x, and Windows 7 SP1 with KB 2670838 installed
|
||||
g_WIC2 = true;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -198,33 +199,22 @@ namespace
|
||||
CLSID_WICImagingFactory1,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(&s_Factory)
|
||||
__uuidof(IWICImagingFactory),
|
||||
factory
|
||||
);
|
||||
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
s_Factory = nullptr;
|
||||
return FALSE;
|
||||
}
|
||||
return SUCCEEDED(hr) ? TRUE : FALSE;
|
||||
}
|
||||
#else
|
||||
HRESULT hr = CoCreateInstance(
|
||||
return SUCCEEDED( CoCreateInstance(
|
||||
CLSID_WICImagingFactory,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(&s_Factory)
|
||||
);
|
||||
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
s_Factory = nullptr;
|
||||
return FALSE;
|
||||
}
|
||||
__uuidof(IWICImagingFactory),
|
||||
factory) ) ? TRUE : FALSE;
|
||||
#endif
|
||||
return TRUE;
|
||||
}, nullptr, nullptr);
|
||||
}, nullptr, reinterpret_cast<LPVOID*>(s_Factory.GetAddressOf()));
|
||||
|
||||
return s_Factory;
|
||||
return s_Factory.Get();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
|
@ -149,30 +149,25 @@ namespace
|
||||
|
||||
IWICImagingFactory2* _GetWIC()
|
||||
{
|
||||
static IWICImagingFactory2* s_Factory = nullptr;
|
||||
static ComPtr<IWICImagingFactory2> s_Factory;
|
||||
|
||||
if (s_Factory)
|
||||
return s_Factory;
|
||||
if ( s_Factory )
|
||||
return s_Factory.Get();
|
||||
|
||||
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
||||
|
||||
InitOnceExecuteOnce(&s_initOnce,
|
||||
[](PINIT_ONCE, PVOID, PVOID *) -> BOOL
|
||||
(void)InitOnceExecuteOnce(&s_initOnce,
|
||||
[](PINIT_ONCE, PVOID, PVOID *factory) -> BOOL
|
||||
{
|
||||
HRESULT hr = CoCreateInstance(
|
||||
return SUCCEEDED( CoCreateInstance(
|
||||
CLSID_WICImagingFactory2,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_PPV_ARGS(&s_Factory));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
s_Factory = nullptr;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}, nullptr, nullptr);
|
||||
__uuidof(IWICImagingFactory2),
|
||||
factory) ) ? TRUE : FALSE;
|
||||
}, nullptr, reinterpret_cast<LPVOID*>(s_Factory.GetAddressOf()));
|
||||
|
||||
return s_Factory;
|
||||
return s_Factory.Get();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user