-
Notifications
You must be signed in to change notification settings - Fork 418
Expand file tree
/
Copy pathDesktopDupScreencap.h
More file actions
53 lines (41 loc) · 1.31 KB
/
DesktopDupScreencap.h
File metadata and controls
53 lines (41 loc) · 1.31 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
#pragma once
#include "Base/UnitBase.h"
#include "SafeDXGI.hpp"
#include "Common/Conf.h"
MAA_CTRL_UNIT_NS_BEGIN
class DesktopDupScreencap : public ScreencapBase
{
public:
explicit DesktopDupScreencap(HWND hwnd = nullptr)
: hwnd_(hwnd)
{
}
virtual ~DesktopDupScreencap() override;
public: // from ScreencapBase
virtual std::optional<cv::Mat> screencap() override;
protected:
bool init();
bool init_texture(ID3D11Texture2D* raw_texture);
void uninit();
std::optional<cv::Mat> screencap_impl();
cv::Mat process_texture_data(const D3D11_MAPPED_SUBRESOURCE& mapped);
ID3D11Device* d3d_device_ = nullptr;
ID3D11DeviceContext* d3d_context_ = nullptr;
IDXGIFactory* dxgi_factory_ = nullptr;
IDXGIAdapter* dxgi_adapter_ = nullptr;
IDXGIOutput1* dxgi_output_ = nullptr;
IDXGIOutputDuplication* dxgi_dup_ = nullptr;
ID3D11Texture2D* readable_texture_ = nullptr;
D3D11_TEXTURE2D_DESC texture_desc_ { 0 };
HWND hwnd_ = nullptr;
HMONITOR current_monitor_ = nullptr;
bool output_just_initialized_ = false;
private:
bool init_d3d_device();
bool init_dxgi_factory();
bool find_output_by_monitor(HMONITOR monitor);
bool init_primary_output();
bool init_output_duplication();
bool ensure_output_for_monitor();
};
MAA_CTRL_UNIT_NS_END