mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
25 lines
714 B
C++
25 lines
714 B
C++
#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;
|
|
}
|