FIRE-12561: f.lux custom color profile will cause video driver to fail upon exit; Fix by Drake Arconis (Alchemy Viewer)

Ansariel 2017-11-25 16:58:52 +01:00
parent 1f767e498a
commit 34b2565d4a
2 changed files with 24 additions and 7 deletions

View File

@ -423,6 +423,9 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,
mKeyVirtualKey = 0;
mhDC = NULL;
mhRC = NULL;
memset(mCurrentGammaRamp, 0, sizeof(mCurrentGammaRamp));
memset(mPrevGammaRamp, 0, sizeof(mPrevGammaRamp));
mCustomGammaSet = FALSE;
// <FS:Ansariel> Respect "Hide pointer while typing" Windows preference setting
if (!SystemParametersInfo(SPI_GETMOUSEVANISH, 0, &mMouseVanish, 0))
@ -788,7 +791,7 @@ void LLWindowWin32::close()
if (mhDC && !ReleaseDC(mWindowHandle, mhDC))
{
LL_WARNS("Window") << "Release of ghDC failed" << LL_ENDL;
LL_WARNS("Window") << "Release of mhDC failed" << LL_ENDL;
mhDC = NULL;
}
@ -2991,13 +2994,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 )
@ -3009,9 +3025,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 );

View File

@ -194,8 +194,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;