浏览代码

libobs/graphics: Add gs_is_monitor_hdr

Only Windows is implemented for now. Mac/Linux return false for now.
jpark37 3 年之前
父节点
当前提交
eccde48926

+ 8 - 0
docs/sphinx/reference-libobs-graphics-graphics.rst

@@ -1506,6 +1506,14 @@ Display Duplicator (Windows Only)
 ---------------------
 
 
+Monitor Functions
+---------------------------------
+
+.. function:: bool gs_is_monitor_hdr(void *monitor)
+
+---------------------
+
+
 Render Helper Functions
 -----------------------
 

+ 6 - 0
libobs-d3d11/d3d11-subsystem.cpp

@@ -3047,6 +3047,12 @@ extern "C" EXPORT bool device_p010_available(gs_device_t *device)
 	return device->p010Supported;
 }
 
+extern "C" EXPORT bool device_is_monitor_hdr(gs_device_t *device, void *monitor)
+{
+	const HMONITOR hMonitor = static_cast<HMONITOR>(monitor);
+	return screen_supports_hdr(device, hMonitor);
+}
+
 extern "C" EXPORT void device_debug_marker_begin(gs_device_t *,
 						 const char *markername,
 						 const float color[4])

+ 5 - 0
libobs-opengl/gl-cocoa.m

@@ -310,6 +310,11 @@ void device_present(gs_device_t *device)
 	[device->plat->context makeCurrentContext];
 }
 
+bool device_is_monitor_hdr(gs_device_t *device, void *monitor)
+{
+	return false;
+}
+
 void gl_getclientsize(const struct gs_swap_chain *swap, uint32_t *width,
 		      uint32_t *height)
 {

+ 5 - 0
libobs-opengl/gl-nix.c

@@ -124,6 +124,11 @@ extern void device_present(gs_device_t *device)
 	gl_vtable->device_present(device);
 }
 
+extern bool device_is_monitor_hdr(gs_device_t *device, void *monitor)
+{
+	return false;
+}
+
 extern struct gs_texture *device_texture_create_from_dmabuf(
 	gs_device_t *device, unsigned int width, unsigned int height,
 	uint32_t drm_format, enum gs_color_format color_format,

+ 5 - 0
libobs-opengl/gl-windows.c

@@ -598,6 +598,11 @@ extern void gl_getclientsize(const struct gs_swap_chain *swap, uint32_t *width,
 	}
 }
 
+EXPORT bool device_is_monitor_hdr(gs_device_t *device, void *monitor)
+{
+	return false;
+}
+
 EXPORT bool device_gdi_texture_available(void)
 {
 	return false;

+ 2 - 0
libobs/graphics/graphics-imports.c

@@ -195,6 +195,8 @@ bool load_graphics_imports(struct gs_exports *exports, void *module,
 	GRAPHICS_IMPORT_OPTIONAL(device_nv12_available);
 	GRAPHICS_IMPORT_OPTIONAL(device_p010_available);
 
+	GRAPHICS_IMPORT(device_is_monitor_hdr);
+
 	GRAPHICS_IMPORT(device_debug_marker_begin);
 	GRAPHICS_IMPORT(device_debug_marker_end);
 

+ 2 - 0
libobs/graphics/graphics-internal.h

@@ -273,6 +273,8 @@ struct gs_exports {
 	bool (*device_nv12_available)(gs_device_t *device);
 	bool (*device_p010_available)(gs_device_t *device);
 
+	bool (*device_is_monitor_hdr)(gs_device_t *device, void *monitor);
+
 	void (*device_debug_marker_begin)(gs_device_t *device,
 					  const char *markername,
 					  const float color[4]);

+ 9 - 0
libobs/graphics/graphics.c

@@ -2840,6 +2840,15 @@ bool gs_p010_available(void)
 		thread_graphics->device);
 }
 
+bool gs_is_monitor_hdr(void *monitor)
+{
+	if (!gs_valid("gs_is_monitor_hdr"))
+		return false;
+
+	return thread_graphics->exports.device_is_monitor_hdr(
+		thread_graphics->device, monitor);
+}
+
 void gs_debug_marker_begin(const float color[4], const char *markername)
 {
 	if (!gs_valid("gs_debug_marker_begin"))

+ 2 - 0
libobs/graphics/graphics.h

@@ -851,6 +851,8 @@ EXPORT bool gs_timer_range_get_data(gs_timer_range_t *range, bool *disjoint,
 EXPORT bool gs_nv12_available(void);
 EXPORT bool gs_p010_available(void);
 
+EXPORT bool gs_is_monitor_hdr(void *monitor);
+
 #define GS_USE_DEBUG_MARKERS 0
 #if GS_USE_DEBUG_MARKERS
 static const float GS_DEBUG_COLOR_DEFAULT[] = {0.5f, 0.5f, 0.5f, 1.0f};