From c5fc8f90060aa7a6c8fbb72313172423b01eddc5 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 19 Jun 2013 08:23:53 -0700
Subject: [PATCH] SH-4246 FIX interesting: fast timers significantly decreases
 framerate moved collapsed flag to fast timer tree node

---
 indra/llcommon/llfasttimer.cpp    |  8 +++-----
 indra/llcommon/llfasttimer.h      |  5 +----
 indra/llcommon/lltrace.cpp        |  3 ++-
 indra/llcommon/lltrace.h          |  1 +
 indra/newview/llappviewer.cpp     |  2 +-
 indra/newview/lldrawable.cpp      |  2 +-
 indra/newview/llfasttimerview.cpp | 28 ++++++++++++++--------------
 indra/newview/llviewerdisplay.cpp |  2 +-
 8 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp
index 4da9c3fd6cb..becfa9c288f 100755
--- a/indra/llcommon/llfasttimer.cpp
+++ b/indra/llcommon/llfasttimer.cpp
@@ -118,7 +118,7 @@ struct SortTimerByName
 
 TimeBlock& TimeBlock::getRootTimeBlock()
 	{
-	static TimeBlock root_timer("root", true, NULL);
+	static TimeBlock root_timer("root", NULL);
 	return root_timer;
 	}
 
@@ -164,11 +164,9 @@ U64 TimeBlock::countsPerSecond()
 }
 #endif
 
-TimeBlock::TimeBlock(const char* name, bool open, TimeBlock* parent)
-:	TraceType<TimeBlockAccumulator>(name),
-	mCollapsed(true)
+TimeBlock::TimeBlock(const char* name, TimeBlock* parent)
+:	TraceType<TimeBlockAccumulator>(name)
 {
-	setCollapsed(!open);
 }
 
 TimeBlockTreeNode& TimeBlock::getTreeNode() const
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index e800befd9fb..642c99ccce1 100755
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -86,7 +86,7 @@ class TimeBlock
 	public LLInstanceTracker<TimeBlock>
 {
 public:
-	TimeBlock(const char* name, bool open = false, TimeBlock* parent = &getRootTimeBlock());
+	TimeBlock(const char* name, TimeBlock* parent = &getRootTimeBlock());
 
 	TimeBlockTreeNode& getTreeNode() const;
 	TimeBlock* getParent() const { return getTreeNode().getParent(); }
@@ -98,9 +98,6 @@ class TimeBlock
 	child_iter endChildren();
 	std::vector<TimeBlock*>& getChildren();
 
-	void setCollapsed(bool collapsed)	{ mCollapsed = collapsed; }
-	bool getCollapsed() const			{ return mCollapsed; }
-
 	TraceType<TimeBlockAccumulator::CallCountFacet>& callCount() 
 	{
 		return static_cast<TraceType<TimeBlockAccumulator::CallCountFacet>&>(*(TraceType<TimeBlockAccumulator>*)this);
diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp
index c831a1548d1..59a4b42c971 100644
--- a/indra/llcommon/lltrace.cpp
+++ b/indra/llcommon/lltrace.cpp
@@ -85,7 +85,8 @@ void set_thread_recorder(ThreadRecorder* recorder)
 TimeBlockTreeNode::TimeBlockTreeNode() 
 :	mBlock(NULL),
 	mParent(NULL),
-	mNeedsSorting(false)
+	mNeedsSorting(false),
+	mCollapsed(true)
 {}
 
 void TimeBlockTreeNode::setParent( TimeBlock* parent )
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index 6292534a03b..fb7ffb0a29f 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -663,6 +663,7 @@ class TimeBlockTreeNode
 	TimeBlock*					mBlock;
 	TimeBlock*					mParent;	
 	std::vector<TimeBlock*>		mChildren;
+	bool						mCollapsed;
 	bool						mNeedsSorting;
 };
 
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index ef24ba21eea..8c51bd4198d 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1248,7 +1248,7 @@ static LLFastTimer::DeclareTimer FTM_SERVICE_CALLBACK("Callback");
 static LLFastTimer::DeclareTimer FTM_AGENT_AUTOPILOT("Autopilot");
 static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE("Update");
 
-LLFastTimer::DeclareTimer FTM_FRAME("Frame", true);
+LLFastTimer::DeclareTimer FTM_FRAME("Frame");
 
 bool LLAppViewer::mainLoop()
 {
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 22a7c350d67..8430c325512 100755
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -300,7 +300,7 @@ S32 LLDrawable::findReferences(LLDrawable *drawablep)
 	return count;
 }
 
-static LLFastTimer::DeclareTimer FTM_ALLOCATE_FACE("Allocate Face", true);
+static LLFastTimer::DeclareTimer FTM_ALLOCATE_FACE("Allocate Face");
 
 LLFace*	LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep)
 {
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 1355b58f8bd..ec307b841e2 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -152,13 +152,13 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask)
 	if (mHoverTimer )
 	{
 		// right click collapses timers
-		if (!mHoverTimer->getCollapsed())
+		if (!mHoverTimer->getTreeNode().mCollapsed)
 		{
-			mHoverTimer->setCollapsed(true);
+			mHoverTimer->getTreeNode().mCollapsed = true;
 		}
 		else if (mHoverTimer->getParent())
 		{
-			mHoverTimer->getParent()->setCollapsed(true);
+			mHoverTimer->getParent()->getTreeNode().mCollapsed = true;
 		}
 		return TRUE;
 	}
@@ -190,7 +190,7 @@ BOOL LLFastTimerView::handleDoubleClick(S32 x, S32 y, MASK mask)
 		it != end_timer_tree();
 		++it)
 	{
-		(*it)->setCollapsed(false);
+		(*it)->getTreeNode().mCollapsed = false;
 	}
 	return TRUE;
 }
@@ -202,13 +202,13 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask)
 		TimeBlock* idp = getLegendID(y);
 		if (idp)
 		{
-			idp->setCollapsed(!idp->getCollapsed());
+			idp->getTreeNode().mCollapsed = !idp->getTreeNode().mCollapsed;
 		}
 	}
 	else if (mHoverTimer)
 	{
 		//left click drills down by expanding timers
-		mHoverTimer->setCollapsed(false);
+		mHoverTimer->getTreeNode().mCollapsed = false;
 	}
 	else if (mGraphRect.pointInRect(x, y))
 	{
@@ -273,7 +273,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 			if (bar.mSelfEnd > mouse_time_offset)
 			{
 				hover_bar = &bar;
-				if (bar.mTimeBlock->getCollapsed())
+				if (bar.mTimeBlock->getTreeNode().mCollapsed)
 				{
 					// stop on first collapsed timeblock, since we can't select any children
 					break;
@@ -373,7 +373,7 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 	return TRUE;
 }
 
-static TimeBlock FTM_RENDER_TIMER("Timers", true);
+static TimeBlock FTM_RENDER_TIMER("Timers");
 static const S32 MARGIN = 10;
 static const S32 LEGEND_WIDTH = 220;
 
@@ -975,7 +975,7 @@ void LLFastTimerView::printLineStats()
 			first = false;
 			legend_stat += idp->getName();
 
-			if (idp->getCollapsed())
+			if (idp->getTreeNode().mCollapsed)
 			{
 				it.skipDescendants();
 			}
@@ -1009,7 +1009,7 @@ void LLFastTimerView::printLineStats()
 
 			timer_stat += llformat("%.1f",ms.value());
 
-			if (idp->getCollapsed())
+			if (idp->getTreeNode().mCollapsed)
 			{
 				it.skipDescendants();
 			}
@@ -1135,7 +1135,7 @@ void LLFastTimerView::drawLineGraph()
 			glLineWidth(1);
 		}
 
-		if (idp->getCollapsed())
+		if (idp->getTreeNode().mCollapsed)
 		{	
 			//skip hidden timers
 			it.skipDescendants();
@@ -1267,7 +1267,7 @@ void LLFastTimerView::drawLegend()
 				gl_line_2d(x + dx - 8, line_start_y, x + dx, line_start_y, color);
 				S32 line_x = x + (TEXT_HEIGHT + 4) + ((get_depth(idp) - 1) * 8);
 				gl_line_2d(line_x, line_start_y, line_x, line_end_y, color);
-				if (idp->getCollapsed() && !idp->getChildren().empty())
+				if (idp->getTreeNode().mCollapsed && !idp->getChildren().empty())
 				{
 					gl_line_2d(line_x+4, line_start_y-3, line_x+4, line_start_y+4, color);
 				}
@@ -1291,7 +1291,7 @@ void LLFastTimerView::drawLegend()
 
 			y -= (TEXT_HEIGHT + 2);
 
-			if (idp->getCollapsed()) 
+			if (idp->getTreeNode().mCollapsed) 
 			{
 				it.skipDescendants();
 			}
@@ -1645,7 +1645,7 @@ S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width,
 		children_rect.mBottom = bar_rect.mBottom;
 	}
 
-	bool children_visible = visible && !time_block->getCollapsed();
+	bool children_visible = visible && !time_block->getTreeNode().mCollapsed;
 
 	bar_index++;
 	const U32 num_bars = LLInstanceTracker<LLTrace::TimeBlock>::instanceCount();
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 7ad4743d82b..bd85056d701 100755
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -210,7 +210,7 @@ void display_stats()
 }
 
 static LLFastTimer::DeclareTimer FTM_PICK("Picking");
-static LLFastTimer::DeclareTimer FTM_RENDER("Render", true);
+static LLFastTimer::DeclareTimer FTM_RENDER("Render");
 static LLFastTimer::DeclareTimer FTM_UPDATE_SKY("Update Sky");
 static LLFastTimer::DeclareTimer FTM_UPDATE_TEXTURES("Update Textures");
 static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE("Update Images");
-- 
GitLab