-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDcxDCompModule.cpp
More file actions
68 lines (56 loc) · 2.03 KB
/
DcxDCompModule.cpp
File metadata and controls
68 lines (56 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "defines.h"
#include "DcxDCompModule.h"
#include "Dcx.h"
#pragma warning(push)
#pragma warning(disable: 26425) //warning C26425 : Assigning 'nullptr' to a static variable.
DcxDCompModule::~DcxDCompModule() noexcept
{
unload();
}
bool DcxDCompModule::load()
{
if (isUseable())
return false;
// DCompModule Loading
DCX_DEBUG(mIRCLinker::debug, __FUNCTIONW__, TEXT("Loading dcomp.dll..."));
m_hModule = LoadLibrary(TEXT("dcomp.dll"));
if (m_hModule)
{
// Get function pointers.
DCompositionCreateDeviceUx = reinterpret_cast<decltype(::DCompositionCreateDevice)*>(::GetProcAddress(m_hModule, "DCompositionCreateDevice"));
DCompositionCreateDevice2Ux = reinterpret_cast<decltype(::DCompositionCreateDevice2)*>(::GetProcAddress(m_hModule, "DCompositionCreateDevice2"));
DCompositionCreateDevice3Ux = reinterpret_cast<decltype(::DCompositionCreateDevice3)*>(::GetProcAddress(m_hModule, "DCompositionCreateDevice3"));
DCompositionCreateSurfaceHandleUx = reinterpret_cast<decltype(::DCompositionCreateSurfaceHandle)*>(::GetProcAddress(m_hModule, "DCompositionCreateSurfaceHandle"));
if (DCompositionCreateDevice2Ux)
{
DCX_DEBUG(mIRCLinker::debug, __FUNCTIONW__, TEXT("Found DComp Functions"));
}
else {
unload();
// silently fail...
DCX_DEBUG(mIRCLinker::debug, __FUNCTIONW__, TEXT("Missing DComp Functions"));
}
}
else {
DCX_DEBUG(mIRCLinker::debug, __FUNCTIONW__, TEXT("Failed to load DComp dll"));
}
return isUseable();
}
bool DcxDCompModule::unload() noexcept
{
if (isUseable())
{
GSL_SUPPRESS(lifetime.1) FreeLibrary(m_hModule);
m_hModule = nullptr;
}
// make sure all functions are nullptr
DCompositionCreateDevice2Ux = nullptr;
return isUseable();
}
#pragma warning(pop)
HRESULT DcxDCompModule::dcxDCompositionCreateDevice2(IUnknown* renderingDevice, REFIID iid, void** dcompositionDevice) noexcept
{
if (DCompositionCreateDevice2Ux)
return DCompositionCreateDevice2Ux(renderingDevice, iid, dcompositionDevice);
return E_NOTIMPL;
}