Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Unified Diff: tools/viewer/Viewer.cpp

Issue 2129613002: More accurate render time and continuous fresh (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove ms argument of onIdle function Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/viewer/Viewer.h ('k') | tools/viewer/sk_app/Application.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/viewer/Viewer.cpp
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 0ed7e26f0a940e635d455b6a4ed19d0ccf2e1110..ff77cc444ef569d5c7864e61fcbdf8bd69b4da21 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -20,6 +20,7 @@
#include "SkRandom.h"
#include "SkStream.h"
#include "SkSurface.h"
+#include "SkTime.h"
using namespace sk_app;
@@ -86,10 +87,12 @@ const char* kFpsStateName = "FPS";
const char* kSplitScreenStateName = "Split screen";
const char* kON = "ON";
const char* kOFF = "OFF";
+const char* kRefreshStateName = "Refresh";
Viewer::Viewer(int argc, char** argv, void* platformData)
: fCurrentMeasurement(0)
, fDisplayStats(false)
+ , fRefresh(false)
, fSplitScreen(false)
, fBackendType(sk_app::Window::kNativeGL_BackendType)
, fZoomCenterX(0.0f)
@@ -400,6 +403,9 @@ void Viewer::drawSlide(SkCanvas* canvas, bool inSplitScreen) {
}
void Viewer::onPaint(SkCanvas* canvas) {
+ // Record measurements
+ double startTime = SkTime::GetMSecs();
+
drawSlide(canvas, false);
if (fSplitScreen && fWindow->supportsContentRect()) {
drawSlide(canvas, true);
@@ -409,6 +415,11 @@ void Viewer::onPaint(SkCanvas* canvas) {
drawStats(canvas);
}
fCommands.drawHelp(canvas);
+
+ fMeasurements[fCurrentMeasurement++] = SkTime::GetMSecs() - startTime;
+ fCurrentMeasurement &= (kMeasurementCount - 1); // fast mod
+ SkASSERT(fCurrentMeasurement < kMeasurementCount);
+ updateUIState(); // Update the FPS
}
bool Viewer::onTouch(intptr_t owner, Window::InputState state, float x, float y) {
@@ -480,16 +491,10 @@ void Viewer::drawStats(SkCanvas* canvas) {
canvas->restore();
}
-void Viewer::onIdle(double ms) {
- // Record measurements
- fMeasurements[fCurrentMeasurement++] = ms;
- fCurrentMeasurement &= (kMeasurementCount - 1); // fast mod
- SkASSERT(fCurrentMeasurement < kMeasurementCount);
-
+void Viewer::onIdle() {
fAnimTimer.updateTime();
- if (fSlides[fCurrentSlide]->animate(fAnimTimer) || fDisplayStats) {
+ if (fSlides[fCurrentSlide]->animate(fAnimTimer) || fDisplayStats || fRefresh) {
fWindow->inval();
- updateUIState(); // Update the FPS
}
}
@@ -596,6 +601,10 @@ void Viewer::onUIStateChanged(const SkString& stateName, const SkString& stateVa
fWindow->inval();
updateUIState();
}
+ } else if (stateName.equals(kRefreshStateName)) {
+ // This state is actually NOT in the UI state.
+ // We use this to allow Android to quickly set bool fRefresh.
+ fRefresh = stateValue.equals(kON);
} else {
SkDebugf("Unknown stateName: %s", stateName.c_str());
}
« no previous file with comments | « tools/viewer/Viewer.h ('k') | tools/viewer/sk_app/Application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698