| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 * | |
| 7 */ | 6 */ |
| 8 | 7 |
| 9 #ifndef VisualLightweightBenchModule_DEFINED | 8 #ifndef VisualLightweightBenchModule_DEFINED |
| 10 #define VisualLightweightBenchModule_DEFINED | 9 #define VisualLightweightBenchModule_DEFINED |
| 11 | 10 |
| 12 #include "VisualModule.h" | 11 #include "VisualStreamTimingModule.h" |
| 13 | 12 |
| 14 #include "ResultsWriter.h" | 13 #include "ResultsWriter.h" |
| 15 #include "SkPicture.h" | 14 #include "SkPicture.h" |
| 16 #include "TimingStateMachine.h" | |
| 17 #include "VisualBench.h" | 15 #include "VisualBench.h" |
| 18 #include "VisualBenchmarkStream.h" | |
| 19 | 16 |
| 20 class SkCanvas; | 17 class SkCanvas; |
| 21 | 18 |
| 22 /* | 19 /* |
| 23 * This module is designed to be a minimal overhead timing module for VisualBenc
h | 20 * This module is designed to be a minimal overhead timing module for VisualBenc
h |
| 24 */ | 21 */ |
| 25 class VisualLightweightBenchModule : public VisualModule { | 22 class VisualLightweightBenchModule : public VisualStreamTimingModule { |
| 26 public: | 23 public: |
| 27 // TODO get rid of backpointer | 24 // TODO get rid of backpointer |
| 28 VisualLightweightBenchModule(VisualBench* owner); | 25 VisualLightweightBenchModule(VisualBench* owner); |
| 29 | 26 |
| 30 void draw(SkCanvas* canvas) override; | |
| 31 | |
| 32 bool onHandleChar(SkUnichar c) override; | 27 bool onHandleChar(SkUnichar c) override; |
| 33 | 28 |
| 34 private: | 29 private: |
| 35 void setTitle(); | 30 void renderFrame(SkCanvas*, Benchmark*, int loops) override; |
| 36 bool setupBackend(); | 31 bool timingFinished(Benchmark*, int loops, double measurement) override; |
| 37 void setupRenderTarget(); | 32 void printStats(Benchmark*, int loops); |
| 38 void printStats(); | |
| 39 bool advanceRecordIfNecessary(SkCanvas*); | |
| 40 inline void renderFrame(SkCanvas*); | |
| 41 | 33 |
| 42 struct Record { | 34 struct Record { |
| 43 SkTArray<double> fMeasurements; | 35 SkTArray<double> fMeasurements; |
| 44 }; | 36 }; |
| 45 int fCurrentSample; | 37 int fCurrentSample; |
| 46 SkTArray<Record> fRecords; | 38 SkTArray<Record> fRecords; |
| 47 SkAutoTDelete<VisualBenchmarkStream> fBenchmarkStream; | |
| 48 SkAutoTUnref<Benchmark> fBenchmark; | |
| 49 TimingStateMachine fTSM; | |
| 50 bool fHasBeenReset; | |
| 51 | 39 |
| 52 // support framework | 40 // support framework |
| 53 SkAutoTUnref<VisualBench> fOwner; | |
| 54 SkAutoTDelete<ResultsWriter> fResults; | 41 SkAutoTDelete<ResultsWriter> fResults; |
| 55 | 42 |
| 56 typedef VisualModule INHERITED; | 43 typedef VisualStreamTimingModule INHERITED; |
| 57 }; | 44 }; |
| 58 | 45 |
| 59 #endif | 46 #endif |
| OLD | NEW |