From 7b4d27ecbcb5ac702459be97cbf6b81354850658 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 14 Mar 2013 19:36:50 -0700
Subject: [PATCH] SH-3931 WIP Interesting: Add graphs to visualize scene load
 metrics collapsed Orientation enums to all use LLView::EOrientation added
 ability to display stat bar horizontally

---
 indra/llcommon/lltracerecording.cpp           |   2 +-
 indra/llcommon/lltracerecording.h             |  16 +-
 indra/llui/lllayoutstack.cpp                  |   8 +-
 indra/llui/lllayoutstack.h                    |  19 +-
 indra/llui/llscrollbar.h                      |   6 +-
 indra/llui/llscrollcontainer.cpp              |   4 +-
 indra/llui/llscrollcontainer.h                |   3 +-
 indra/llui/llslider.h                         |   4 +-
 indra/llui/llstatbar.cpp                      | 187 +++++++++++-------
 indra/llui/llstatbar.h                        |  39 ++--
 indra/llui/llstatgraph.cpp                    |  17 --
 indra/llui/llstatgraph.h                      |   4 +-
 indra/llui/lltoolbar.cpp                      |  10 +-
 indra/llui/lltoolbar.h                        |   2 +-
 indra/llui/llview.cpp                         |  10 +
 indra/llui/llview.h                           |  13 ++
 indra/newview/lltoolbarview.cpp               |   6 +-
 indra/newview/llviewermessage.cpp             |   2 +-
 .../skins/default/xui/en/floater_stats.xml    |   1 +
 19 files changed, 197 insertions(+), 156 deletions(-)

diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp
index ef0a633c9ce..6695ebeacae 100644
--- a/indra/llcommon/lltracerecording.cpp
+++ b/indra/llcommon/lltracerecording.cpp
@@ -547,7 +547,7 @@ void ExtendableRecording::splitFrom(ExtendableRecording& other)
 
 PeriodicRecording& get_frame_recording()
 {
-	static LLThreadLocalPointer<PeriodicRecording> sRecording(new PeriodicRecording(200, PeriodicRecording::STARTED));
+	static LLThreadLocalPointer<PeriodicRecording> sRecording(new PeriodicRecording(1000, PeriodicRecording::STARTED));
 	return *sRecording;
 }
 
diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h
index a5edcb857a3..70afe51d6e9 100644
--- a/indra/llcommon/lltracerecording.h
+++ b/indra/llcommon/lltracerecording.h
@@ -100,15 +100,10 @@ class LLStopWatchControlsMixin
 
 namespace LLTrace
 {
-	struct RecordingBuffers
+	class RecordingBuffers
 	{
+	public:
 		RecordingBuffers();
-		LLCopyOnWritePointer<AccumulatorBuffer<CountAccumulator<F64> > >		mCountsFloat;
-		LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F64> > >	mMeasurementsFloat;
-		LLCopyOnWritePointer<AccumulatorBuffer<CountAccumulator<S64> > >		mCounts;
-		LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<S64> > >	mMeasurements;
-		LLCopyOnWritePointer<AccumulatorBuffer<TimeBlockAccumulator> >			mStackTimers;
-		LLCopyOnWritePointer<AccumulatorBuffer<MemStatAccumulator> >			mMemStats;
 
 		void handOffTo(RecordingBuffers& other);
 		void makePrimary();
@@ -120,6 +115,13 @@ namespace LLTrace
 		void mergeBuffers(const RecordingBuffers& other);
 		void resetBuffers(RecordingBuffers* other = NULL);
 
+	protected:
+		LLCopyOnWritePointer<AccumulatorBuffer<CountAccumulator<F64> > >		mCountsFloat;
+		LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F64> > >	mMeasurementsFloat;
+		LLCopyOnWritePointer<AccumulatorBuffer<CountAccumulator<S64> > >		mCounts;
+		LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<S64> > >	mMeasurements;
+		LLCopyOnWritePointer<AccumulatorBuffer<TimeBlockAccumulator> >			mStackTimers;
+		LLCopyOnWritePointer<AccumulatorBuffer<MemStatAccumulator> >			mMemStats;
 	};
 
 	class Recording : public LLStopWatchControlsMixin<Recording>, public RecordingBuffers
diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp
index 4c730286da8..194d2b700cc 100644
--- a/indra/llui/lllayoutstack.cpp
+++ b/indra/llui/lllayoutstack.cpp
@@ -42,12 +42,6 @@ static const F32 MAX_FRACTIONAL_SIZE = 1.f;
 static LLDefaultChildRegistry::Register<LLLayoutStack> register_layout_stack("layout_stack");
 static LLLayoutStack::LayoutStackRegistry::Register<LLLayoutPanel> register_layout_panel("layout_panel");
 
-void LLLayoutStack::OrientationNames::declareValues()
-{
-	declare("horizontal", HORIZONTAL);
-	declare("vertical", VERTICAL);
-}
-
 //
 // LLLayoutPanel
 //
@@ -141,7 +135,7 @@ S32 LLLayoutPanel::getVisibleDim() const
 						+ (((F32)mTargetDim - min_dim) * (1.f - mCollapseAmt))));
 }
  
-void LLLayoutPanel::setOrientation( LLLayoutStack::ELayoutOrientation orientation )
+void LLLayoutPanel::setOrientation( LLView::EOrientation orientation )
 {
 	mOrientation = orientation;
 	S32 layout_dim = llround((F32)((mOrientation == LLLayoutStack::HORIZONTAL)
diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h
index 648cd5fdce2..f1668d7473b 100644
--- a/indra/llui/lllayoutstack.h
+++ b/indra/llui/lllayoutstack.h
@@ -37,24 +37,13 @@ class LLLayoutPanel;
 class LLLayoutStack : public LLView, public LLInstanceTracker<LLLayoutStack>
 {
 public:
-	typedef enum e_layout_orientation
-	{
-		HORIZONTAL,
-		VERTICAL
-	} ELayoutOrientation;
-
-	struct OrientationNames
-	:	public LLInitParam::TypeValuesHelper<ELayoutOrientation, OrientationNames>
-	{
-		static void declareValues();
-	};
 
 	struct LayoutStackRegistry : public LLChildRegistry<LayoutStackRegistry>
 	{};
 
 	struct Params : public LLInitParam::Block<Params, LLView::Params>
 	{
-		Mandatory<ELayoutOrientation, OrientationNames>	orientation;
+		Mandatory<EOrientation>	orientation;
 		Optional<S32>			border_size;
 		Optional<bool>			animate,
 								clip;
@@ -104,7 +93,7 @@ class LLLayoutStack : public LLView, public LLInstanceTracker<LLLayoutStack>
 	bool animatePanels();
 	void createResizeBar(LLLayoutPanel* panel);
 
-	const ELayoutOrientation mOrientation;
+	const EOrientation mOrientation;
 
 	typedef std::vector<LLLayoutPanel*> e_panel_list_t;
 	e_panel_list_t mPanels;
@@ -179,7 +168,7 @@ friend class LLUICtrlFactory;
 	F32 getVisibleAmount() const;
 	S32 getVisibleDim() const;
 
-	void setOrientation(LLLayoutStack::ELayoutOrientation orientation);
+	void setOrientation(LLView::EOrientation orientation);
 	void storeOriginalDim();
 
 	void setIgnoreReshape(bool ignore) { mIgnoreReshape = ignore; }
@@ -198,7 +187,7 @@ friend class LLUICtrlFactory;
 	F32		mFractionalSize;
 	S32		mTargetDim;
 	bool	mIgnoreReshape;
-	LLLayoutStack::ELayoutOrientation mOrientation;
+	LLView::EOrientation mOrientation;
 	class LLResizeBar* mResizeBar;
 };
 
diff --git a/indra/llui/llscrollbar.h b/indra/llui/llscrollbar.h
index ff74f753b9f..3f3ca1378b3 100644
--- a/indra/llui/llscrollbar.h
+++ b/indra/llui/llscrollbar.h
@@ -40,13 +40,11 @@ class LLScrollbar
 {
 public:
 
-	enum ORIENTATION { HORIZONTAL, VERTICAL };
-	
 	typedef boost::function<void (S32, LLScrollbar*)> callback_t;
 	struct Params 
 	:	public LLInitParam::Block<Params, LLUICtrl::Params>
 	{
-		Mandatory<ORIENTATION>			orientation;
+		Mandatory<EOrientation>			orientation;
 		Mandatory<S32>					doc_size;
 		Mandatory<S32>					doc_pos;
 		Mandatory<S32>					page_size;
@@ -131,7 +129,7 @@ class LLScrollbar
 
 	callback_t			mChangeCallback;
 
-	const ORIENTATION	mOrientation;	
+	const EOrientation	mOrientation;	
 	S32					mDocSize;		// Size of the document that the scrollbar is modeling.  Units depend on the user.  0 <= mDocSize.
 	S32					mDocPos;		// Position within the doc that the scrollbar is modeling, in "lines" (user size)
 	S32					mPageSize;		// Maximum number of lines that can be seen at one time.
diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp
index 2fd187a5268..2abfb154948 100644
--- a/indra/llui/llscrollcontainer.cpp
+++ b/indra/llui/llscrollcontainer.cpp
@@ -140,7 +140,7 @@ LLScrollContainer::~LLScrollContainer( void )
 {
 	// mScrolledView and mScrollbar are child views, so the LLView
 	// destructor takes care of memory deallocation.
-	for( S32 i = 0; i < SCROLLBAR_COUNT; i++ )
+	for( S32 i = 0; i < ORIENTATION_COUNT; i++ )
 	{
 		mScrollbar[i] = NULL;
 	}
@@ -211,7 +211,7 @@ BOOL LLScrollContainer::handleKeyHere(KEY key, MASK mask)
 	{
 		return TRUE;
 	}
-	for( S32 i = 0; i < SCROLLBAR_COUNT; i++ )
+	for( S32 i = 0; i < ORIENTATION_COUNT; i++ )
 	{
 		if( mScrollbar[i]->handleKeyHere(key, mask) )
 		{
diff --git a/indra/llui/llscrollcontainer.h b/indra/llui/llscrollcontainer.h
index d87c95b3d75..f9ce4a74ef1 100644
--- a/indra/llui/llscrollcontainer.h
+++ b/indra/llui/llscrollcontainer.h
@@ -56,7 +56,6 @@ class LLScrollContainer : public LLUICtrl
 public:
 	// Note: vertical comes before horizontal because vertical
 	// scrollbars have priority for mouse and keyboard events.
-	enum SCROLL_ORIENTATION { VERTICAL, HORIZONTAL, SCROLLBAR_COUNT };
 
 	struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
 	{
@@ -126,7 +125,7 @@ class LLScrollContainer : public LLUICtrl
 	void updateScroll();
 	void calcVisibleSize( S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const;
 
-	LLScrollbar* mScrollbar[SCROLLBAR_COUNT];
+	LLScrollbar* mScrollbar[ORIENTATION_COUNT];
 	S32			mSize;
 	BOOL		mIsOpaque;
 	LLUIColor	mBackgroundColor;
diff --git a/indra/llui/llslider.h b/indra/llui/llslider.h
index 700c17ea3e9..3b492d81823 100644
--- a/indra/llui/llslider.h
+++ b/indra/llui/llslider.h
@@ -34,8 +34,6 @@
 class LLSlider : public LLF32UICtrl
 {
 public:
-	enum ORIENTATION { HORIZONTAL, VERTICAL };
-
 	struct Params : public LLInitParam::Block<Params, LLF32UICtrl::Params>
 	{
 		Optional<std::string> orientation;
@@ -98,7 +96,7 @@ class LLSlider : public LLF32UICtrl
 	LLPointer<LLUIImage>	mTrackHighlightHorizontalImage;
 	LLPointer<LLUIImage>	mTrackHighlightVerticalImage;
 
-	const ORIENTATION	mOrientation;
+	const EOrientation	mOrientation;
 
 	LLRect		mThumbRect;
 	LLUIColor	mTrackColor;
diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp
index 954f615210a..2bc385061af 100644
--- a/indra/llui/llstatbar.cpp
+++ b/indra/llui/llstatbar.cpp
@@ -57,7 +57,8 @@ LLStatBar::LLStatBar(const Params& p)
 	  mPerSec(p.show_per_sec),
 	  mDisplayBar(p.show_bar),
 	  mDisplayHistory(p.show_history),
-	  mDisplayMean(p.show_mean)
+	  mDisplayMean(p.show_mean),
+	  mOrientation(p.orientation)
 {}
 
 BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask)
@@ -167,15 +168,27 @@ void LLStatBar::draw()
 		mUpdateTimer.reset();
 	}
 
-	S32 width = getRect().getWidth() - 40;
-	S32 max_width = width;
-	S32 bar_top = getRect().getHeight() - 15; // 16 pixels from top.
-	S32 bar_height = bar_top - 20;
-	S32 tick_height = 4;
-	S32 tick_width = 1;
-	S32 left, top, right, bottom;
+	S32 bar_top, bar_left, bar_right, bar_bottom;
+	if (mOrientation == HORIZONTAL)
+	{
+		bar_top = getRect().getHeight() - 15;
+		bar_left = 0;
+		bar_right = getRect().getWidth() - 80;
+		bar_bottom = 0;
+	}
+	else // VERTICAL
+	{
+		bar_top = getRect().getHeight() - 15; // 16 pixels from top.
+		bar_left = 0;
+		bar_right = getRect().getWidth();
+		bar_bottom = 20;
+	}
+	const S32 tick_length = 4;
+	const S32 tick_width = 1;
 
-	F32 value_scale = max_width/(mMaxBar - mMinBar);
+	F32 value_scale = (mOrientation == HORIZONTAL) 
+					? (bar_top - bar_bottom)/(mMaxBar - mMinBar)
+					: (bar_right - bar_left)/(mMaxBar - mMinBar);
 
 	LLFontGL::getFontMonospace()->renderUTF8(mLabel, 0, 0, getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f),
 											 LLFontGL::LEFT, LLFontGL::TOP);
@@ -194,9 +207,16 @@ void LLStatBar::draw()
 	}
 
 	// Draw the value.
-	LLFontGL::getFontMonospace()->renderUTF8(value_str, 0, width, getRect().getHeight(), 
-											 LLColor4(1.f, 1.f, 1.f, 0.5f),
-											 LLFontGL::RIGHT, LLFontGL::TOP);
+	if (mOrientation == HORIZONTAL)
+	{
+
+	}
+	else
+	{
+		LLFontGL::getFontMonospace()->renderUTF8(value_str, 0, bar_right, getRect().getHeight(), 
+			LLColor4(1.f, 1.f, 1.f, 0.5f),
+			LLFontGL::RIGHT, LLFontGL::TOP);
+	}
 
 	value_format = llformat( "%%.%df", mPrecision);
 	if (mDisplayBar && (mCountFloatp || mCountIntp || mMeasurementFloatp || mMeasurementIntp))
@@ -204,64 +224,75 @@ void LLStatBar::draw()
 		std::string tick_label;
 
 		// Draw the tick marks.
-		F32 tick_value;
-		top = bar_top;
-		bottom = bar_top - bar_height - tick_height/2;
-
 		LLGLSUIDefault gls_ui;
 		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 
-		for (tick_value = mMinBar; tick_value <= mMaxBar; tick_value += mTickSpacing)
+		for (F32 tick_value = mMinBar; tick_value <= mMaxBar; tick_value += mTickSpacing)
 		{
-			left = llfloor((tick_value - mMinBar)*value_scale);
-			right = left + tick_width;
-			gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 1.f, 1.f, 0.1f));
+			const S32 begin = llfloor((tick_value - mMinBar)*value_scale);
+			const S32 end = begin + tick_width;
+			if (mOrientation == HORIZONTAL)
+			{
+			}
+			else
+			{
+				gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length/2, LLColor4(1.f, 1.f, 1.f, 0.1f));
+			}
 		}
 
 		// Draw the tick labels (and big ticks).
-		bottom = bar_top - bar_height - tick_height;
-		for (tick_value = mMinBar; tick_value <= mMaxBar; tick_value += mLabelSpacing)
+		for (F32 tick_value = mMinBar; tick_value <= mMaxBar; tick_value += mLabelSpacing)
 		{
-			left = llfloor((tick_value - mMinBar)*value_scale);
-			right = left + tick_width;
-			gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 1.f, 1.f, 0.25f));
-
+			const S32 begin = llfloor((tick_value - mMinBar)*value_scale);
+			const S32 end = begin + tick_width;
 			tick_label = llformat( value_format.c_str(), tick_value);
+
 			// draw labels for the tick marks
-			LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, left - 1, bar_top - bar_height - tick_height,
-													 LLColor4(1.f, 1.f, 1.f, 0.5f),
-													 LLFontGL::LEFT, LLFontGL::TOP);
+			if (mOrientation == HORIZONTAL)
+			{
+			}
+			else
+			{
+				gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length, LLColor4(1.f, 1.f, 1.f, 0.25f));
+				LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, begin - 1, bar_bottom - tick_length,
+					LLColor4(1.f, 1.f, 1.f, 0.5f),
+					LLFontGL::LEFT, LLFontGL::TOP);
+			}
 		}
 
-		// Now, draw the bars
-		top = bar_top;
-		bottom = bar_top - bar_height;
-
 		// draw background bar.
-		left = 0;
-		right = width;
-		gl_rect_2d(left, top, right, bottom, LLColor4(0.f, 0.f, 0.f, 0.25f));
+		gl_rect_2d(bar_left, bar_top, bar_right, bar_bottom, LLColor4(0.f, 0.f, 0.f, 0.25f));
 
 		if (frame_recording.getNumPeriods() == 0)
 		{
 			// No data, don't draw anything...
 			return;
 		}
+
 		// draw min and max
-		left = (S32) ((min - mMinBar) * value_scale);
+		S32 begin = (S32) ((min - mMinBar) * value_scale);
 
-		if (left < 0)
+		if (begin < 0)
 		{
-			left = 0;
+			begin = 0;
 			llwarns << "Min:" << min << llendl;
 		}
 
-		right = (S32) ((max - mMinBar) * value_scale);
-		gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 0.f, 0.f, 0.25f));
+		S32 end = (S32) ((max - mMinBar) * value_scale);
+		if (mOrientation == HORIZONTAL)
+		{
+			gl_rect_2d(bar_left, end, bar_right, begin, LLColor4(1.f, 0.f, 0.f, 0.25f));
+		}
+		else // VERTICAL
+		{
+			gl_rect_2d(begin, bar_top, end, bar_bottom, LLColor4(1.f, 0.f, 0.f, 0.25f));
+		}
 
 		if (mDisplayHistory && (mCountFloatp || mCountIntp || mMeasurementFloatp || mMeasurementIntp))
 		{
-			S32 num_values = frame_recording.getNumPeriods() - 1;
+			const S32 num_values = frame_recording.getNumPeriods() - 1;
+			S32 begin = 0;
+			S32 end = 0;
 			S32 i;
 			for (i = 1; i <= num_values; i++)
 			{
@@ -269,66 +300,86 @@ void LLStatBar::draw()
 				{
 					if (mCountFloatp)
 					{
-						left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountFloatp)  - mMinBar) * value_scale);
-						right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountFloatp)  - mMinBar) * value_scale) + 1;
+						begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountFloatp)  - mMinBar) * value_scale);
+						end = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountFloatp)  - mMinBar) * value_scale) + 1;
 					}
 					else if (mCountIntp)
 					{
-						left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountIntp)  - mMinBar) * value_scale);
-						right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountIntp)  - mMinBar) * value_scale) + 1;
+						begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountIntp)  - mMinBar) * value_scale);
+						end = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountIntp)  - mMinBar) * value_scale) + 1;
 					}
 					else if (mMeasurementFloatp)
 					{
-						left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementFloatp)  - mMinBar) * value_scale);
-						right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementFloatp)  - mMinBar) * value_scale) + 1;
+						begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementFloatp)  - mMinBar) * value_scale);
+						end = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementFloatp)  - mMinBar) * value_scale) + 1;
 					}
 					else if (mMeasurementIntp)
 					{
-						left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementIntp)  - mMinBar) * value_scale);
-						right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementIntp)  - mMinBar) * value_scale) + 1;
+						begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementIntp)  - mMinBar) * value_scale);
+						end = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementIntp)  - mMinBar) * value_scale) + 1;
 					}
-					gl_rect_2d(left, bottom+i+1, right, bottom+i, LLColor4(1.f, 0.f, 0.f, 1.f));
 				}
 				else
 				{
 					if (mCountFloatp)
 					{
-						left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountFloatp)  - mMinBar) * value_scale);
-						right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountFloatp)  - mMinBar) * value_scale) + 1;
+						begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountFloatp)  - mMinBar) * value_scale);
+						end = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountFloatp)  - mMinBar) * value_scale) + 1;
 					}
 					else if (mCountIntp)
 					{
-						left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountIntp)  - mMinBar) * value_scale);
-						right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountIntp)  - mMinBar) * value_scale) + 1;
+						begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountIntp)  - mMinBar) * value_scale);
+						end = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountIntp)  - mMinBar) * value_scale) + 1;
 					}
 					else if (mMeasurementFloatp)
 					{
-						left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementFloatp)  - mMinBar) * value_scale);
-						right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementFloatp)  - mMinBar) * value_scale) + 1;
+						begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementFloatp)  - mMinBar) * value_scale);
+						end = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementFloatp)  - mMinBar) * value_scale) + 1;
 					}
 					else if (mMeasurementIntp)
 					{
-						left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementIntp)  - mMinBar) * value_scale);
-						right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementIntp)  - mMinBar) * value_scale) + 1;
+						begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementIntp)  - mMinBar) * value_scale);
+						end = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementIntp)  - mMinBar) * value_scale) + 1;
 					}
-					gl_rect_2d(left, bottom+i+1, right, bottom+i, LLColor4(1.f, 0.f, 0.f, 1.f));
+				}
+				if (mOrientation == HORIZONTAL)
+				{
+					gl_rect_2d(bar_right - i, end, bar_right - i - 1, begin, LLColor4(1.f, 0.f, 0.f, 1.f));
+				}
+				else
+				{
+					gl_rect_2d(begin, bar_bottom+i+1, end, bar_bottom+i, LLColor4(1.f, 0.f, 0.f, 1.f));
 				}
 			}
 		}
 		else
 		{
+			S32 begin = (S32) ((current - mMinBar) * value_scale) - 1;
+			S32 end = (S32) ((current - mMinBar) * value_scale) + 1;
 			// draw current
-			left = (S32) ((current - mMinBar) * value_scale) - 1;
-			right = (S32) ((current - mMinBar) * value_scale) + 1;
-			gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 0.f, 0.f, 1.f));
+			if (mOrientation == HORIZONTAL)
+			{
+				gl_rect_2d(bar_left, end, bar_right, begin, LLColor4(1.f, 0.f, 0.f, 1.f));
+			}
+			else
+			{
+				gl_rect_2d(begin, bar_top, end, bar_bottom, LLColor4(1.f, 0.f, 0.f, 1.f));
+			}
 		}
 
 		// draw mean bar
-		top = bar_top + 2;
-		bottom = bar_top - bar_height - 2;
-		left = (S32) ((mean - mMinBar) * value_scale) - 1;
-		right = (S32) ((mean - mMinBar) * value_scale) + 1;
-		gl_rect_2d(left, top, right, bottom, LLColor4(0.f, 1.f, 0.f, 1.f));
+		{
+			const S32 begin = (S32) ((mean - mMinBar) * value_scale) - 1;
+			const S32 end = (S32) ((mean - mMinBar) * value_scale) + 1;
+			if (mOrientation == HORIZONTAL)
+			{
+				gl_rect_2d(bar_left - 2, begin, bar_right + 2, end, LLColor4(0.f, 1.f, 0.f, 1.f));
+			}
+			else
+			{
+				gl_rect_2d(begin, bar_top + 2, end, bar_bottom - 2, LLColor4(0.f, 1.f, 0.f, 1.f));
+			}
+		}
 	}
 	
 	LLView::draw();
diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h
index c366fd65db9..0ec8aaeaa9a 100644
--- a/indra/llui/llstatbar.h
+++ b/indra/llui/llstatbar.h
@@ -55,6 +55,7 @@ class LLStatBar : public LLView
 								show_mean;
 
 		Optional<std::string>	stat;
+		Optional<EOrientation>	orientation;
 
 		Params()
 			: label("label"),
@@ -70,7 +71,8 @@ class LLStatBar : public LLView
 			  show_bar("show_bar", TRUE),
 			  show_history("show_history", false),
 			  show_mean("show_mean", true),
-			  stat("stat")
+			  stat("stat"),
+			  orientation("orientation", VERTICAL)
 		{
 			changeDefault(follows.flags, FOLLOWS_TOP | FOLLOWS_LEFT);
 		}
@@ -88,27 +90,28 @@ class LLStatBar : public LLView
 	/*virtual*/ LLRect getRequiredRect();	// Return the height of this object, given the set options.
 
 private:
-	F32 mMinBar;
-	F32 mMaxBar;
-	F32 mTickSpacing;
-	F32 mLabelSpacing;
-	U32 mPrecision;
-	F32 mUpdatesPerSec;
-	F32 mUnitScale;
-	BOOL mPerSec;				// Use the per sec stats.
-	BOOL mDisplayBar;			// Display the bar graph.
-	BOOL mDisplayHistory;
-	BOOL mDisplayMean;			// If true, display mean, if false, display current value
-
-	LLTrace::TraceType<LLTrace::CountAccumulator<F64> >* mCountFloatp;
-	LLTrace::TraceType<LLTrace::CountAccumulator<S64> >* mCountIntp;
+	F32          mMinBar;
+	F32          mMaxBar;
+	F32          mTickSpacing;
+	F32          mLabelSpacing;
+	U32          mPrecision;
+	F32          mUpdatesPerSec;
+	F32          mUnitScale;
+	bool         mPerSec;				// Use the per sec stats.
+	bool         mDisplayBar;			// Display the bar graph.
+	bool         mDisplayHistory;
+	bool         mDisplayMean;			// If true, display mean, if false, display current value
+	EOrientation mOrientation;
+
+	LLTrace::TraceType<LLTrace::CountAccumulator<F64> >*       mCountFloatp;
+	LLTrace::TraceType<LLTrace::CountAccumulator<S64> >*       mCountIntp;
 	LLTrace::TraceType<LLTrace::MeasurementAccumulator<F64> >* mMeasurementFloatp;
 	LLTrace::TraceType<LLTrace::MeasurementAccumulator<S64> >* mMeasurementIntp;
 
 	LLFrameTimer mUpdateTimer;
-	LLUIString mLabel;
-	std::string mUnitLabel;
-	F32 mValue;
+	LLUIString   mLabel;
+	std::string  mUnitLabel;
+	F32          mValue;
 };
 
 #endif
diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp
index 22c276a0183..bdb378c9c54 100644
--- a/indra/llui/llstatgraph.cpp
+++ b/indra/llui/llstatgraph.cpp
@@ -58,14 +58,6 @@ LLStatGraph::LLStatGraph(const Params& p)
 	{
 		mThresholds.push_back(Threshold(it->value(), it->color));
 	}
-
-	//mThresholdColors[0] = LLColor4(0.f, 1.f, 0.f, 1.f);
-	//mThresholdColors[1] = LLColor4(1.f, 1.f, 0.f, 1.f);
-	//mThresholdColors[2] = LLColor4(1.f, 0.f, 0.f, 1.f);
-	//mThresholdColors[3] = LLColor4(1.f, 0.f, 0.f, 1.f);
-	//mThresholds[0] = 50.f;
-	//mThresholds[1] = 75.f;
-	//mThresholds[2] = 100.f;
 }
 
 void LLStatGraph::draw()
@@ -116,15 +108,6 @@ void LLStatGraph::draw()
 
 	LLColor4 color;
 
-	//S32 i;
-	//for (i = 0; i < mNumThresholds - 1; i++)
-	//{
-	//	if (mThresholds[i] > mValue)
-	//	{
-	//		break;
-	//	}
-	//}
-
 	threshold_vec_t::iterator it = std::lower_bound(mThresholds.begin(), mThresholds.end(), Threshold(mValue / mMax, LLUIColor()));
 
 	if (it != mThresholds.begin())
diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h
index 57856ff6f2a..c9e33ed9029 100644
--- a/indra/llui/llstatgraph.h
+++ b/indra/llui/llstatgraph.h
@@ -57,8 +57,8 @@ class LLStatGraph : public LLView
 
 	struct StatParams : public LLInitParam::ChoiceBlock<StatParams>
 	{
-		Alternative<LLTrace::TraceType<LLTrace::CountAccumulator<F64> >* >		count_stat_float;
-		Alternative<LLTrace::TraceType<LLTrace::CountAccumulator<S64> >* >		count_stat_int;
+		Alternative<LLTrace::TraceType<LLTrace::CountAccumulator<F64> >* >			count_stat_float;
+		Alternative<LLTrace::TraceType<LLTrace::CountAccumulator<S64> >* >			count_stat_int;
 		Alternative<LLTrace::TraceType<LLTrace::MeasurementAccumulator<F64> >* >	measurement_stat_float;
 		Alternative<LLTrace::TraceType<LLTrace::MeasurementAccumulator<S64> >* >	measurement_stat_int;
 	};
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 81ea0ebf0ca..2297285c391 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -42,9 +42,9 @@
 
 namespace LLToolBarEnums
 {
-	LLLayoutStack::ELayoutOrientation getOrientation(SideType sideType)
+	LLView::EOrientation getOrientation(SideType sideType)
 	{
-		LLLayoutStack::ELayoutOrientation orientation = LLLayoutStack::HORIZONTAL;
+		LLView::EOrientation orientation = LLLayoutStack::HORIZONTAL;
 
 		if ((sideType == SIDE_LEFT) || (sideType == SIDE_RIGHT))
 		{
@@ -172,7 +172,7 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p)
 	// Initialize the base object
 	LLUICtrl::initFromParams(p);
 	
-	LLLayoutStack::ELayoutOrientation orientation = getOrientation(p.side);
+	LLView::EOrientation orientation = getOrientation(p.side);
 
 	LLLayoutStack::Params centering_stack_p;
 	centering_stack_p.name = "centering_stack";
@@ -524,7 +524,7 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y)
 	int rank = 0;
 
 	// Convert the toolbar coord into button panel coords
-	LLLayoutStack::ELayoutOrientation orientation = getOrientation(mSideType);
+	LLView::EOrientation orientation = getOrientation(mSideType);
 	S32 button_panel_x = 0;
 	S32 button_panel_y = 0;
 	localPointToOtherView(x, y, &button_panel_x, &button_panel_y, mButtonPanel);
@@ -643,7 +643,7 @@ void LLToolBar::updateLayoutAsNeeded()
 {
 	if (!mNeedsLayout) return;
 
-	LLLayoutStack::ELayoutOrientation orientation = getOrientation(mSideType);
+	LLView::EOrientation orientation = getOrientation(mSideType);
 	
 	// our terminology for orientation-agnostic layout is such that
 	// length refers to a distance in the direction we stack the buttons 
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index a50c60282c4..2ffcc8b574c 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -124,7 +124,7 @@ namespace LLToolBarEnums
 		SIDE_TOP,
 	};
 
-	LLLayoutStack::ELayoutOrientation getOrientation(SideType sideType);
+	LLView::EOrientation getOrientation(SideType sideType);
 }
 
 // NOTE: This needs to occur before Param block declaration for proper compilation.
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 587953477d7..ba88396294f 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -83,6 +83,16 @@ template class LLView* LLView::getChild<class LLView>(
 
 static LLDefaultChildRegistry::Register<LLView> r("view");
 
+namespace LLInitParam
+{
+	void TypeValues<LLView::EOrientation>::declareValues()
+	{
+		declare("horizontal", LLView::HORIZONTAL);
+		declare("vertical", LLView::VERTICAL);	
+	}
+}
+
+
 LLView::Follows::Follows()
 :   string(""),
 	flags("flags", FOLLOWS_LEFT | FOLLOWS_TOP)
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index e18cfff8e5d..88813da3c60 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -105,6 +105,9 @@ class LLView
 	public LLTrace::MemTrackable<LLView> // track memory usage
 {
 public:
+
+	enum EOrientation { HORIZONTAL, VERTICAL, ORIENTATION_COUNT };
+
 	struct Follows : public LLInitParam::ChoiceBlock<Follows>
 	{
 		Alternative<std::string>	string;
@@ -676,6 +679,16 @@ class LLView
 	static LLTrace::MemStatHandle sMemStat;
 };
 
+namespace LLInitParam
+{
+template<>
+struct TypeValues<LLView::EOrientation> : public LLInitParam::TypeValuesHelper<LLView::EOrientation>
+{
+	static void declareValues();
+};
+}
+
+
 class LLCompareByTabOrder
 {
 public:
diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp
index 81ad96f39e4..da7b2593770 100644
--- a/indra/newview/lltoolbarview.cpp
+++ b/indra/newview/lltoolbarview.cpp
@@ -517,7 +517,7 @@ void LLToolBarView::draw()
 	{
 		if (mToolbars[i])
 		{
-			LLLayoutStack::ELayoutOrientation orientation = LLToolBarEnums::getOrientation(mToolbars[i]->getSideType());
+			LLView::EOrientation orientation = LLToolBarEnums::getOrientation(mToolbars[i]->getSideType());
 
 			if (orientation == LLLayoutStack::HORIZONTAL)
 			{
@@ -535,8 +535,8 @@ void LLToolBarView::draw()
 	for (S32 i = TOOLBAR_FIRST; i <= TOOLBAR_LAST; i++)
 	{
 		mToolbars[i]->getParent()->setVisible(mShowToolbars 
-											&& (mToolbars[i]->hasButtons() 
-											|| isToolDragged()));
+												&& (mToolbars[i]->hasButtons() 
+													|| isToolDragged()));
 	}
 
 	// Draw drop zones if drop of a tool is active
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index db169b86a46..483e42d2960 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4065,7 +4065,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
 		{
 			LLTracker::stopTracking(NULL);
 		}
-		else if ( is_teleport && !gAgent.getTeleportKeepsLookAt() )
+		else if ( is_teleport && !gAgent.getTeleportKeepsLookAt() && look_at.isExactlyZero())
 		{
 			//look at the beacon
 			LLVector3 global_agent_pos = agent_pos;
diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index 273954ee3e5..93d99458000 100644
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -35,6 +35,7 @@
 			 setting="OpenDebugStatBasic">
 			<stat_bar
 			   name="fps"
+         orientation="horizontal"
 			   label="FPS"
 			   unit_label="fps"
 			   stat="fpsstat"
-- 
GitLab