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 * | 6 * |
7 */ | 7 */ |
8 | 8 |
9 #include "VisualBench.h" | 9 #include "VisualBench.h" |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 #define HUMANIZE(time) humanize(time).c_str() | 50 #define HUMANIZE(time) humanize(time).c_str() |
51 | 51 |
52 VisualBench::VisualBench(void* hwnd, int argc, char** argv) | 52 VisualBench::VisualBench(void* hwnd, int argc, char** argv) |
53 : INHERITED(hwnd) | 53 : INHERITED(hwnd) |
54 , fCurrentSample(0) | 54 , fCurrentSample(0) |
55 , fCurrentFrame(0) | 55 , fCurrentFrame(0) |
56 , fFlushes(1) | 56 , fFlushes(1) |
57 , fLoops(1) | 57 , fLoops(1) |
58 , fState(kPreWarmLoops_State) | 58 , fState(kPreWarmLoops_State) |
59 , fBenchmark(NULL) | 59 , fBenchmark(nullptr) |
60 , fResults(new ResultsWriter) { | 60 , fResults(new ResultsWriter) { |
61 SkCommandLineFlags::Parse(argc, argv); | 61 SkCommandLineFlags::Parse(argc, argv); |
62 | 62 |
63 this->setTitle(); | 63 this->setTitle(); |
64 this->setupBackend(); | 64 this->setupBackend(); |
65 | 65 |
66 fBenchmarkStream.reset(new VisualBenchmarkStream); | 66 fBenchmarkStream.reset(new VisualBenchmarkStream); |
67 | 67 |
68 // Print header | 68 // Print header |
69 SkDebugf("curr/maxrss\tloops\tflushes\tmin\tmedian\tmean\tmax\tstddev\tbench
\n"); | 69 SkDebugf("curr/maxrss\tloops\tflushes\tmin\tmedian\tmean\tmax\tstddev\tbench
\n"); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 INHERITED::detach(); | 116 INHERITED::detach(); |
117 return false; | 117 return false; |
118 } | 118 } |
119 | 119 |
120 this->setVsync(false); | 120 this->setVsync(false); |
121 this->resetContext(); | 121 this->resetContext(); |
122 return true; | 122 return true; |
123 } | 123 } |
124 | 124 |
125 void VisualBench::resetContext() { | 125 void VisualBench::resetContext() { |
126 fSurface.reset(NULL); | 126 fSurface.reset(nullptr); |
127 | 127 |
128 fInterface.reset(GrGLCreateNativeInterface()); | 128 fInterface.reset(GrGLCreateNativeInterface()); |
129 SkASSERT(fInterface); | 129 SkASSERT(fInterface); |
130 | 130 |
131 // setup contexts | 131 // setup contexts |
132 fContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fInter
face.get())); | 132 fContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fInter
face.get())); |
133 SkASSERT(fContext); | 133 SkASSERT(fContext); |
134 | 134 |
135 // setup rendertargets | 135 // setup rendertargets |
136 this->setupRenderTarget(); | 136 this->setupRenderTarget(); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 this->preWarm(kTiming_State); | 259 this->preWarm(kTiming_State); |
260 break; | 260 break; |
261 } | 261 } |
262 case kTiming_State: { | 262 case kTiming_State: { |
263 this->timing(canvas); | 263 this->timing(canvas); |
264 break; | 264 break; |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 // Invalidate the window to force a redraw. Poor man's animation mechanism. | 268 // Invalidate the window to force a redraw. Poor man's animation mechanism. |
269 this->inval(NULL); | 269 this->inval(nullptr); |
270 } | 270 } |
271 | 271 |
272 inline double VisualBench::elapsed() { | 272 inline double VisualBench::elapsed() { |
273 fTimer.end(); | 273 fTimer.end(); |
274 return fTimer.fWall; | 274 return fTimer.fWall; |
275 } | 275 } |
276 | 276 |
277 void VisualBench::resetTimingState() { | 277 void VisualBench::resetTimingState() { |
278 fCurrentFrame = 0; | 278 fCurrentFrame = 0; |
279 fTimer = WallTimer(); | 279 fTimer = WallTimer(); |
(...skipping 24 matching lines...) Expand all Loading... |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 void VisualBench::recordMeasurement() { | 307 void VisualBench::recordMeasurement() { |
308 double measurement = this->elapsed() / (FLAGS_frames * fLoops * fFlushes); | 308 double measurement = this->elapsed() / (FLAGS_frames * fLoops * fFlushes); |
309 fRecords.back().fMeasurements.push_back(measurement); | 309 fRecords.back().fMeasurements.push_back(measurement); |
310 } | 310 } |
311 | 311 |
312 void VisualBench::postDraw(SkCanvas* canvas) { | 312 void VisualBench::postDraw(SkCanvas* canvas) { |
313 fBenchmark->perCanvasPostDraw(canvas); | 313 fBenchmark->perCanvasPostDraw(canvas); |
314 fBenchmark.reset(NULL); | 314 fBenchmark.reset(nullptr); |
315 fCurrentSample = 0; | 315 fCurrentSample = 0; |
316 fFlushes = 1; | 316 fFlushes = 1; |
317 fLoops = 1; | 317 fLoops = 1; |
318 } | 318 } |
319 | 319 |
320 inline void VisualBench::timing(SkCanvas* canvas) { | 320 inline void VisualBench::timing(SkCanvas* canvas) { |
321 if (fCurrentFrame >= FLAGS_frames) { | 321 if (fCurrentFrame >= FLAGS_frames) { |
322 this->recordMeasurement(); | 322 this->recordMeasurement(); |
323 if (fCurrentSample++ >= FLAGS_samples) { | 323 if (fCurrentSample++ >= FLAGS_samples) { |
324 this->printStats(); | 324 this->printStats(); |
(...skipping 24 matching lines...) Expand all Loading... |
349 | 349 |
350 void application_term() { | 350 void application_term() { |
351 SkEvent::Term(); | 351 SkEvent::Term(); |
352 SkGraphics::Term(); | 352 SkGraphics::Term(); |
353 } | 353 } |
354 | 354 |
355 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { | 355 SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { |
356 return new VisualBench(hwnd, argc, argv); | 356 return new VisualBench(hwnd, argc, argv); |
357 } | 357 } |
358 | 358 |
OLD | NEW |