diff options
author | 2015-08-11 11:07:07 -0700 | |
---|---|---|
committer | 2015-08-11 11:07:07 -0700 | |
commit | 4d0d81aec2667cf4dc82971ee42c29c1ec1aeb13 (patch) | |
tree | 32b4173528ec453acfa83e00c92b1a69e1338fd4 /samplecode | |
parent | 8ee06f21a27bbffaf613a312c6f24bbbb21c650a (diff) |
Add high resolution WallTimer to SampleApp
Gives better than 1 ms results when timing framerate.
Review URL: https://codereview.chromium.org/1288473002
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleApp.cpp | 12 | ||||
-rw-r--r-- | samplecode/SampleApp.h | 5 |
2 files changed, 9 insertions, 8 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index 486feedb79..5bb223a312 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -1313,8 +1313,9 @@ void SampleWindow::afterChildren(SkCanvas* orig) { } // Do this after presentGL and other finishing, rather than in afterChild - if (fMeasureFPS && fMeasureFPS_StartTime) { - fMeasureFPS_Time += SkTime::GetMSecs() - fMeasureFPS_StartTime; + if (fMeasureFPS) { + fTimer.end(); + fMeasureFPS_Time += fTimer.fWall; } } @@ -1351,9 +1352,8 @@ void SampleWindow::beforeChild(SkView* child, SkCanvas* canvas) { } if (fMeasureFPS) { - if (SampleView::SetRepeatDraw(child, FPS_REPEAT_COUNT)) { - fMeasureFPS_StartTime = SkTime::GetMSecs(); - } + (void)SampleView::SetRepeatDraw(child, FPS_REPEAT_COUNT); + fTimer.start(); } else { (void)SampleView::SetRepeatDraw(child, 1); } @@ -1935,7 +1935,7 @@ void SampleWindow::updateTitle() { } if (fMeasureFPS) { - title.appendf(" %8.3f ms", fMeasureFPS_Time / (float)FPS_REPEAT_COUNT); + title.appendf(" %8.4f ms", fMeasureFPS_Time / (float)FPS_REPEAT_COUNT); } SkView* view = curr_view(this); diff --git a/samplecode/SampleApp.h b/samplecode/SampleApp.h index 97854fcb97..c0f845d32c 100644 --- a/samplecode/SampleApp.h +++ b/samplecode/SampleApp.h @@ -16,6 +16,7 @@ #include "SkTDArray.h" #include "SkTouchGesture.h" #include "SkWindow.h" +#include "timer/Timer.h" class GrContext; class GrRenderTarget; @@ -183,8 +184,8 @@ private: bool fPerspAnim; bool fRequestGrabImage; bool fMeasureFPS; - SkMSec fMeasureFPS_Time; - SkMSec fMeasureFPS_StartTime; + WallTimer fTimer; + double fMeasureFPS_Time; bool fMagnify; int fTilingMode; |