add isHDR #46
This commit is contained in:
@@ -80,6 +80,7 @@ public class TextureEditor : Editor
|
|||||||
EditorGUILayout.EnumPopup("Rotation", monitor.rotation);
|
EditorGUILayout.EnumPopup("Rotation", monitor.rotation);
|
||||||
EditorGUILayout.Vector2Field("Resolution", new Vector2(monitor.width, monitor.height));
|
EditorGUILayout.Vector2Field("Resolution", new Vector2(monitor.width, monitor.height));
|
||||||
EditorGUILayout.Vector2Field("DPI", new Vector2(monitor.dpiX, monitor.dpiY));
|
EditorGUILayout.Vector2Field("DPI", new Vector2(monitor.dpiX, monitor.dpiY));
|
||||||
|
EditorGUILayout.Toggle("Is HDR", monitor.isHDR);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -76,111 +76,115 @@ public struct DXGI_OUTDUPL_MOVE_RECT
|
|||||||
|
|
||||||
public static class Lib
|
public static class Lib
|
||||||
{
|
{
|
||||||
|
const string dllName = "uDesktopDuplication";
|
||||||
|
|
||||||
public delegate void MessageHandler(Message message);
|
public delegate void MessageHandler(Message message);
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public delegate void DebugLogDelegate(string str);
|
public delegate void DebugLogDelegate(string str);
|
||||||
|
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern bool IsInitialized();
|
public static extern bool IsInitialized();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern void Initialize();
|
public static extern void Initialize();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern void Finalize();
|
public static extern void Finalize();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern void Reinitialize();
|
public static extern void Reinitialize();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern void Update();
|
public static extern void Update();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern Message PopMessage();
|
public static extern Message PopMessage();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern void EnableDebug();
|
public static extern void EnableDebug();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern void DisableDebug();
|
public static extern void DisableDebug();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern void SetDebugMode(DebugMode mode);
|
public static extern void SetDebugMode(DebugMode mode);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern void SetLogFunc(DebugLogDelegate func);
|
public static extern void SetLogFunc(DebugLogDelegate func);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern void SetErrorFunc(DebugLogDelegate func);
|
public static extern void SetErrorFunc(DebugLogDelegate func);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetMonitorCount();
|
public static extern int GetMonitorCount();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern bool HasMonitorCountChanged();
|
public static extern bool HasMonitorCountChanged();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetCursorMonitorId();
|
public static extern int GetCursorMonitorId();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetTotalWidth();
|
public static extern int GetTotalWidth();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetTotalHeight();
|
public static extern int GetTotalHeight();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern IntPtr GetRenderEventFunc();
|
public static extern IntPtr GetRenderEventFunc();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetId(int id);
|
public static extern int GetId(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern DuplicatorState GetState(int id);
|
public static extern DuplicatorState GetState(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern void GetName(int id, StringBuilder buf, int len);
|
public static extern void GetName(int id, StringBuilder buf, int len);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetLeft(int id);
|
public static extern int GetLeft(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetRight(int id);
|
public static extern int GetRight(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetTop(int id);
|
public static extern int GetTop(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetBottom(int id);
|
public static extern int GetBottom(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetWidth(int id);
|
public static extern int GetWidth(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetHeight(int id);
|
public static extern int GetHeight(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetDpiX(int id);
|
public static extern int GetDpiX(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetDpiY(int id);
|
public static extern int GetDpiY(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
|
public static extern bool IsHDR(int id);
|
||||||
|
[DllImport(dllName)]
|
||||||
public static extern MonitorRotation GetRotation(int id);
|
public static extern MonitorRotation GetRotation(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern bool IsPrimary(int id);
|
public static extern bool IsPrimary(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern bool IsCursorVisible();
|
public static extern bool IsCursorVisible();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetCursorX();
|
public static extern int GetCursorX();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetCursorY();
|
public static extern int GetCursorY();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetCursorShapeWidth();
|
public static extern int GetCursorShapeWidth();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetCursorShapeHeight();
|
public static extern int GetCursorShapeHeight();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetCursorShapePitch();
|
public static extern int GetCursorShapePitch();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern CursorShapeType GetCursorShapeType();
|
public static extern CursorShapeType GetCursorShapeType();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern void GetCursorTexture(IntPtr ptr);
|
public static extern void GetCursorTexture(IntPtr ptr);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetCursorHotSpotX();
|
public static extern int GetCursorHotSpotX();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetCursorHotSpotY();
|
public static extern int GetCursorHotSpotY();
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int SetTexturePtr(int id, IntPtr ptr);
|
public static extern int SetTexturePtr(int id, IntPtr ptr);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern IntPtr GetSharedTextureHandle(int id);
|
public static extern IntPtr GetSharedTextureHandle(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetMoveRectCount(int id);
|
public static extern int GetMoveRectCount(int id);
|
||||||
[DllImport("uDesktopDuplication", EntryPoint = "GetMoveRects")]
|
[DllImport(dllName, EntryPoint = "GetMoveRects")]
|
||||||
private static extern IntPtr GetMoveRects_Internal(int id);
|
private static extern IntPtr GetMoveRects_Internal(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern int GetDirtyRectCount(int id);
|
public static extern int GetDirtyRectCount(int id);
|
||||||
[DllImport("uDesktopDuplication", EntryPoint = "GetDirtyRects")]
|
[DllImport(dllName, EntryPoint = "GetDirtyRects")]
|
||||||
private static extern IntPtr GetDirtyRects_Internal(int id);
|
private static extern IntPtr GetDirtyRects_Internal(int id);
|
||||||
[DllImport("uDesktopDuplication", EntryPoint = "GetPixels")]
|
[DllImport(dllName, EntryPoint = "GetPixels")]
|
||||||
private static extern bool GetPixels_Internal(int id, IntPtr ptr, int x, int y, int width, int height);
|
private static extern bool GetPixels_Internal(int id, IntPtr ptr, int x, int y, int width, int height);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern IntPtr GetBuffer(int id);
|
public static extern IntPtr GetBuffer(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern bool HasBeenUpdated(int id);
|
public static extern bool HasBeenUpdated(int id);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern bool UseGetPixels(int id, bool use);
|
public static extern bool UseGetPixels(int id, bool use);
|
||||||
[DllImport("uDesktopDuplication")]
|
[DllImport(dllName)]
|
||||||
public static extern void SetFrameRate(uint frameRate);
|
public static extern void SetFrameRate(uint frameRate);
|
||||||
|
|
||||||
public static string GetName(int id)
|
public static string GetName(int id)
|
||||||
|
|||||||
@@ -130,6 +130,11 @@ public class Monitor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool isHDR
|
||||||
|
{
|
||||||
|
get { return Lib.IsHDR(id); }
|
||||||
|
}
|
||||||
|
|
||||||
public float widthMeter
|
public float widthMeter
|
||||||
{
|
{
|
||||||
get { return width / dpiX * 0.0254f; }
|
get { return width / dpiX * 0.0254f; }
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ void Duplicator::InitializeDevice()
|
|||||||
|
|
||||||
if (FAILED(device_->Create(monitor_->GetAdapter())))
|
if (FAILED(device_->Create(monitor_->GetAdapter())))
|
||||||
{
|
{
|
||||||
Debug::Error("Monitor::Initialize() => IsolatedD3D11Device::Create() failed.");
|
Debug::Error("Duplicator::InitializeDevice() => IsolatedD3D11Device::Create() failed.");
|
||||||
state_ = State::Unknown;
|
state_ = State::Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
|
#include <dxgi1_6.h>
|
||||||
#include <ShellScalingAPI.h>
|
#include <ShellScalingAPI.h>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include "Monitor.h"
|
#include "Monitor.h"
|
||||||
@@ -59,6 +60,16 @@ void Monitor::Initialize(
|
|||||||
// DPI is set as -1, so the application has to use the appropriate value.
|
// 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;
|
const auto rot = outputDesc_.Rotation;
|
||||||
Debug::Log("Monitor::Initialized() =>");
|
Debug::Log("Monitor::Initialized() =>");
|
||||||
Debug::Log(" ID : ", id_);
|
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
|
int Monitor::GetMoveRectCount() const
|
||||||
{
|
{
|
||||||
const auto& metaData = duplicator_->GetLastFrame().metaData;
|
const auto& metaData = duplicator_->GetLastFrame().metaData;
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public:
|
|||||||
int GetRotation() const;
|
int GetRotation() const;
|
||||||
int GetDpiX() const;
|
int GetDpiX() const;
|
||||||
int GetDpiY() const;
|
int GetDpiY() const;
|
||||||
|
bool IsHDR() const;
|
||||||
Microsoft::WRL::ComPtr<IDXGIOutputDuplication> GetDeskDupl();
|
Microsoft::WRL::ComPtr<IDXGIOutputDuplication> GetDeskDupl();
|
||||||
int GetMoveRectCount() const;
|
int GetMoveRectCount() const;
|
||||||
DXGI_OUTDUPL_MOVE_RECT* GetMoveRects() const;
|
DXGI_OUTDUPL_MOVE_RECT* GetMoveRects() const;
|
||||||
@@ -63,6 +64,7 @@ private:
|
|||||||
const int id_;
|
const int id_;
|
||||||
UINT dpiX_ = -1, dpiY_ = -1;
|
UINT dpiX_ = -1, dpiY_ = -1;
|
||||||
int width_ = -1, height_ = -1;
|
int width_ = -1, height_ = -1;
|
||||||
|
bool isHDR_ = false;
|
||||||
bool hasBeenUpdated_ = false;
|
bool hasBeenUpdated_ = false;
|
||||||
bool useGetPixels_ = false;
|
bool useGetPixels_ = false;
|
||||||
|
|
||||||
|
|||||||
@@ -298,6 +298,16 @@ extern "C"
|
|||||||
return -1;
|
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()
|
UNITY_INTERFACE_EXPORT bool UNITY_INTERFACE_API IsCursorVisible()
|
||||||
{
|
{
|
||||||
if (!g_manager) return false;
|
if (!g_manager) return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user