OLD | NEW |
(Empty) | |
| 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 #ifndef nanobench_DEFINED |
| 9 #define nanobench_DEFINED |
| 10 |
| 11 #include "Benchmark.h" |
| 12 #include "SkImageInfo.h" |
| 13 #include "SkSurface.h" |
| 14 #include "SkTypes.h" |
| 15 |
| 16 #if SK_SUPPORT_GPU |
| 17 #include "GrContextFactory.h" |
| 18 #endif |
| 19 |
| 20 class ResultsWriter; |
| 21 class SkBitmap; |
| 22 class SkCanvas; |
| 23 |
| 24 struct Config { |
| 25 const char* name; |
| 26 Benchmark::Backend backend; |
| 27 SkColorType color; |
| 28 SkAlphaType alpha; |
| 29 int samples; |
| 30 #if SK_SUPPORT_GPU |
| 31 GrContextFactory::GLContextType ctxType; |
| 32 bool useDFText; |
| 33 #else |
| 34 int bogusInt; |
| 35 bool bogusBool; |
| 36 #endif |
| 37 }; |
| 38 |
| 39 struct Target { |
| 40 explicit Target(const Config& c) : config(c) { } |
| 41 virtual ~Target() { } |
| 42 |
| 43 const Config config; |
| 44 SkAutoTDelete<SkSurface> surface; |
| 45 |
| 46 /** Called once per target, immediately before any timing or drawing. */ |
| 47 virtual void setup() { } |
| 48 |
| 49 /** Called *after* the clock timer is started, before the benchmark |
| 50 is drawn. */ |
| 51 virtual SkCanvas* beginTiming(SkCanvas* canvas) { return canvas; } |
| 52 |
| 53 /** Called *after* a benchmark is drawn, but before the clock timer |
| 54 is stopped. */ |
| 55 virtual void endTiming() { } |
| 56 |
| 57 /** Called between benchmarks (or between calibration and measured |
| 58 runs) to make sure all pending work in drivers / threads is |
| 59 complete. */ |
| 60 virtual void fence() { } |
| 61 |
| 62 /** CPU-like targets can just be timed, but GPU-like |
| 63 targets need to pay attention to frame boundaries |
| 64 or other similar details. */ |
| 65 virtual bool needsFrameTiming() const { return false; } |
| 66 |
| 67 /** Called once per target, during program initialization. |
| 68 Returns false if initialization fails. */ |
| 69 virtual bool init(SkImageInfo info, Benchmark* bench); |
| 70 |
| 71 /** Stores any pixels drawn to the screen in the bitmap. |
| 72 Returns false on error. */ |
| 73 virtual bool capturePixels(SkBitmap* bmp); |
| 74 |
| 75 /** Writes any config-specific data to the log. */ |
| 76 virtual void fillOptions(ResultsWriter*) { } |
| 77 }; |
| 78 |
| 79 #endif // nanobench_DEFINED |
OLD | NEW |