From b3ef02541253daf23dfc6aff70f831e91c4371e9 Mon Sep 17 00:00:00 2001
From: andreykproductengine <akleshchev@productengine.com>
Date: Thu, 17 Sep 2015 15:33:04 +0300
Subject: [PATCH] MAINT-5570 [QuickGraphics] Visual complexity notifications
 are confusing.

---
 indra/newview/llattachmentsmgr.h         |  5 ++
 indra/newview/llavatarrendernotifier.cpp | 61 +++++++++++++++++-------
 indra/newview/llavatarrendernotifier.h   |  2 +-
 indra/newview/llvoavatar.cpp             | 11 +++++
 4 files changed, 61 insertions(+), 18 deletions(-)

diff --git a/indra/newview/llattachmentsmgr.h b/indra/newview/llattachmentsmgr.h
index d56d6eb27bc..fab146cb525 100755
--- a/indra/newview/llattachmentsmgr.h
+++ b/indra/newview/llattachmentsmgr.h
@@ -87,6 +87,11 @@ class LLAttachmentsMgr: public LLSingleton<LLAttachmentsMgr>
     void onDetachRequested(const LLUUID& inv_item_id);
     void onDetachCompleted(const LLUUID& inv_item_id);
 
+    bool hasPendingAttachments() { return mPendingAttachments.size() > 0; }
+    bool hasAttachmentRequests() { return mAttachmentRequests.size() > 0; }
+    bool hasDetachRequests() { return mAttachmentRequests.size() > 0; }
+    bool hasRecentlyArrivedAttachments() { return mRecentlyArrivedAttachments.size() > 0; }
+
 private:
 
     class LLItemRequestTimes: public std::map<LLUUID,LLTimer>
diff --git a/indra/newview/llavatarrendernotifier.cpp b/indra/newview/llavatarrendernotifier.cpp
index 4ac36ec0186..04689d27265 100644
--- a/indra/newview/llavatarrendernotifier.cpp
+++ b/indra/newview/llavatarrendernotifier.cpp
@@ -32,8 +32,9 @@
 // std headers
 // external library headers
 // other Linden headers
-#include "llagent.h"
 #include "llagentwearables.h"
+#include "llappearancemgr.h"
+#include "llattachmentsmgr.h"
 #include "llnotifications.h"
 #include "llnotificationsutil.h"
 #include "llnotificationtemplate.h"
@@ -62,6 +63,7 @@ mLatestOverLimitPct(0.0f),
 mShowOverLimitAgents(false),
 mNotifyOutfitLoading(false)
 {
+    mPopUpDelayTimer.resetWithExpiry(OVER_LIMIT_UPDATE_DELAY);
 }
 
 std::string LLAvatarRenderNotifier::overLimitMessage()
@@ -97,9 +99,10 @@ std::string LLAvatarRenderNotifier::overLimitMessage()
     return LLTrans::getString(message);
 }
 
-void LLAvatarRenderNotifier::displayNotification()
+void LLAvatarRenderNotifier::displayNotification(bool show_over_limit)
 {
     mAgentComplexity = mLatestAgentComplexity;
+    mShowOverLimitAgents = show_over_limit;
 	static LLCachedControl<U32> expire_delay(gSavedSettings, "ShowMyComplexityChanges", 20);
 
 	LLDate expire_date(LLDate::now().secondsSinceEpoch() + expire_delay);
@@ -157,7 +160,7 @@ void LLAvatarRenderNotifier::updateNotificationRegion(U32 agentcount, U32 overLi
     if (mAgentsCount == mLatestAgentsCount
         && mOverLimitAgents == mLatestOverLimitAgents)
     {
-        //no changes since last notification
+        // no changes since last notification
         return;
     }
 
@@ -167,9 +170,7 @@ void LLAvatarRenderNotifier::updateNotificationRegion(U32 agentcount, U32 overLi
         )
     {
         // display in case of drop to/from zero and in case of significant (RENDER_ALLOWED_CHANGE_PCT) changes
-
-        mShowOverLimitAgents = true;
-        displayNotification();
+        displayNotification(true);
 
         // default timeout before next notification
         static LLCachedControl<U32> pop_up_delay(gSavedSettings, "ComplexityChangesPopUpDelay", 300);
@@ -191,24 +192,51 @@ void LLAvatarRenderNotifier::updateNotificationAgent(U32 agentComplexity)
     if (!mNotifyOutfitLoading)
     {
         // We should not notify about initial outfit and it's load process without reason
-        if (isAgentAvatarValid()
-            && gAgent.isInitialized()
-            && gAgent.isOutfitChosen()
+
+        if (!isAgentAvatarValid())
+        {
+            return;
+        }
+
+        static S32 initial_cof_version(-1);
+        static S32 rez_status(0);
+
+        if (initial_cof_version < 0
             && gAgentWearables.areWearablesLoaded()
-            && gAgentAvatarp->isFullyLoaded())
+            && !LLAttachmentsMgr::getInstance()->hasPendingAttachments()
+            && !LLAttachmentsMgr::getInstance()->hasAttachmentRequests()
+            && !LLAttachmentsMgr::getInstance()->hasRecentlyArrivedAttachments())
         {
-            // Initial outfit was fully loaded
+            // cof formed
+            initial_cof_version = LLAppearanceMgr::instance().getCOFVersion();
+
+            // outfit might have been pre-loaded in one go, we are adding/removing items in such case
+            mNotifyOutfitLoading = gAgentAvatarp->isAllLocalTextureDataFinal();
+        }
+
+        if (initial_cof_version >= 0 && initial_cof_version != gAgentAvatarp->mLastUpdateRequestCOFVersion)
+        {
+            // version mismatch in comparison to initial outfit - outfit changed
             mNotifyOutfitLoading = true;
         }
-        else if (mLatestOverLimitAgents > 0
-            || mAgentComplexity > mLatestAgentComplexity)
+        else if (mLatestOverLimitAgents > 0)
         {
-            // Some users can't see agent already or user switched outfits,
-            // this is a reason to show load process
+            // Some users can't see agent already, notify user about complexity growth
             mNotifyOutfitLoading = true;
         }
+        else if (gAgentAvatarp->mLastRezzedStatus >= rez_status)
+        {
+            rez_status = gAgentAvatarp->mLastRezzedStatus;
+        }
         else
         {
+            // rez status decreased - outfit related action was initiated
+            mNotifyOutfitLoading = true;
+        }
+
+        if (!mNotifyOutfitLoading)
+        {
+            // avatar or outfit not ready
             mAgentComplexity = mLatestAgentComplexity;
             return;
         }
@@ -217,8 +245,7 @@ void LLAvatarRenderNotifier::updateNotificationAgent(U32 agentComplexity)
     if (mAgentComplexity != mLatestAgentComplexity)
     {
         // if we have an agent complexity change, we always display it and hide 'over limit'
-        mShowOverLimitAgents = false;
-        displayNotification();
+        displayNotification(false);
 
         // next 'over limit' update should be displayed after delay to make sure information got updated at server side
         mPopUpDelayTimer.resetWithExpiry(OVER_LIMIT_UPDATE_DELAY);
diff --git a/indra/newview/llavatarrendernotifier.h b/indra/newview/llavatarrendernotifier.h
index 509bc64b20e..2949af2c01b 100644
--- a/indra/newview/llavatarrendernotifier.h
+++ b/indra/newview/llavatarrendernotifier.h
@@ -40,7 +40,7 @@ class LLAvatarRenderNotifier : public LLSingleton<LLAvatarRenderNotifier>
 public:
 	LLAvatarRenderNotifier();
 
-	void displayNotification();
+    void displayNotification(bool show_over_limit);
 	bool isNotificationVisible();
 
 	void updateNotificationRegion(U32 agentcount, U32 overLimit);
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index edb447e4973..60fd98b3d7c 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -6457,6 +6457,17 @@ BOOL LLVOAvatar::processFullyLoadedChange(bool loading)
 	mPreviousFullyLoaded = mFullyLoaded;
 	mFullyLoadedInitialized = TRUE;
 	mFullyLoadedFrameCounter++;
+
+    if (changed)
+    {
+        static LLCachedControl<U32> show_my_complexity_changes(gSavedSettings, "ShowMyComplexityChanges", 20);
+
+        if (isSelf() && show_my_complexity_changes)
+        {
+            // to know about outfit switching
+            LLAvatarRenderNotifier::getInstance()->updateNotificationAgent(mVisualComplexity);
+        }
+    }
 	
 	return changed;
 }
-- 
GitLab