From 54c882713591000383704ccd3c5866a226918eef Mon Sep 17 00:00:00 2001
From: Loren Shih <seraph@lindenlab.com>
Date: Thu, 4 Nov 2010 16:54:20 -0400
Subject: [PATCH] SH-353 FIXED Crash when toggling anisotropic filtering

---
 indra/llrender/llimagegl.h                  |  1 +
 indra/newview/llfloaterhardwaresettings.cpp | 25 ---------------------
 indra/newview/llviewercontrol.cpp           |  8 +++++++
 3 files changed, 9 insertions(+), 25 deletions(-)

diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h
index 87a835cdccf..6c980984c0a 100644
--- a/indra/llrender/llimagegl.h
+++ b/indra/llrender/llimagegl.h
@@ -64,6 +64,7 @@ class LLImageGL : public LLRefCount
 	// Save off / restore GL textures
 	static void destroyGL(BOOL save_state = TRUE);
 	static void restoreGL();
+	static void dirtyTexOptions();
 
 	// Sometimes called externally for textures not using LLImageGL (should go away...)	
 	static S32 updateBoundTexMem(const S32 mem, const S32 ncomponents, S32 category) ;
diff --git a/indra/newview/llfloaterhardwaresettings.cpp b/indra/newview/llfloaterhardwaresettings.cpp
index e562b00a046..1e917105522 100644
--- a/indra/newview/llfloaterhardwaresettings.cpp
+++ b/indra/newview/llfloaterhardwaresettings.cpp
@@ -131,31 +131,6 @@ BOOL LLFloaterHardwareSettings::postBuild()
 
 void LLFloaterHardwareSettings::apply()
 {
-	// Anisotropic rendering
-	//Do nothing here -- this code is unreliable, and UI now tells users to restart for changes to take affect
-	/*BOOL old_anisotropic = LLImageGL::sGlobalUseAnisotropic;
-	LLImageGL::sGlobalUseAnisotropic = getChild<LLUICtrl>("ani")->getValue();
-
-	U32 fsaa = (U32) getChild<LLUICtrl>("fsaa")->getValue().asInteger();
-	U32 old_fsaa = gSavedSettings.getU32("RenderFSAASamples");
-
-	BOOL logged_in = (LLStartUp::getStartupState() >= STATE_STARTED);
-
-	if (old_fsaa != fsaa)
-	{
-		gSavedSettings.setU32("RenderFSAASamples", fsaa);
-		LLWindow* window = gViewerWindow->getWindow();
-		LLCoordScreen size;
-		window->getSize(&size);
-		gViewerWindow->changeDisplaySettings(size,
-											gSavedSettings.getBOOL("DisableVerticalSync"),
-											logged_in);
-	}
-	else if (old_anisotropic != LLImageGL::sGlobalUseAnisotropic)
-	{
-		gViewerWindow->restartDisplay(logged_in);
-	}*/
-
 	refresh();
 }
 
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 522b5a7dfa5..fbec2a7b9e6 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -131,6 +131,13 @@ static bool handleReleaseGLBufferChanged(const LLSD& newvalue)
 	return true;
 }
 
+static bool handleAnisotropicChanged(const LLSD& newvalue)
+{
+	LLImageGL::sGlobalUseAnisotropic = newvalue.asBoolean();
+	LLImageGL::dirtyTexOptions();
+	return true;
+}
+
 static bool handleVolumeLODChanged(const LLSD& newvalue)
 {
 	LLVOVolume::sLODFactor = (F32) newvalue.asReal();
@@ -498,6 +505,7 @@ void settings_setup_listeners()
 	gSavedSettings.getControl("RenderSpecularResY")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderSpecularExponent")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderFSAASamples")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
+	gSavedSettings.getControl("RenderAnisotropic")->getSignal()->connect(boost::bind(&handleAnisotropicChanged, _2));
 	gSavedSettings.getControl("RenderShadowResolutionScale")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
 	gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
-- 
GitLab