Add high resolution WallTimer to SampleApp
Gives better than 1 ms results when timing framerate. Review URL: https://codereview.chromium.org/1288473002
This commit is contained in:
parent
8ee06f21a2
commit
4d0d81aec2
@ -22,6 +22,7 @@
|
||||
'../samplecode', # To pull SampleApp.h and SampleCode.h
|
||||
'../src/pipe/utils', # For TiledPipeController
|
||||
'../src/utils/debugger',
|
||||
'../tools',
|
||||
],
|
||||
'includes': [
|
||||
'gmslides.gypi',
|
||||
@ -154,6 +155,7 @@
|
||||
'skia_lib.gyp:skia_lib',
|
||||
'tools.gyp:resources',
|
||||
'tools.gyp:sk_tool_utils',
|
||||
'tools.gyp:timer',
|
||||
'views.gyp:views',
|
||||
'views_animated.gyp:views_animated',
|
||||
'xml.gyp:xml',
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user