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

Side by Side Diff: bench/nanobench.cpp

Issue 630843002: Make the Sk GL context class an abstract base class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix android link problem and ios compile problem Created 6 years, 2 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 | gyp/gpu.gypi » ('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 2014 Google Inc. 2 * Copyright 2014 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 #include <ctype.h> 8 #include <ctype.h>
9 9
10 #include "Benchmark.h" 10 #include "Benchmark.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e6); 77 if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e6);
78 #ifdef SK_BUILD_FOR_WIN 78 #ifdef SK_BUILD_FOR_WIN
79 if (ms < 1) return SkStringPrintf("%.3gus", ms*1e3); 79 if (ms < 1) return SkStringPrintf("%.3gus", ms*1e3);
80 #else 80 #else
81 if (ms < 1) return SkStringPrintf("%.3gµs", ms*1e3); 81 if (ms < 1) return SkStringPrintf("%.3gµs", ms*1e3);
82 #endif 82 #endif
83 return SkStringPrintf("%.3gms", ms); 83 return SkStringPrintf("%.3gms", ms);
84 } 84 }
85 #define HUMANIZE(ms) humanize(ms).c_str() 85 #define HUMANIZE(ms) humanize(ms).c_str()
86 86
87 static double time(int loops, Benchmark* bench, SkCanvas* canvas, SkGLContextHel per* gl) { 87 static double time(int loops, Benchmark* bench, SkCanvas* canvas, SkGLContext* g l) {
88 if (canvas) { 88 if (canvas) {
89 canvas->clear(SK_ColorWHITE); 89 canvas->clear(SK_ColorWHITE);
90 } 90 }
91 WallTimer timer; 91 WallTimer timer;
92 timer.start(); 92 timer.start();
93 if (bench) { 93 if (bench) {
94 bench->draw(loops, canvas); 94 bench->draw(loops, canvas);
95 } 95 }
96 if (canvas) { 96 if (canvas) {
97 canvas->flush(); 97 canvas->flush();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 196 }
197 loops = clamp_loops(loops); 197 loops = clamp_loops(loops);
198 198
199 for (int i = 0; i < FLAGS_samples; i++) { 199 for (int i = 0; i < FLAGS_samples; i++) {
200 samples[i] = time(loops, bench, canvas, NULL) / loops; 200 samples[i] = time(loops, bench, canvas, NULL) / loops;
201 } 201 }
202 return loops; 202 return loops;
203 } 203 }
204 204
205 #if SK_SUPPORT_GPU 205 #if SK_SUPPORT_GPU
206 static int gpu_bench(SkGLContextHelper* gl, 206 static int gpu_bench(SkGLContext* gl,
207 Benchmark* bench, 207 Benchmark* bench,
208 SkCanvas* canvas, 208 SkCanvas* canvas,
209 double* samples) { 209 double* samples) {
210 gl->makeCurrent(); 210 gl->makeCurrent();
211 // Make sure we're done with whatever came before. 211 // Make sure we're done with whatever came before.
212 SK_GL(*gl, Finish()); 212 SK_GL(*gl, Finish());
213 213
214 // First, figure out how many loops it'll take to get a frame up to FLAGS_gp uMs. 214 // First, figure out how many loops it'll take to get a frame up to FLAGS_gp uMs.
215 int loops = FLAGS_loops; 215 int loops = FLAGS_loops;
216 if (kAutoTuneLoops == loops) { 216 if (kAutoTuneLoops == loops) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 #else 267 #else
268 int bogusInt; 268 int bogusInt;
269 #endif 269 #endif
270 }; 270 };
271 271
272 struct Target { 272 struct Target {
273 explicit Target(const Config& c) : config(c) {} 273 explicit Target(const Config& c) : config(c) {}
274 const Config config; 274 const Config config;
275 SkAutoTDelete<SkSurface> surface; 275 SkAutoTDelete<SkSurface> surface;
276 #if SK_SUPPORT_GPU 276 #if SK_SUPPORT_GPU
277 SkGLContextHelper* gl; 277 SkGLContext* gl;
278 #endif 278 #endif
279 }; 279 };
280 280
281 static bool is_cpu_config_allowed(const char* name) { 281 static bool is_cpu_config_allowed(const char* name) {
282 for (int i = 0; i < FLAGS_config.count(); i++) { 282 for (int i = 0; i < FLAGS_config.count(); i++) {
283 if (to_lower(FLAGS_config[i]).equals(name)) { 283 if (to_lower(FLAGS_config[i]).equals(name)) {
284 return true; 284 return true;
285 } 285 }
286 } 286 }
287 return false; 287 return false;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 const SkTDArray<Config>& configs) { 382 const SkTDArray<Config>& configs) {
383 for (int i = 0; i < configs.count(); ++i) { 383 for (int i = 0; i < configs.count(); ++i) {
384 if (Target* t = is_enabled(b, configs[i])) { 384 if (Target* t = is_enabled(b, configs[i])) {
385 targets->push(t); 385 targets->push(t);
386 } 386 }
387 387
388 } 388 }
389 } 389 }
390 390
391 #if SK_SUPPORT_GPU 391 #if SK_SUPPORT_GPU
392 static void fill_gpu_options(ResultsWriter* log, SkGLContextHelper* ctx) { 392 static void fill_gpu_options(ResultsWriter* log, SkGLContext* ctx) {
393 const GrGLubyte* version; 393 const GrGLubyte* version;
394 SK_GL_RET(*ctx, version, GetString(GR_GL_VERSION)); 394 SK_GL_RET(*ctx, version, GetString(GR_GL_VERSION));
395 log->configOption("GL_VERSION", (const char*)(version)); 395 log->configOption("GL_VERSION", (const char*)(version));
396 396
397 SK_GL_RET(*ctx, version, GetString(GR_GL_RENDERER)); 397 SK_GL_RET(*ctx, version, GetString(GR_GL_RENDERER));
398 log->configOption("GL_RENDERER", (const char*) version); 398 log->configOption("GL_RENDERER", (const char*) version);
399 399
400 SK_GL_RET(*ctx, version, GetString(GR_GL_VENDOR)); 400 SK_GL_RET(*ctx, version, GetString(GR_GL_VENDOR));
401 log->configOption("GL_VENDOR", (const char*) version); 401 log->configOption("GL_VENDOR", (const char*) version);
402 402
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 717
718 return 0; 718 return 0;
719 } 719 }
720 720
721 #if !defined SK_BUILD_FOR_IOS 721 #if !defined SK_BUILD_FOR_IOS
722 int main(int argc, char** argv) { 722 int main(int argc, char** argv) {
723 SkCommandLineFlags::Parse(argc, argv); 723 SkCommandLineFlags::Parse(argc, argv);
724 return nanobench_main(); 724 return nanobench_main();
725 } 725 }
726 #endif 726 #endif
OLDNEW
« no previous file with comments | « no previous file | gyp/gpu.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698