aboutsummaryrefslogtreecommitdiff
path: root/samplecode/SampleApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'samplecode/SampleApp.cpp')
-rw-r--r--samplecode/SampleApp.cpp15
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