diff options
author | 2017-05-24 09:58:07 -0400 | |
---|---|---|
committer | 2017-05-24 15:38:17 +0000 | |
commit | 5458cf8ec62c548480d5bb142afa71e4269ddac9 (patch) | |
tree | 1e27246cd9035f608e17194b5d99d92de5da40a5 /samplecode/SampleApp.cpp | |
parent | 3b840e930493d260bf4945af03920c01400ee6cc (diff) |
Add cumulative fps to SampleApp
In some samples (whose frame time is really really small),
the fps number jumps so fast that I can hardly see even
the first digit of the number. This problem will become
more severe for threaded backend which substantially lowers
the frame time. Taking an average over a long time would
give me a much more stable fps number.
Bug: skia:
Change-Id: Ie6052b4735d9410d5e644331bf025b5bf9f40323
Reviewed-on: https://skia-review.googlesource.com/17823
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Yuqian Li <liyuqian@google.com>
Diffstat (limited to 'samplecode/SampleApp.cpp')
-rw-r--r-- | samplecode/SampleApp.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index bdd1ef1673..87873f16f1 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -383,6 +383,7 @@ public: } void windowSizeChanged(SampleWindow* win) override { + win->resetFPS(); #if SK_SUPPORT_GPU if (fCurContext) { AttachmentInfo attachmentInfo; @@ -1480,6 +1481,8 @@ void SampleWindow::afterChildren(SkCanvas* orig) { orig->flush(); fTimer.end(); fMeasureFPS_Time += fTimer.fWall; + fCumulativeFPS_Time += fTimer.fWall; + fCumulativeFPS_Count += FPS_REPEAT_COUNT; } } @@ -1582,6 +1585,7 @@ void SampleWindow::updateMatrix(){ this->inval(nullptr); } bool SampleWindow::previousSample() { + this->resetFPS(); fCurrIndex = (fCurrIndex - 1 + fSamples.count()) % fSamples.count(); this->loadView((*fSamples[fCurrIndex])()); return true; @@ -1590,6 +1594,7 @@ bool SampleWindow::previousSample() { #include "SkResourceCache.h" #include "SkGlyphCache.h" bool SampleWindow::nextSample() { + this->resetFPS(); fCurrIndex = (fCurrIndex + 1) % fSamples.count(); this->loadView((*fSamples[fCurrIndex])()); @@ -1603,6 +1608,7 @@ bool SampleWindow::nextSample() { } bool SampleWindow::goToSample(int i) { + this->resetFPS(); fCurrIndex = (i) % fSamples.count(); this->loadView((*fSamples[fCurrIndex])()); return true; @@ -1869,6 +1875,9 @@ bool SampleWindow::onHandleChar(SkUnichar uni) { this->inval(nullptr); } break; + case '0': + this->resetFPS(); + break; case 'A': if (gSkUseAnalyticAA.load() && !gSkForceAnalyticAA.load()) { gSkForceAnalyticAA = true; @@ -2001,6 +2010,11 @@ void SampleWindow::toggleFPS() { this->inval(nullptr); } +void SampleWindow::resetFPS() { + fCumulativeFPS_Time = 0; + fCumulativeFPS_Count = 0; +} + void SampleWindow::toggleDistanceFieldFonts() { // reset backend fDevManager->tearDownBackend(this); @@ -2279,6 +2293,7 @@ void SampleWindow::updateTitle() { if (fMeasureFPS) { title.appendf(" %8.4f ms", fMeasureFPS_Time / (float)FPS_REPEAT_COUNT); + title.appendf(" -> %4.4f ms", fCumulativeFPS_Time / (float)SkTMax(1, fCumulativeFPS_Count)); } #if SK_SUPPORT_GPU |