mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add support for DirectX desktop capturer backend.
This commit is contained in:
parent
50558de591
commit
2830049a53
1 changed files with 63 additions and 19 deletions
|
@ -14,25 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
|
|
||||||
HRESULT WINAPI D3D11CreateDevice(
|
#define LOAD_METHOD(lib, name) ::base::Platform::LoadMethod(lib, #name, name)
|
||||||
_In_opt_ IDXGIAdapter* pAdapter,
|
|
||||||
D3D_DRIVER_TYPE DriverType,
|
|
||||||
HMODULE Software,
|
|
||||||
UINT Flags,
|
|
||||||
_In_reads_opt_(FeatureLevels) CONST D3D_FEATURE_LEVEL* pFeatureLevels,
|
|
||||||
UINT FeatureLevels,
|
|
||||||
UINT SDKVersion,
|
|
||||||
_COM_Outptr_opt_ ID3D11Device** ppDevice,
|
|
||||||
_Out_opt_ D3D_FEATURE_LEVEL* pFeatureLevel,
|
|
||||||
_COM_Outptr_opt_ ID3D11DeviceContext** ppImmediateContext) {
|
|
||||||
return S_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT WINAPI CreateDXGIFactory1(
|
|
||||||
REFIID riid,
|
|
||||||
_COM_Outptr_ void **ppFactory) {
|
|
||||||
return S_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
namespace Dlls {
|
namespace Dlls {
|
||||||
|
@ -64,6 +46,8 @@ void init() {
|
||||||
u"rstrtmgr.dll"_q,
|
u"rstrtmgr.dll"_q,
|
||||||
u"psapi.dll"_q,
|
u"psapi.dll"_q,
|
||||||
u"user32.dll"_q,
|
u"user32.dll"_q,
|
||||||
|
u"d3d11.dll"_q,
|
||||||
|
u"dxgi.dll"_q,
|
||||||
};
|
};
|
||||||
for (const auto &lib : list) {
|
for (const auto &lib : list) {
|
||||||
SafeLoadLibrary(lib);
|
SafeLoadLibrary(lib);
|
||||||
|
@ -92,6 +76,26 @@ f_DwmSetWindowAttribute DwmSetWindowAttribute;
|
||||||
f_GetProcessMemoryInfo GetProcessMemoryInfo;
|
f_GetProcessMemoryInfo GetProcessMemoryInfo;
|
||||||
f_SetWindowCompositionAttribute SetWindowCompositionAttribute;
|
f_SetWindowCompositionAttribute SetWindowCompositionAttribute;
|
||||||
|
|
||||||
|
// D3D11.DLL
|
||||||
|
|
||||||
|
HRESULT (__stdcall *D3D11CreateDevice)(
|
||||||
|
_In_opt_ IDXGIAdapter* pAdapter,
|
||||||
|
D3D_DRIVER_TYPE DriverType,
|
||||||
|
HMODULE Software,
|
||||||
|
UINT Flags,
|
||||||
|
_In_reads_opt_(FeatureLevels) CONST D3D_FEATURE_LEVEL* pFeatureLevels,
|
||||||
|
UINT FeatureLevels,
|
||||||
|
UINT SDKVersion,
|
||||||
|
_COM_Outptr_opt_ ID3D11Device** ppDevice,
|
||||||
|
_Out_opt_ D3D_FEATURE_LEVEL* pFeatureLevel,
|
||||||
|
_COM_Outptr_opt_ ID3D11DeviceContext** ppImmediateContext);
|
||||||
|
|
||||||
|
// DXGI.DLL
|
||||||
|
|
||||||
|
HRESULT (__stdcall *CreateDXGIFactory1)(
|
||||||
|
REFIID riid,
|
||||||
|
_COM_Outptr_ void **ppFactory);
|
||||||
|
|
||||||
void start() {
|
void start() {
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
@ -141,7 +145,47 @@ void start() {
|
||||||
|
|
||||||
const auto LibUser32 = SafeLoadLibrary(u"user32.dll"_q);
|
const auto LibUser32 = SafeLoadLibrary(u"user32.dll"_q);
|
||||||
LoadMethod(LibUser32, "SetWindowCompositionAttribute", SetWindowCompositionAttribute);
|
LoadMethod(LibUser32, "SetWindowCompositionAttribute", SetWindowCompositionAttribute);
|
||||||
|
|
||||||
|
const auto LibD3D11 = SafeLoadLibrary(u"d3d11.dll"_q);
|
||||||
|
LOAD_METHOD(LibD3D11, D3D11CreateDevice);
|
||||||
|
|
||||||
|
const auto LibDXGI = SafeLoadLibrary(u"dxgi.dll"_q);
|
||||||
|
LOAD_METHOD(LibDXGI, CreateDXGIFactory1);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Dlls
|
} // namespace Dlls
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
||||||
|
HRESULT WINAPI D3D11CreateDevice(
|
||||||
|
_In_opt_ IDXGIAdapter* pAdapter,
|
||||||
|
D3D_DRIVER_TYPE DriverType,
|
||||||
|
HMODULE Software,
|
||||||
|
UINT Flags,
|
||||||
|
_In_reads_opt_(FeatureLevels) CONST D3D_FEATURE_LEVEL* pFeatureLevels,
|
||||||
|
UINT FeatureLevels,
|
||||||
|
UINT SDKVersion,
|
||||||
|
_COM_Outptr_opt_ ID3D11Device** ppDevice,
|
||||||
|
_Out_opt_ D3D_FEATURE_LEVEL* pFeatureLevel,
|
||||||
|
_COM_Outptr_opt_ ID3D11DeviceContext** ppImmediateContext) {
|
||||||
|
return Platform::Dlls::D3D11CreateDevice
|
||||||
|
? Platform::Dlls::D3D11CreateDevice(
|
||||||
|
pAdapter,
|
||||||
|
DriverType,
|
||||||
|
Software,
|
||||||
|
Flags,
|
||||||
|
pFeatureLevels,
|
||||||
|
FeatureLevels,
|
||||||
|
SDKVersion,
|
||||||
|
ppDevice,
|
||||||
|
pFeatureLevel,
|
||||||
|
ppImmediateContext)
|
||||||
|
: S_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI CreateDXGIFactory1(
|
||||||
|
REFIID riid,
|
||||||
|
_COM_Outptr_ void **ppFactory) {
|
||||||
|
return Platform::Dlls::CreateDXGIFactory1
|
||||||
|
? Platform::Dlls::CreateDXGIFactory1(riid, ppFactory)
|
||||||
|
: S_FALSE;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue