summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llstatbar.cpp79
-rw-r--r--indra/llui/llstatbar.h3
-rw-r--r--indra/llui/llstatgraph.cpp123
-rw-r--r--indra/llui/llstatgraph.h99
4 files changed, 216 insertions, 88 deletions
diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp
index a21d7aa6a1..2d1b582598 100644
--- a/indra/llui/llstatbar.cpp
+++ b/indra/llui/llstatbar.cpp
@@ -36,6 +36,7 @@
#include "llstat.h"
#include "lluictrlfactory.h"
+#include "lltracesampler.h"
///////////////////////////////////////////////////////////////////////////////////
@@ -46,6 +47,8 @@ LLStatBar::LLStatBar(const Params& p)
mMinBar(p.bar_min),
mMaxBar(p.bar_max),
mStatp(LLStat::getInstance(p.stat)),
+ mFloatStatp(LLTrace::Stat<F32>::getInstance(p.stat)),
+ mIntStatp(LLTrace::Stat<S32>::getInstance(p.stat)),
mTickSpacing(p.tick_spacing),
mLabelSpacing(p.label_spacing),
mPrecision(p.precision),
@@ -84,30 +87,66 @@ BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask)
void LLStatBar::draw()
{
- if (!mStatp)
+ F32 current = 0.f,
+ min = 0.f,
+ max = 0.f,
+ mean = 0.f;
+
+ if (mStatp)
{
-// llinfos << "No stats for statistics bar!" << llendl;
- return;
+ // Get the values.
+ if (mPerSec)
+ {
+ current = mStatp->getCurrentPerSec();
+ min = mStatp->getMinPerSec();
+ max = mStatp->getMaxPerSec();
+ mean = mStatp->getMeanPerSec();
+ }
+ else
+ {
+ current = mStatp->getCurrent();
+ min = mStatp->getMin();
+ max = mStatp->getMax();
+ mean = mStatp->getMean();
+ }
}
-
- // Get the values.
- F32 current, min, max, mean;
- if (mPerSec)
+ else if (mFloatStatp)
{
- current = mStatp->getCurrentPerSec();
- min = mStatp->getMinPerSec();
- max = mStatp->getMaxPerSec();
- mean = mStatp->getMeanPerSec();
+ LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler();
+ if (mPerSec)
+ {
+ current = sampler->getSum(*mFloatStatp) / sampler->getSampleTime();
+ min = sampler->getMin(*mFloatStatp) / sampler->getSampleTime();
+ max = sampler->getMax(*mFloatStatp) / sampler->getSampleTime();
+ mean = sampler->getMean(*mFloatStatp) / sampler->getSampleTime();
+ }
+ else
+ {
+ current = sampler->getSum(*mFloatStatp);
+ min = sampler->getMin(*mFloatStatp);
+ max = sampler->getMax(*mFloatStatp);
+ mean = sampler->getMean(*mFloatStatp);
+ }
}
- else
+ else if (mIntStatp)
{
- current = mStatp->getCurrent();
- min = mStatp->getMin();
- max = mStatp->getMax();
- mean = mStatp->getMean();
+ LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler();
+ if (mPerSec)
+ {
+ current = (F32)sampler->getSum(*mIntStatp) / sampler->getSampleTime();
+ min = (F32)sampler->getMin(*mIntStatp) / sampler->getSampleTime();
+ max = (F32)sampler->getMax(*mIntStatp) / sampler->getSampleTime();
+ mean = (F32)sampler->getMean(*mIntStatp) / sampler->getSampleTime();
+ }
+ else
+ {
+ current = (F32)sampler->getSum(*mIntStatp);
+ min = (F32)sampler->getMin(*mIntStatp);
+ max = (F32)sampler->getMax(*mIntStatp);
+ mean = (F32)sampler->getMean(*mIntStatp);
+ }
}
-
if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f))
{
if (mDisplayMean)
@@ -153,7 +192,7 @@ void LLStatBar::draw()
LLFontGL::RIGHT, LLFontGL::TOP);
value_format = llformat( "%%.%df", mPrecision);
- if (mDisplayBar)
+ if (mDisplayBar && mStatp)
{
std::string tick_label;
@@ -213,9 +252,9 @@ void LLStatBar::draw()
right = (S32) ((max - mMinBar) * value_scale);
gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 0.f, 0.f, 0.25f));
- S32 num_values = mStatp->getNumValues() - 1;
if (mDisplayHistory)
{
+ S32 num_values = mStatp->getNumValues() - 1;
S32 i;
for (i = 0; i < num_values; i++)
{
@@ -270,7 +309,7 @@ LLRect LLStatBar::getRequiredRect()
if (mDisplayBar)
{
- if (mDisplayHistory)
+ if (mDisplayHistory && mStatp)
{
rect.mTop = 35 + mStatp->getNumBins();
}
diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h
index 7e636d0aa7..8348290abf 100644
--- a/indra/llui/llstatbar.h
+++ b/indra/llui/llstatbar.h
@@ -29,6 +29,7 @@
#include "llview.h"
#include "llframetimer.h"
+#include "lltrace.h"
class LLStat;
@@ -92,6 +93,8 @@ private:
BOOL mDisplayMean; // If true, display mean, if false, display current value
LLStat* mStatp;
+ LLTrace::Stat<F32>* mFloatStatp;
+ LLTrace::Stat<S32>* mIntStatp;
LLFrameTimer mUpdateTimer;
LLUIString mLabel;
diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp
index e44887ebf0..19896c4597 100644
--- a/indra/llui/llstatgraph.cpp
+++ b/indra/llui/llstatgraph.cpp
@@ -35,28 +35,38 @@
#include "llstat.h"
#include "llgl.h"
#include "llglheaders.h"
+#include "lltracesampler.h"
//#include "llviewercontrol.h"
///////////////////////////////////////////////////////////////////////////////////
-LLStatGraph::LLStatGraph(const LLView::Params& p)
-: LLView(p)
+LLStatGraph::LLStatGraph(const Params& p)
+: LLView(p),
+ mMin(p.min),
+ mMax(p.max),
+ mPerSec(true),
+ mPrecision(p.precision),
+ mValue(p.value),
+ mStatp(p.stat.legacy_stat),
+ mF32Statp(p.stat.f32_stat),
+ mS32Statp(p.stat.s32_stat)
{
- mStatp = NULL;
setToolTip(p.name());
- mNumThresholds = 3;
- 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;
- mMin = 0.f;
- mMax = 125.f;
- mPerSec = TRUE;
- mValue = 0.f;
- mPrecision = 0;
+
+ for(LLInitParam::ParamIterator<ThresholdParams>::const_iterator it = p.thresholds.threshold.begin(), end_it = p.thresholds.threshold.end();
+ it != end_it;
+ ++it)
+ {
+ 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()
@@ -74,6 +84,33 @@ void LLStatGraph::draw()
mValue = mStatp->getMean();
}
}
+ else if (mF32Statp)
+ {
+ LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler();
+
+ if (mPerSec)
+ {
+ mValue = sampler->getSum(*mF32Statp) / sampler->getSampleTime();
+ }
+ else
+ {
+ mValue = sampler->getSum(*mF32Statp);
+ }
+
+ }
+ else if (mS32Statp)
+ {
+ LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler();
+
+ if (mPerSec)
+ {
+ mValue = sampler->getSum(*mS32Statp) / sampler->getSampleTime();
+ }
+ else
+ {
+ mValue = sampler->getSum(*mS32Statp);
+ }
+ }
frac = (mValue - mMin) / range;
frac = llmax(0.f, frac);
frac = llmin(1.f, frac);
@@ -91,19 +128,22 @@ void LLStatGraph::draw()
LLColor4 color;
- S32 i;
- for (i = 0; i < mNumThresholds - 1; i++)
+ //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())
{
- if (mThresholds[i] > mValue)
- {
- break;
- }
+ it--;
}
- //gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0,
- // LLUIColorTable::instance().getColor("ColorDropShadow"),
- // (S32) gSavedSettings.getF32("DropShadowFloater") );
-
color = LLUIColorTable::instance().getColor( "MenuDefaultBgColor" );
gGL.color4fv(color.mV);
gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, TRUE);
@@ -111,16 +151,11 @@ void LLStatGraph::draw()
gGL.color4fv(LLColor4::black.mV);
gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, FALSE);
- color = mThresholdColors[i];
+ color = it->mColor;
gGL.color4fv(color.mV);
gl_rect_2d(1, llround(frac*getRect().getHeight()), getRect().getWidth() - 1, 0, TRUE);
}
-void LLStatGraph::setValue(const LLSD& value)
-{
- mValue = (F32)value.asReal();
-}
-
void LLStatGraph::setMin(const F32 min)
{
mMin = min;
@@ -131,27 +166,3 @@ void LLStatGraph::setMax(const F32 max)
mMax = max;
}
-void LLStatGraph::setStat(LLStat *statp)
-{
- mStatp = statp;
-}
-
-void LLStatGraph::setLabel(const std::string& label)
-{
- mLabel = label;
-}
-
-void LLStatGraph::setUnits(const std::string& units)
-{
- mUnits = units;
-}
-
-void LLStatGraph::setPrecision(const S32 precision)
-{
- mPrecision = precision;
-}
-
-void LLStatGraph::setThreshold(const S32 i, F32 value)
-{
- mThresholds[i] = value;
-}
diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h
index 757525e232..e7de945694 100644
--- a/indra/llui/llstatgraph.h
+++ b/indra/llui/llstatgraph.h
@@ -30,29 +30,88 @@
#include "llview.h"
#include "llframetimer.h"
#include "v4color.h"
+#include "lltrace.h"
class LLStat;
class LLStatGraph : public LLView
{
public:
- LLStatGraph(const LLView::Params&);
+ struct ThresholdParams : public LLInitParam::Block<ThresholdParams>
+ {
+ Mandatory<F32> value;
+ Optional<LLUIColor> color;
- virtual void draw();
+ ThresholdParams()
+ : value("value"),
+ color("color", LLColor4::white)
+ {}
+ };
+
+ struct Thresholds : public LLInitParam::Block<Thresholds>
+ {
+ Multiple<ThresholdParams> threshold;
+
+ Thresholds()
+ : threshold("threshold")
+ {}
+ };
+
+ struct StatParams : public LLInitParam::ChoiceBlock<StatParams>
+ {
+ Alternative<LLStat*> legacy_stat;
+ Alternative<LLTrace::Stat<F32>* > f32_stat;
+ Alternative<LLTrace::Stat<S32>* > s32_stat;
+ };
+
+ struct Params : public LLInitParam::Block<Params, LLView::Params>
+ {
+ Mandatory<StatParams> stat;
+ Optional<std::string> label,
+ units;
+ Optional<S32> precision;
+ Optional<F32> min,
+ max;
+ Optional<bool> per_sec;
+ Optional<F32> value;
+
+ Optional<Thresholds> thresholds;
+
+ Params()
+ : stat("stat"),
+ label("label"),
+ units("units"),
+ precision("precision", 0),
+ min("min", 0.f),
+ max("max", 125.f),
+ per_sec("per_sec", true),
+ value("value", 0.f),
+ thresholds("thresholds")
+ {
+ Thresholds _thresholds;
+ _thresholds.threshold.add(ThresholdParams().value(0.f).color(LLColor4::green))
+ .add(ThresholdParams().value(0.33f).color(LLColor4::yellow))
+ .add(ThresholdParams().value(0.5f).color(LLColor4::red))
+ .add(ThresholdParams().value(0.75f).color(LLColor4::red));
+ thresholds = _thresholds;
+ }
+ };
+ LLStatGraph(const Params&);
- void setLabel(const std::string& label);
- void setUnits(const std::string& units);
- void setPrecision(const S32 precision);
- void setStat(LLStat *statp);
- void setThreshold(const S32 i, F32 value);
void setMin(const F32 min);
void setMax(const F32 max);
+ virtual void draw();
+
/*virtual*/ void setValue(const LLSD& value);
- LLStat *mStatp;
- BOOL mPerSec;
private:
+ LLStat* mStatp;
+ LLTrace::Stat<F32>* mF32Statp;
+ LLTrace::Stat<S32>* mS32Statp;
+
+ BOOL mPerSec;
+
F32 mValue;
F32 mMin;
@@ -62,9 +121,25 @@ private:
std::string mUnits;
S32 mPrecision; // Num of digits of precision after dot
- S32 mNumThresholds;
- F32 mThresholds[4];
- LLColor4 mThresholdColors[4];
+ struct Threshold
+ {
+ Threshold(F32 value, const LLUIColor& color)
+ : mValue(value),
+ mColor(color)
+ {}
+
+ F32 mValue;
+ LLUIColor mColor;
+ bool operator <(const Threshold& other)
+ {
+ return mValue < other.mValue;
+ }
+ };
+ typedef std::vector<Threshold> threshold_vec_t;
+ threshold_vec_t mThresholds;
+ //S32 mNumThresholds;
+ //F32 mThresholds[4];
+ //LLColor4 mThresholdColors[4];
};
#endif // LL_LLSTATGRAPH_H