From aa96a6a4e8ebd86b8dc8da530b79f6cbb0365b04 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 10 Jun 2010 12:51:25 -0600
Subject: EXT-7760: FIXED:  only 10 avatars render non-impostored

---
 indra/newview/app_settings/settings.xml            |  2 +-
 indra/newview/featuretable.txt                     |  2 +-
 indra/newview/featuretable_linux.txt               |  2 +-
 indra/newview/featuretable_mac.txt                 |  2 +-
 indra/newview/llappviewer.cpp                      |  2 +-
 indra/newview/llviewerdisplay.cpp                  |  2 +-
 indra/newview/llvoavatar.cpp                       | 16 ++++++++--------
 indra/newview/llvoavatar.h                         |  4 ++--
 .../default/xui/en/panel_preferences_graphics1.xml | 22 +++++-----------------
 9 files changed, 21 insertions(+), 33 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index b0211dd85b..d94814d781 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6202,7 +6202,7 @@
       <key>Type</key>
       <string>S32</string>
       <key>Value</key>
-      <integer>35</integer>
+      <integer>12</integer>
     </map>
     <key>RenderAvatarVP</key>
     <map>
diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt
index de4d787d65..e8591ca086 100644
--- a/indra/newview/featuretable.txt
+++ b/indra/newview/featuretable.txt
@@ -26,7 +26,7 @@ list all
 RenderAnisotropic			1	0
 RenderAvatarCloth			1	1
 RenderAvatarLODFactor		1	1.0
-RenderAvatarMaxVisible      1   35
+RenderAvatarMaxVisible      1   12
 RenderAvatarVP				1	1
 RenderCubeMap				1	1
 RenderDelayVBUpdate			1	0
diff --git a/indra/newview/featuretable_linux.txt b/indra/newview/featuretable_linux.txt
index adda7cec4d..779490c9f7 100644
--- a/indra/newview/featuretable_linux.txt
+++ b/indra/newview/featuretable_linux.txt
@@ -26,7 +26,7 @@ list all
 RenderAnisotropic			1	0
 RenderAvatarCloth			1	1
 RenderAvatarLODFactor		1	1.0
-RenderAvatarMaxVisible      1   35
+RenderAvatarMaxVisible      1   12
 RenderAvatarVP				1	1
 RenderCubeMap				1	1
 RenderDelayVBUpdate			1	0
diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt
index 82886d7e2c..47033efc47 100644
--- a/indra/newview/featuretable_mac.txt
+++ b/indra/newview/featuretable_mac.txt
@@ -26,7 +26,7 @@ list all
 RenderAnisotropic				1	0
 RenderAvatarCloth				0	0
 RenderAvatarLODFactor			1	1.0
-RenderAvatarMaxVisible          1   35
+RenderAvatarMaxVisible          1   12
 RenderAvatarVP					1	0
 RenderCubeMap					1	1
 RenderDelayVBUpdate				1	0
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 95084666bb..7f0186575d 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -416,7 +416,7 @@ static void settings_to_globals()
 	LLVolumeImplFlexible::sUpdateFactor = gSavedSettings.getF32("RenderFlexTimeFactor");
 	LLVOTree::sTreeFactor				= gSavedSettings.getF32("RenderTreeLODFactor");
 	LLVOAvatar::sLODFactor				= gSavedSettings.getF32("RenderAvatarLODFactor");
-	LLVOAvatar::sMaxVisible				= gSavedSettings.getS32("RenderAvatarMaxVisible");
+	LLVOAvatar::sMaxVisible				= (U32)gSavedSettings.getS32("RenderAvatarMaxVisible");
 	LLVOAvatar::sVisibleInFirstPerson	= gSavedSettings.getBOOL("FirstPersonAvatarVisible");
 	// clamp auto-open time to some minimum usable value
 	LLFolderView::sAutoOpenTime			= llmax(0.25f, gSavedSettings.getF32("FolderAutoOpenDelay"));
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 3482ac508e..f7cde9a6cb 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -597,7 +597,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 
 		LLPipeline::sFastAlpha = gSavedSettings.getBOOL("RenderFastAlpha");
 		LLPipeline::sUseFarClip = gSavedSettings.getBOOL("RenderUseFarClip");
-		LLVOAvatar::sMaxVisible = gSavedSettings.getS32("RenderAvatarMaxVisible");
+		LLVOAvatar::sMaxVisible = (U32)gSavedSettings.getS32("RenderAvatarMaxVisible");
 		LLPipeline::sDelayVBUpdate = gSavedSettings.getBOOL("RenderDelayVBUpdate");
 
 		S32 occlusion = LLPipeline::sUseOcclusion;
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 3e93dc1a90..411809d4ba 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -595,7 +595,7 @@ LLVOAvatarSkeletonInfo* LLVOAvatar::sAvatarSkeletonInfo = NULL;
 LLVOAvatar::LLVOAvatarXmlInfo* LLVOAvatar::sAvatarXmlInfo = NULL;
 LLVOAvatarDictionary *LLVOAvatar::sAvatarDictionary = NULL;
 S32 LLVOAvatar::sFreezeCounter = 0;
-S32 LLVOAvatar::sMaxVisible = 50;
+U32 LLVOAvatar::sMaxVisible = 12;
 F32 LLVOAvatar::sRenderDistance = 256.f;
 S32	LLVOAvatar::sNumVisibleAvatars = 0;
 S32	LLVOAvatar::sNumLODChangesThisFrame = 0;
@@ -3173,23 +3173,23 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
 		{ // muted avatars update at 16 hz
 			mUpdatePeriod = 16;
 		}
-		else if (visible && mVisibilityRank <= LLVOAvatar::sMaxVisible * 0.25f)
+		else if (visible && mVisibilityRank <= LLVOAvatar::sMaxVisible)
 		{ //first 25% of max visible avatars are not impostored
 			mUpdatePeriod = 1;
 		}
-		else if (visible && mVisibilityRank > LLVOAvatar::sMaxVisible * 0.75f)
-		{ //back 25% of max visible avatars are slow updating impostors
-			mUpdatePeriod = 8;
-		}
-		else if (visible && mVisibilityRank > (U32) LLVOAvatar::sMaxVisible)
+		else if (visible && mVisibilityRank > LLVOAvatar::sMaxVisible * 4)
 		{ //background avatars are REALLY slow updating impostors
 			mUpdatePeriod = 16;
 		}
+		else if (visible && mVisibilityRank > LLVOAvatar::sMaxVisible * 3)
+		{ //back 25% of max visible avatars are slow updating impostors
+			mUpdatePeriod = 8;
+		}		
 		else if (visible && mImpostorPixelArea <= impostor_area)
 		{  // stuff in between gets an update period based on pixel area
 			mUpdatePeriod = llclamp((S32) sqrtf(impostor_area*4.f/mImpostorPixelArea), 2, 8);
 		}
-		else if (visible && mVisibilityRank > LLVOAvatar::sMaxVisible * 0.25f)
+		else if (visible && mVisibilityRank > LLVOAvatar::sMaxVisible)
 		{ // force nearby impostors in ultra crowded areas
 			mUpdatePeriod = 2;
 		}
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index b30cce09f6..4259bb8e73 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -223,8 +223,8 @@ public:
 public:
 	static S32		sRenderName;
 	static BOOL		sRenderGroupTitles;
-	static S32		sMaxVisible;
-	static F32		sRenderDistance; //distance at which avatars will render (affected by control "RenderAvatarMaxVisible")
+	static U32		sMaxVisible; //(affected by control "RenderAvatarMaxVisible")
+	static F32		sRenderDistance; //distance at which avatars will render.
 	static BOOL		sShowAnimationDebug; // show animation debug info
 	static BOOL		sUseImpostors; //use impostors for far away avatars
 	static BOOL		sShowFootPlane;	// show foot collision plane reported by server
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index 266fd6cb5e..ccd99c6fb5 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -372,30 +372,18 @@
     decimal_digits="0"
     follows="left|top"
     height="16"
-    increment="2"
-    initial_value="35"
-    label="Max. avatar draw distance:"
+    increment="1"
+    initial_value="12"
+    label="Max. # of non-impostor avatars:"
     label_width="185"
     layout="topleft"
     left_delta="0"
     max_val="65"
     min_val="1"
-    name="MaxAvatarDrawDistance"
+    name="MaxNumberAvatarDrawn"
     top_pad="4"
     width="290" />
-    <text
-    type="string"
-    length="1"
-    follows="left|top"
-    height="12"
-    layout="topleft"
-    left_delta="291"
-    name="DrawDistanceMeterText3"
-    top_delta="0"
-    width="128">
-      m
-    </text>
-		<slider
+    <slider
 		control_name="RenderGlowResolutionPow"
 		decimal_digits="0"
 		follows="left|top"
-- 
cgit v1.2.3


From 8108de817c32e3e4f7337b76534987c3be54bedc Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 16 Jun 2010 11:42:05 -0600
Subject: EXT-6567: POSSIBLE FIXED: crash at LLImageBase::allocateData
 [secondlife-bin llimage.cpp:170]; also removed the debug code for this bug.

---
 indra/llimage/llimage.cpp        |  8 ++------
 indra/newview/lltexturefetch.cpp | 11 +++++++++--
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index aa7c8c789a..0fc5ca1ad6 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -168,8 +168,8 @@ U8* LLImageBase::allocateData(S32 size)
 		}
 		else
 		{
-		llerrs << "LLImageBase::allocateData: bad size: " << size << llendl;
-	}
+			llerrs << "LLImageBase::allocateData: bad size: " << size << llendl;
+		}
 	}
 	if (!mData || size != mDataSize)
 	{
@@ -267,10 +267,6 @@ LLImageRaw::LLImageRaw(U16 width, U16 height, S8 components)
 {
 	mMemType = LLMemType::MTYPE_IMAGERAW;
 	//llassert( S32(width) * S32(height) * S32(components) <= MAX_IMAGE_DATA_SIZE );
-	if(S32(width) * S32(height) * S32(components) > MAX_IMAGE_DATA_SIZE)
-	{
-		llwarns << "over size: width: " << (S32)width << " height: " << (S32)height << " components: " << (S32)components << llendl ;
-	}
 	allocateDataSize(width, height, components);
 	++sRawImageCount;
 }
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 52d227f827..ffd0330ace 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -582,14 +582,21 @@ bool LLTextureFetchWorker::doWork(S32 param)
 {
 	LLMutexLock lock(&mWorkMutex);
 
-	if ((mFetcher->isQuitting() || mImagePriority < 1.0f || getFlags(LLWorkerClass::WCF_DELETE_REQUESTED)))
+	if ((mFetcher->isQuitting() || getFlags(LLWorkerClass::WCF_DELETE_REQUESTED)))
 	{
 		if (mState < DECODE_IMAGE)
 		{
 			return true; // abort
 		}
 	}
-	
+	if(mImagePriority < 1.0f)
+	{
+		if (mState == INIT || mState == LOAD_FROM_NETWORK || mState == LOAD_FROM_SIMULATOR)
+		{
+			return true; // abort
+		}
+	}
+
 	if (mFetcher->mDebugPause)
 	{
 		return false; // debug: don't do any work
-- 
cgit v1.2.3


From 5c7911f1e2cb060e5e2353cec01a7ecc09f05126 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 16 Jun 2010 14:03:56 -0600
Subject: EXT-7032: POSSIBLE FIXED: [crashhunters] crash in libcurl background
 thread on windows

---
 indra/newview/lltexturefetch.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index ffd0330ace..ceed90e210 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -596,6 +596,11 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			return true; // abort
 		}
 	}
+	if(mState > CACHE_POST && !mCanUseNET && !mCanUseHTTP)
+	{
+		//nowhere to get data, abort.
+		return true ;
+	}
 
 	if (mFetcher->mDebugPause)
 	{
@@ -784,7 +789,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			}
 			// don't return, fall through to next state
 		}
-		else if (mSentRequest == UNSENT)
+		else if (mSentRequest == UNSENT && mCanUseNET)
 		{
 			// Add this to the network queue and sit here.
 			// LLTextureFetch::update() will send off a request which will change our state
@@ -837,6 +842,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 	
 	if (mState == SEND_HTTP_REQ)
 	{
+		if(mCanUseHTTP)
 		{
 			const S32 HTTP_QUEUE_MAX_SIZE = 8;
 			// *TODO: Integrate this with llviewerthrottle
@@ -902,6 +908,10 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			}
 			// fall through
 		}
+		else //can not use http fetch.
+		{
+			return true ; //abort
+		}
 	}
 	
 	if (mState == WAIT_HTTP_REQ)
-- 
cgit v1.2.3