summaryrefslogtreecommitdiff
path: root/indra/llui/llstatgraph.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/llstatgraph.cpp')
-rw-r--r--indra/llui/llstatgraph.cpp123
1 files changed, 67 insertions, 56 deletions
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;
-}