add isHDR #46
This commit is contained in:
@@ -80,6 +80,7 @@ public class TextureEditor : Editor
|
||||
EditorGUILayout.EnumPopup("Rotation", monitor.rotation);
|
||||
EditorGUILayout.Vector2Field("Resolution", new Vector2(monitor.width, monitor.height));
|
||||
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
|
||||
{
|
||||
const string dllName = "uDesktopDuplication";
|
||||
|
||||
public delegate void MessageHandler(Message message);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void DebugLogDelegate(string str);
|
||||
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern bool IsInitialized();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern void Initialize();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern void Finalize();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern void Reinitialize();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern void Update();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern Message PopMessage();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern void EnableDebug();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern void DisableDebug();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern void SetDebugMode(DebugMode mode);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern void SetLogFunc(DebugLogDelegate func);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern void SetErrorFunc(DebugLogDelegate func);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetMonitorCount();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern bool HasMonitorCountChanged();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetCursorMonitorId();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetTotalWidth();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetTotalHeight();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern IntPtr GetRenderEventFunc();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetId(int id);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern DuplicatorState GetState(int id);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern void GetName(int id, StringBuilder buf, int len);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetLeft(int id);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetRight(int id);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetTop(int id);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetBottom(int id);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetWidth(int id);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetHeight(int id);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetDpiX(int id);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
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);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern bool IsPrimary(int id);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern bool IsCursorVisible();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetCursorX();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetCursorY();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetCursorShapeWidth();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetCursorShapeHeight();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetCursorShapePitch();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern CursorShapeType GetCursorShapeType();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern void GetCursorTexture(IntPtr ptr);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetCursorHotSpotX();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetCursorHotSpotY();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int SetTexturePtr(int id, IntPtr ptr);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern IntPtr GetSharedTextureHandle(int id);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetMoveRectCount(int id);
|
||||
[DllImport("uDesktopDuplication", EntryPoint = "GetMoveRects")]
|
||||
[DllImport(dllName, EntryPoint = "GetMoveRects")]
|
||||
private static extern IntPtr GetMoveRects_Internal(int id);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern int GetDirtyRectCount(int id);
|
||||
[DllImport("uDesktopDuplication", EntryPoint = "GetDirtyRects")]
|
||||
[DllImport(dllName, EntryPoint = "GetDirtyRects")]
|
||||
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);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern IntPtr GetBuffer(int id);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern bool HasBeenUpdated(int id);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern bool UseGetPixels(int id, bool use);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
[DllImport(dllName)]
|
||||
public static extern void SetFrameRate(uint frameRate);
|
||||
|
||||
public static string GetName(int id)
|
||||
|
||||
@@ -130,6 +130,11 @@ public class Monitor
|
||||
}
|
||||
}
|
||||
|
||||
public bool isHDR
|
||||
{
|
||||
get { return Lib.IsHDR(id); }
|
||||
}
|
||||
|
||||
public float widthMeter
|
||||
{
|
||||
get { return width / dpiX * 0.0254f; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user