Only restore gamma ramp if it has been changed.

This commit is contained in:
Camilla Berglund 2012-05-24 11:46:51 +02:00
parent f5eb79ed28
commit 79bef68511
5 changed files with 7 additions and 3 deletions

View File

@ -129,6 +129,7 @@ int _glfwPlatformTerminate(void)
} }
// Restore the original gamma ramp // Restore the original gamma ramp
if (_glfwLibrary.rampChanged)
_glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp); _glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp);
CGDisplayModeRelease(_glfwLibrary.NS.desktopMode); CGDisplayModeRelease(_glfwLibrary.NS.desktopMode);

View File

@ -112,5 +112,6 @@ GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp)
_glfwPlatformSetGammaRamp(ramp); _glfwPlatformSetGammaRamp(ramp);
_glfwLibrary.currentRamp = *ramp; _glfwLibrary.currentRamp = *ramp;
_glfwLibrary.rampChanged = GL_TRUE;
} }

View File

@ -245,6 +245,7 @@ struct _GLFWlibrary
GLFWgammaramp currentRamp; GLFWgammaramp currentRamp;
GLFWgammaramp originalRamp; GLFWgammaramp originalRamp;
int originalRampSize; int originalRampSize;
GLboolean rampChanged;
// This is defined in the current port's platform.h // This is defined in the current port's platform.h
_GLFW_PLATFORM_LIBRARY_WINDOW_STATE; _GLFW_PLATFORM_LIBRARY_WINDOW_STATE;

View File

@ -190,6 +190,7 @@ int _glfwPlatformInit(void)
int _glfwPlatformTerminate(void) int _glfwPlatformTerminate(void)
{ {
// Restore the original gamma ramp // Restore the original gamma ramp
if (_glfwLibrary.rampChanged)
_glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp); _glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp);
if (_glfwLibrary.Win32.classAtom) if (_glfwLibrary.Win32.classAtom)

View File

@ -659,7 +659,7 @@ static Cursor createNULLCursor(void)
static void terminateDisplay(void) static void terminateDisplay(void)
{ {
if (_glfwLibrary.originalRampSize) if (_glfwLibrary.originalRampSize && _glfwLibrary.rampChanged)
_glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp); _glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp);
if (_glfwLibrary.X11.display) if (_glfwLibrary.X11.display)