summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrake Arconis <drake@alchemyviewer.org>2019-02-08 19:26:28 -0800
committerDrake Arconis <drake@alchemyviewer.org>2019-02-08 19:26:28 -0800
commit6308743fd2c9fde30277c7c63aeeacd8facd9419 (patch)
tree9950e400fba8bf16c1f6838328fbce2ad0a8f889
parent2672194b1d3eb03648861a29e57d81a38f527746 (diff)
Fix issue where gamma was being corrupted on windows with night light enabled
-rw-r--r--indra/llwindow/llwindowwin32.cpp24
-rw-r--r--indra/llwindow/llwindowwin32.h5
2 files changed, 23 insertions, 6 deletions
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index 504c1589b0..27787a51a8 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -425,6 +425,9 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,
mKeyVirtualKey = 0;
mhDC = NULL;
mhRC = NULL;
+ memset(mCurrentGammaRamp, 0, sizeof(mCurrentGammaRamp));
+ memset(mPrevGammaRamp, 0, sizeof(mPrevGammaRamp));
+ mCustomGammaSet = FALSE;
if (!SystemParametersInfo(SPI_GETMOUSEVANISH, 0, &mMouseVanish, 0))
{
@@ -2989,13 +2992,26 @@ F32 LLWindowWin32::getGamma()
BOOL LLWindowWin32::restoreGamma()
{
- return SetDeviceGammaRamp(mhDC, mPrevGammaRamp);
+ if (mCustomGammaSet != FALSE)
+ {
+ mCustomGammaSet = FALSE;
+ return SetDeviceGammaRamp(mhDC, mPrevGammaRamp);
+ }
+ return TRUE;
}
BOOL LLWindowWin32::setGamma(const F32 gamma)
{
mCurrentGamma = gamma;
+ //Get the previous gamma ramp to restore later.
+ if (mCustomGammaSet == FALSE)
+ {
+ if (GetDeviceGammaRamp(mhDC, mPrevGammaRamp) == FALSE)
+ return FALSE;
+ mCustomGammaSet = TRUE;
+ }
+
LL_DEBUGS("Window") << "Setting gamma to " << gamma << LL_ENDL;
for ( int i = 0; i < 256; ++i )
@@ -3007,9 +3023,9 @@ BOOL LLWindowWin32::setGamma(const F32 gamma)
if ( value > 0xffff )
value = 0xffff;
- mCurrentGammaRamp [ 0 * 256 + i ] =
- mCurrentGammaRamp [ 1 * 256 + i ] =
- mCurrentGammaRamp [ 2 * 256 + i ] = ( WORD )value;
+ mCurrentGammaRamp[0][i] =
+ mCurrentGammaRamp[1][i] =
+ mCurrentGammaRamp[2][i] = (WORD) value;
};
return SetDeviceGammaRamp ( mhDC, mCurrentGammaRamp );
diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h
index d72623a6f4..9cd16eb993 100644
--- a/indra/llwindow/llwindowwin32.h
+++ b/indra/llwindow/llwindowwin32.h
@@ -184,8 +184,9 @@ protected:
F32 mCurrentGamma;
U32 mFSAASamples;
- WORD mPrevGammaRamp[256*3];
- WORD mCurrentGammaRamp[256*3];
+ WORD mPrevGammaRamp[3][256];
+ WORD mCurrentGammaRamp[3][256];
+ BOOL mCustomGammaSet;
LPWSTR mIconResource;
BOOL mMousePositionModified;