Chromium Code Reviews| Index: tools/viewer/Viewer.cpp |
| diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp |
| index 0ed7e26f0a940e635d455b6a4ed19d0ccf2e1110..bb775edf69cd577555c7cd673a3fa51961f58e2f 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) { |
| @@ -481,15 +492,9 @@ void Viewer::drawStats(SkCanvas* canvas) { |
| } |
| void Viewer::onIdle(double ms) { |
|
jvanverth1
2016/07/06 15:27:20
We don't need the ms parameter any more, so I woul
liyuqian
2016/07/06 15:54:40
Done.
|
| - // Record measurements |
| - fMeasurements[fCurrentMeasurement++] = ms; |
| - fCurrentMeasurement &= (kMeasurementCount - 1); // fast mod |
| - SkASSERT(fCurrentMeasurement < kMeasurementCount); |
| - |
| 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()); |
| } |