feat: 实现 PrintWindow 捕获方式

速度很慢,暂不支持 UWP 窗口
This commit is contained in:
Xu Liu 2021-11-30 21:21:48 +08:00
commit 738db504b2
9 changed files with 65 additions and 7 deletions

View file

@ -0,0 +1,25 @@
#include "pch.h"
#include "PrintWindowFrameSource.h"
#include "App.h"
extern std::shared_ptr<spdlog::logger> logger;
bool PrintWindowFrameSource::Update() {
HDC hdcDest;
HRESULT hr = _dxgiSurface->GetDC(TRUE, &hdcDest);
if (FAILED(hr)) {
SPDLOG_LOGGER_ERROR(logger, MakeComErrorMsg("从 Texture2D 获取 IDXGISurface1 失败", hr));
return false;
}
// https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/ui/snapshot/snapshot_win.cc
// 不支持子窗口
if (!PrintWindow(App::GetInstance().GetHwndSrc(), hdcDest, PW_CLIENTONLY | PW_RENDERFULLCONTENT)) {
SPDLOG_LOGGER_ERROR(logger, MakeWin32ErrorMsg("PrintWindow 失败"));
}
_dxgiSurface->ReleaseDC(nullptr);
return true;
}