Magpie/Runtime/FrameSourceBase.h
2022-01-18 18:58:25 +08:00

44 lines
1.2 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include "pch.h"
class FrameSourceBase {
public:
FrameSourceBase() {}
virtual ~FrameSourceBase() {}
// 不可复制,不可移动
FrameSourceBase(const FrameSourceBase&) = delete;
FrameSourceBase(FrameSourceBase&&) = delete;
virtual bool Initialize() = 0;
virtual ComPtr<ID3D11Texture2D> GetOutput() = 0;
enum class UpdateState {
NewFrame,
NoUpdate,
Waiting,
Error
};
virtual UpdateState Update() = 0;
virtual bool HasRoundCornerInWin11() = 0;
virtual bool IsScreenCapture() = 0;
protected:
// 获取坐标系 1 到坐标系 2 的映射关系
// 坐标系 1屏幕坐标系即虚拟化后的坐标系。原点为屏幕左上角
// 坐标系 2虚拟化前的坐标系即窗口所见的坐标系原点为窗口左上角
// 两坐标系为线性映射a 和 b 返回该映射的参数
// 如果窗口本身支持高 DPI则 a 为 1否则 a 为 DPI 缩放的倒数
// 此函数是为了将屏幕上的点映射到窗口坐标系中,并且无视 DPI 虚拟化
// 坐标系 1 中的 (x1, y1) 映射到 (x1 * a + bx, x2 * a + by)
static bool _GetMapToOriginDPI(HWND hWnd, double& a, double& bx, double& by);
static bool _CenterWindowIfNecessary(HWND hWnd, const RECT& rcWork);
};