This commit is contained in:
hecomi
2020-12-20 23:53:46 +09:00
parent 18c5edf423
commit ab8671fb84
9 changed files with 91 additions and 52 deletions
@@ -39,7 +39,7 @@ void Duplicator::InitializeDevice()
if (FAILED(device_->Create(monitor_->GetAdapter())))
{
Debug::Error("Monitor::Initialize() => IsolatedD3D11Device::Create() failed.");
Debug::Error("Duplicator::InitializeDevice() => IsolatedD3D11Device::Create() failed.");
state_ = State::Unknown;
}
}
@@ -1,4 +1,5 @@
#include <d3d11.h>
#include <dxgi1_6.h>
#include <ShellScalingAPI.h>
#include <queue>
#include "Monitor.h"
@@ -59,6 +60,16 @@ void Monitor::Initialize(
// DPI is set as -1, so the application has to use the appropriate value.
}
ComPtr<IDXGIOutput6> output6;
if (SUCCEEDED(output_.As(&output6)))
{
DXGI_OUTPUT_DESC1 desc1;
if (SUCCEEDED(output6->GetDesc1(&desc1)))
{
isHDR_ = desc1.ColorSpace == DXGI_COLOR_SPACE_TYPE::DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020;
}
}
const auto rot = outputDesc_.Rotation;
Debug::Log("Monitor::Initialized() =>");
Debug::Log(" ID : ", id_);
@@ -295,6 +306,12 @@ int Monitor::GetHeight() const
}
bool Monitor::IsHDR() const
{
return static_cast<int>(isHDR_);
}
int Monitor::GetMoveRectCount() const
{
const auto& metaData = duplicator_->GetLastFrame().metaData;
@@ -46,6 +46,7 @@ public:
int GetRotation() const;
int GetDpiX() const;
int GetDpiY() const;
bool IsHDR() const;
Microsoft::WRL::ComPtr<IDXGIOutputDuplication> GetDeskDupl();
int GetMoveRectCount() const;
DXGI_OUTDUPL_MOVE_RECT* GetMoveRects() const;
@@ -63,6 +64,7 @@ private:
const int id_;
UINT dpiX_ = -1, dpiY_ = -1;
int width_ = -1, height_ = -1;
bool isHDR_ = false;
bool hasBeenUpdated_ = false;
bool useGetPixels_ = false;
@@ -298,6 +298,16 @@ extern "C"
return -1;
}
UNITY_INTERFACE_EXPORT bool UNITY_INTERFACE_API IsHDR(int id)
{
if (!g_manager) return false;
if (auto monitor = g_manager->GetMonitor(id))
{
return monitor->IsHDR();
}
return false;
}
UNITY_INTERFACE_EXPORT bool UNITY_INTERFACE_API IsCursorVisible()
{
if (!g_manager) return false;