From d71736f3d92f1a276d4aafcbf70c6a8597457220 Mon Sep 17 00:00:00 2001
From: Leslie Linden <leslie@lindenlab.com>
Date: Tue, 15 Nov 2011 17:32:09 -0800
Subject: [PATCH] SH-1865 PROGRESS -- Disable the anti-aliasing control on
 hardware our code doesn't support for anti-aliasing

---
 indra/llui/llspinctrl.h                       |  3 ++
 indra/newview/llfloaterhardwaresettings.cpp   | 38 +++++++++++++++----
 indra/newview/pipeline.cpp                    |  4 +-
 .../xui/en/floater_hardware_settings.xml      |  2 +-
 4 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/indra/llui/llspinctrl.h b/indra/llui/llspinctrl.h
index d197084e38f..87814f838e8 100644
--- a/indra/llui/llspinctrl.h
+++ b/indra/llui/llspinctrl.h
@@ -96,6 +96,9 @@ class LLSpinCtrl
 
 	void			onUpBtn(const LLSD& data);
 	void			onDownBtn(const LLSD& data);
+	
+	const LLColor4&	getEnabledTextColor() const	{ return mTextEnabledColor.get(); }
+	const LLColor4&	getDisabledTextColor() const { return mTextDisabledColor.get(); }
 
 private:
 	void			updateLabelColor();
diff --git a/indra/newview/llfloaterhardwaresettings.cpp b/indra/newview/llfloaterhardwaresettings.cpp
index 42ec7d765b4..f9a403cf9ff 100644
--- a/indra/newview/llfloaterhardwaresettings.cpp
+++ b/indra/newview/llfloaterhardwaresettings.cpp
@@ -34,7 +34,9 @@
 #include "llviewercontrol.h"
 #include "llviewertexturelist.h"
 #include "llfeaturemanager.h"
+#include "llspinctrl.h"
 #include "llstartup.h"
+#include "lltextbox.h"
 #include "pipeline.h"
 
 // Linden library includes
@@ -98,18 +100,40 @@ void LLFloaterHardwareSettings::refreshEnabledState()
 	}
 
 	// if no windlight shaders, turn off nighttime brightness, gamma, and fog distance
-	getChildView("gamma")->setEnabled(!gPipeline.canUseWindLightShaders());
+	LLSpinCtrl* gamma_ctrl = getChild<LLSpinCtrl>("gamma");
+	gamma_ctrl->setEnabled(!gPipeline.canUseWindLightShaders());
 	getChildView("(brightness, lower is brighter)")->setEnabled(!gPipeline.canUseWindLightShaders());
 	getChildView("fog")->setEnabled(!gPipeline.canUseWindLightShaders());
-	getChildView("fsaa")->setEnabled(gPipeline.canUseAntiAliasing());
-	getChildView("antialiasing restart")->setVisible(!gSavedSettings.getBOOL("RenderDeferred"));
 
-	/* Enable to reset fsaa value to disabled when feature is not available.
-	if (!gPipeline.canUseAntiAliasing())
+	// anti-aliasing
 	{
-		getChild<LLUICtrl>("fsaa")->setValue((LLSD::Integer) 0);
+		LLUICtrl* fsaa_ctrl = getChild<LLUICtrl>("fsaa");
+		LLTextBox* fsaa_text = getChild<LLTextBox>("antialiasing label");
+		LLView* fsaa_restart = getChildView("antialiasing restart");
+		
+		// Enable or disable the control, the "Antialiasing:" label and the restart warning
+		// based on code support for the feature on the current hardware.
+
+		if (gPipeline.canUseAntiAliasing())
+		{
+			fsaa_ctrl->setEnabled(TRUE);
+			
+			// borrow the text color from the gamma control for consistency
+			fsaa_text->setColor(gamma_ctrl->getEnabledTextColor());
+
+			fsaa_restart->setVisible(!gSavedSettings.getBOOL("RenderDeferred"));
+		}
+		else
+		{
+			fsaa_ctrl->setEnabled(FALSE);
+			fsaa_ctrl->setValue((LLSD::Integer) 0);
+			
+			// borrow the text color from the gamma control for consistency
+			fsaa_text->setColor(gamma_ctrl->getDisabledTextColor());
+			
+			fsaa_restart->setVisible(FALSE);
+		}
 	}
-	*/
 }
 
 //============================================================================
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index c9e1b44b3ff..230bf0e9fdf 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1165,7 +1165,9 @@ BOOL LLPipeline::canUseWindLightShadersOnObjects() const
 
 BOOL LLPipeline::canUseAntiAliasing() const
 {
-	return TRUE;
+	// We can use anti-aliasing if the GL manager can support some multisampling
+	BOOL can_fsaa = (gGLManager.getNumFBOFSAASamples(2) > 1);
+	return can_fsaa;
 }
 
 void LLPipeline::unloadShaders()
diff --git a/indra/newview/skins/default/xui/en/floater_hardware_settings.xml b/indra/newview/skins/default/xui/en/floater_hardware_settings.xml
index 05f4c52b950..66bb9d3cea8 100644
--- a/indra/newview/skins/default/xui/en/floater_hardware_settings.xml
+++ b/indra/newview/skins/default/xui/en/floater_hardware_settings.xml
@@ -35,7 +35,7 @@
      height="12"
      layout="topleft"
      left="10"
-     name="Antialiasing:"
+     name="antialiasing label"
      top_pad="7"
      width="188">
         Antialiasing:
-- 
GitLab