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