libobs/graphics: Add gs_is_monitor_hdr

Only Windows is implemented for now. Mac/Linux return false for now.
master
jpark37 2022-03-09 21:41:23 -08:00
parent abddfead2f
commit eccde48926
9 changed files with 44 additions and 0 deletions

View File

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

View File

@ -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])

View File

@ -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)
{

View File

@ -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,

View File

@ -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;

View File

@ -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);

View File

@ -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]);

View File

@ -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"))

View File

@ -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};