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

Unified Diff: tools/VisualBench/VisualInteractiveModule.cpp

Issue 1385073002: Create VisualStreamTimingModule (Closed) Base URL: https://skia.googlesource.com/skia.git@vb3a
Patch Set: feedback inc Created 5 years, 2 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/VisualBench/VisualInteractiveModule.h ('k') | tools/VisualBench/VisualLightweightBenchModule.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/VisualBench/VisualInteractiveModule.cpp
diff --git a/tools/VisualBench/VisualInteractiveModule.cpp b/tools/VisualBench/VisualInteractiveModule.cpp
index d2e5b20fa3b253a8cc419796aec4e2fee55cfc20..b597b05727532bf15e84731447c20dde9db02140 100755
--- a/tools/VisualBench/VisualInteractiveModule.cpp
+++ b/tools/VisualBench/VisualInteractiveModule.cpp
@@ -3,42 +3,28 @@
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
- *
*/
#include "VisualInteractiveModule.h"
-#include "ProcStats.h"
-#include "SkApplication.h"
#include "SkCanvas.h"
#include "SkCommandLineFlags.h"
#include "SkForceLinking.h"
-#include "SkGraphics.h"
-#include "SkGr.h"
#include "SkImageDecoder.h"
-#include "SkOSFile.h"
-#include "SkStream.h"
-#include "Stats.h"
-#include "gl/GrGLInterface.h"
__SK_FORCE_IMAGE_DECODER_LINKING;
VisualInteractiveModule::VisualInteractiveModule(VisualBench* owner)
- : fCurrentMeasurement(0)
- , fBenchmark(nullptr)
- , fAdvance(false)
- , fHasBeenReset(false)
- , fOwner(SkRef(owner)) {
- fBenchmarkStream.reset(new VisualBenchmarkStream);
-
+ : INHERITED(owner, false)
+ , fCurrentMeasurement(0)
+ , fAdvance(false) {
memset(fMeasurements, 0, sizeof(fMeasurements));
}
-inline void VisualInteractiveModule::renderFrame(SkCanvas* canvas) {
- fBenchmark->draw(fTSM.loops(), canvas);
+void VisualInteractiveModule::renderFrame(SkCanvas* canvas, Benchmark* benchmark, int loops) {
+ benchmark->draw(loops, canvas);
this->drawStats(canvas);
canvas->flush();
- fOwner->present();
}
void VisualInteractiveModule::drawStats(SkCanvas* canvas) {
@@ -80,63 +66,16 @@ void VisualInteractiveModule::drawStats(SkCanvas* canvas) {
}
-bool VisualInteractiveModule::advanceRecordIfNecessary(SkCanvas* canvas) {
- if (fBenchmark) {
+bool VisualInteractiveModule::timingFinished(Benchmark* benchmark, int loops, double measurement) {
+ // Record measurements
+ fMeasurements[fCurrentMeasurement++] = measurement;
+ fCurrentMeasurement &= (kMeasurementCount-1); // fast mod
+ SkASSERT(fCurrentMeasurement < kMeasurementCount);
+ if (fAdvance) {
+ fAdvance = false;
return true;
}
-
- fBenchmark.reset(fBenchmarkStream->next());
- if (!fBenchmark) {
- return false;
- }
-
- // clear both buffers
- fOwner->clear(canvas, SK_ColorWHITE, 2);
-
- fBenchmark->delayedSetup();
- fBenchmark->preTimingHooks(canvas);
- return true;
-}
-#include "GrGpu.h"
-#include "GrResourceCache.h"
-void VisualInteractiveModule::draw(SkCanvas* canvas) {
- if (!this->advanceRecordIfNecessary(canvas)) {
- SkDebugf("Exiting VisualBench successfully\n");
- fOwner->closeWindow();
- return;
- }
-
- if (fHasBeenReset) {
- fHasBeenReset = false;
- fBenchmark->preTimingHooks(canvas);
- }
-
- this->renderFrame(canvas);
- TimingStateMachine::ParentEvents event = fTSM.nextFrame(false);
- switch (event) {
- case TimingStateMachine::kReset_ParentEvents:
- fBenchmark->postTimingHooks(canvas);
- fHasBeenReset = true;
- fOwner->reset();
- break;
- case TimingStateMachine::kTiming_ParentEvents:
- break;
- case TimingStateMachine::kTimingFinished_ParentEvents:
- // Record measurements
- fMeasurements[fCurrentMeasurement++] = fTSM.lastMeasurement();
- fCurrentMeasurement &= (kMeasurementCount-1); // fast mod
- SkASSERT(fCurrentMeasurement < kMeasurementCount);
- this->drawStats(canvas);
- if (fAdvance) {
- fAdvance = false;
- fTSM.nextBenchmark(canvas, fBenchmark);
- fBenchmark->postTimingHooks(canvas);
- fBenchmark.reset(nullptr);
- fOwner->reset();
- fHasBeenReset = true;
- }
- break;
- }
+ return false;
}
bool VisualInteractiveModule::onHandleChar(SkUnichar c) {
« no previous file with comments | « tools/VisualBench/VisualInteractiveModule.h ('k') | tools/VisualBench/VisualLightweightBenchModule.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698