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

Side by Side Diff: bench/nanobench.h

Issue 1039253002: Minor cleanup in nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Canvas may not be present Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | bench/nanobench.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 */ 6 */
7 7
8 #ifndef nanobench_DEFINED 8 #ifndef nanobench_DEFINED
9 #define nanobench_DEFINED 9 #define nanobench_DEFINED
10 10
(...skipping 29 matching lines...) Expand all
40 explicit Target(const Config& c) : config(c) { } 40 explicit Target(const Config& c) : config(c) { }
41 virtual ~Target() { } 41 virtual ~Target() { }
42 42
43 const Config config; 43 const Config config;
44 SkAutoTDelete<SkSurface> surface; 44 SkAutoTDelete<SkSurface> surface;
45 45
46 /** Called once per target, immediately before any timing or drawing. */ 46 /** Called once per target, immediately before any timing or drawing. */
47 virtual void setup() { } 47 virtual void setup() { }
48 48
49 /** Called *after* the clock timer is started, before the benchmark 49 /** Called *after* the clock timer is started, before the benchmark
50 is drawn. */ 50 is drawn. Most back ends just return the canvas passed in,
51 but some may replace it. */
51 virtual SkCanvas* beginTiming(SkCanvas* canvas) { return canvas; } 52 virtual SkCanvas* beginTiming(SkCanvas* canvas) { return canvas; }
52 53
53 /** Called *after* a benchmark is drawn, but before the clock timer 54 /** Called *after* a benchmark is drawn, but before the clock timer
54 is stopped. */ 55 is stopped. */
55 virtual void endTiming() { } 56 virtual void endTiming() { }
56 57
57 /** Called between benchmarks (or between calibration and measured 58 /** Called between benchmarks (or between calibration and measured
58 runs) to make sure all pending work in drivers / threads is 59 runs) to make sure all pending work in drivers / threads is
59 complete. */ 60 complete. */
60 virtual void fence() { } 61 virtual void fence() { }
61 62
62 /** CPU-like targets can just be timed, but GPU-like 63 /** CPU-like targets can just be timed, but GPU-like
63 targets need to pay attention to frame boundaries 64 targets need to pay attention to frame boundaries
64 or other similar details. */ 65 or other similar details. */
65 virtual bool needsFrameTiming() const { return false; } 66 virtual bool needsFrameTiming() const { return false; }
66 67
67 /** Called once per target, during program initialization. 68 /** Called once per target, during program initialization.
68 Returns false if initialization fails. */ 69 Returns false if initialization fails. */
69 virtual bool init(SkImageInfo info, Benchmark* bench); 70 virtual bool init(SkImageInfo info, Benchmark* bench);
70 71
71 /** Stores any pixels drawn to the screen in the bitmap. 72 /** Stores any pixels drawn to the screen in the bitmap.
72 Returns false on error. */ 73 Returns false on error. */
73 virtual bool capturePixels(SkBitmap* bmp); 74 virtual bool capturePixels(SkBitmap* bmp);
74 75
75 /** Writes any config-specific data to the log. */ 76 /** Writes any config-specific data to the log. */
76 virtual void fillOptions(ResultsWriter*) { } 77 virtual void fillOptions(ResultsWriter*) { }
78
79 SkCanvas* getCanvas() const {
80 if (!surface.get()) {
81 return NULL;
82 }
83 return surface->getCanvas();
84 }
77 }; 85 };
78 86
79 #endif // nanobench_DEFINED 87 #endif // nanobench_DEFINED
OLDNEW
« no previous file with comments | « no previous file | bench/nanobench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698