mirror of
https://github.com/glfw/glfw.git
synced 2025-10-04 13:46:37 +00:00
Monitor: factor out _glfwPlatformGetGammaRampSize
Factor out a helper function to retrieve current gamma ramp size out of _glfwPlatformGetGammaRamp implementations on Cocoa and X11, and add a trivial implementation for Windows. No functional change.
This commit is contained in:
parent
95341ef9fd
commit
776d431ded
@ -467,9 +467,14 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
|
||||
CVDisplayLinkRelease(link);
|
||||
}
|
||||
|
||||
int _glfwPlatformGetGammaRampSize(_GLFWmonitor* monitor)
|
||||
{
|
||||
return CGDisplayGammaTableCapacity(monitor->ns.displayID);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
{
|
||||
uint32_t i, size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
|
||||
uint32_t i, size = _glfwPlatformGetGammaRampSize(monitor);
|
||||
CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue));
|
||||
|
||||
CGGetDisplayTransferByTable(monitor->ns.displayID,
|
||||
|
@ -611,6 +611,7 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||
float* xscale, float* yscale);
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count);
|
||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode);
|
||||
int _glfwPlatformGetGammaRampSize(_GLFWmonitor* monitor);
|
||||
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
|
||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
||||
|
||||
|
@ -58,6 +58,11 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
{
|
||||
}
|
||||
|
||||
int _glfwPlatformGetGammaRampSize(_GLFWmonitor* monitor)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
{
|
||||
}
|
||||
|
@ -455,6 +455,11 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
&mode->blueBits);
|
||||
}
|
||||
|
||||
int _glfwPlatformGetGammaRampSize(_GLFWmonitor* monitor)
|
||||
{
|
||||
return 256;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
{
|
||||
HDC dc;
|
||||
|
@ -180,6 +180,11 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
*mode = monitor->modes[monitor->wl.currentMode];
|
||||
}
|
||||
|
||||
int _glfwPlatformGetGammaRampSize(_GLFWmonitor* monitor)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
|
@ -422,17 +422,28 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
}
|
||||
}
|
||||
|
||||
int _glfwPlatformGetGammaRampSize(_GLFWmonitor* monitor)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
|
||||
size = XRRGetCrtcGammaSize(_glfw.x11.display, monitor->x11.crtc);
|
||||
else if (_glfw.x11.vidmode.available)
|
||||
XF86VidModeGetGammaRampSize(_glfw.x11.display, _glfw.x11.screen, &size);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
{
|
||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
|
||||
{
|
||||
const size_t size = XRRGetCrtcGammaSize(_glfw.x11.display,
|
||||
monitor->x11.crtc);
|
||||
XRRCrtcGamma* gamma = XRRGetCrtcGamma(_glfw.x11.display,
|
||||
monitor->x11.crtc);
|
||||
int size = _glfwPlatformGetGammaRampSize(monitor);
|
||||
|
||||
_glfwAllocGammaArrays(ramp, size);
|
||||
|
||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
|
||||
{
|
||||
XRRCrtcGamma* gamma = XRRGetCrtcGamma(_glfw.x11.display,
|
||||
monitor->x11.crtc);
|
||||
memcpy(ramp->red, gamma->red, size * sizeof(unsigned short));
|
||||
memcpy(ramp->green, gamma->green, size * sizeof(unsigned short));
|
||||
memcpy(ramp->blue, gamma->blue, size * sizeof(unsigned short));
|
||||
@ -441,11 +452,6 @@ void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
}
|
||||
else if (_glfw.x11.vidmode.available)
|
||||
{
|
||||
int size;
|
||||
XF86VidModeGetGammaRampSize(_glfw.x11.display, _glfw.x11.screen, &size);
|
||||
|
||||
_glfwAllocGammaArrays(ramp, size);
|
||||
|
||||
XF86VidModeGetGammaRamp(_glfw.x11.display,
|
||||
_glfw.x11.screen,
|
||||
ramp->size, ramp->red, ramp->green, ramp->blue);
|
||||
|
Loading…
Reference in New Issue
Block a user