From 79bef6851156e710df564cc7607698b4e30152a7 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 24 May 2012 11:46:51 +0200 Subject: [PATCH] Only restore gamma ramp if it has been changed. --- src/cocoa_init.m | 3 ++- src/gamma.c | 1 + src/internal.h | 1 + src/win32_init.c | 3 ++- src/x11_init.c | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 329bcfa4..7c208b90 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -129,7 +129,8 @@ int _glfwPlatformTerminate(void) } // Restore the original gamma ramp - _glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp); + if (_glfwLibrary.rampChanged) + _glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp); CGDisplayModeRelease(_glfwLibrary.NS.desktopMode); diff --git a/src/gamma.c b/src/gamma.c index 34cb22f5..21940b0e 100644 --- a/src/gamma.c +++ b/src/gamma.c @@ -112,5 +112,6 @@ GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp) _glfwPlatformSetGammaRamp(ramp); _glfwLibrary.currentRamp = *ramp; + _glfwLibrary.rampChanged = GL_TRUE; } diff --git a/src/internal.h b/src/internal.h index 6398bdc5..681df74d 100644 --- a/src/internal.h +++ b/src/internal.h @@ -245,6 +245,7 @@ struct _GLFWlibrary GLFWgammaramp currentRamp; GLFWgammaramp originalRamp; int originalRampSize; + GLboolean rampChanged; // This is defined in the current port's platform.h _GLFW_PLATFORM_LIBRARY_WINDOW_STATE; diff --git a/src/win32_init.c b/src/win32_init.c index 2422dd4b..194ff6c4 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -190,7 +190,8 @@ int _glfwPlatformInit(void) int _glfwPlatformTerminate(void) { // Restore the original gamma ramp - _glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp); + if (_glfwLibrary.rampChanged) + _glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp); if (_glfwLibrary.Win32.classAtom) { diff --git a/src/x11_init.c b/src/x11_init.c index 6ea80351..3543c9f5 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -659,7 +659,7 @@ static Cursor createNULLCursor(void) static void terminateDisplay(void) { - if (_glfwLibrary.originalRampSize) + if (_glfwLibrary.originalRampSize && _glfwLibrary.rampChanged) _glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp); if (_glfwLibrary.X11.display)