OLD | NEW |
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" |
11 #include "CrashHandler.h" | 11 #include "CrashHandler.h" |
12 #include "GMBench.h" | 12 #include "GMBench.h" |
13 #include "ResultsWriter.h" | 13 #include "ResultsWriter.h" |
14 #include "SKPBench.h" | 14 #include "SKPBench.h" |
15 #include "Stats.h" | 15 #include "Stats.h" |
16 #include "Timer.h" | 16 #include "Timer.h" |
17 | 17 |
18 #include "SkOSFile.h" | 18 #include "SkOSFile.h" |
19 #include "SkCanvas.h" | 19 #include "SkCanvas.h" |
20 #include "SkCommonFlags.h" | 20 #include "SkCommonFlags.h" |
21 #include "SkForceLinking.h" | 21 #include "SkForceLinking.h" |
22 #include "SkGraphics.h" | 22 #include "SkGraphics.h" |
23 #include "SkString.h" | 23 #include "SkString.h" |
24 #include "SkSurface.h" | 24 #include "SkSurface.h" |
25 | 25 |
26 #if SK_SUPPORT_GPU | 26 #if SK_SUPPORT_GPU |
27 #include "gl/GrGLDefines.h" | 27 #include "gl/GrGLDefines.h" |
28 #include "GrContextFactory.h" | 28 #include "GrContextFactory.h" |
29 GrContextFactory gGrFactory; | 29 SkAutoTDelete<GrContextFactory> gGrFactory; |
30 #endif | 30 #endif |
31 | 31 |
32 __SK_FORCE_IMAGE_DECODER_LINKING; | 32 __SK_FORCE_IMAGE_DECODER_LINKING; |
33 | 33 |
34 static const int kAutoTuneLoops = -1; | 34 static const int kAutoTuneLoops = -1; |
35 | 35 |
36 static const int kDefaultLoops = | 36 static const int kDefaultLoops = |
37 #ifdef SK_DEBUG | 37 #ifdef SK_DEBUG |
38 1; | 38 1; |
39 #else | 39 #else |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 281 } |
282 return false; | 282 return false; |
283 } | 283 } |
284 | 284 |
285 #if SK_SUPPORT_GPU | 285 #if SK_SUPPORT_GPU |
286 static bool is_gpu_config_allowed(const char* name, GrContextFactory::GLContextT
ype ctxType, | 286 static bool is_gpu_config_allowed(const char* name, GrContextFactory::GLContextT
ype ctxType, |
287 int sampleCnt) { | 287 int sampleCnt) { |
288 if (!is_cpu_config_allowed(name)) { | 288 if (!is_cpu_config_allowed(name)) { |
289 return false; | 289 return false; |
290 } | 290 } |
291 if (const GrContext* ctx = gGrFactory.get(ctxType)) { | 291 if (const GrContext* ctx = gGrFactory->get(ctxType)) { |
292 return sampleCnt <= ctx->getMaxSampleCount(); | 292 return sampleCnt <= ctx->getMaxSampleCount(); |
293 } | 293 } |
294 return false; | 294 return false; |
295 } | 295 } |
296 #endif | 296 #endif |
297 | 297 |
298 #if SK_SUPPORT_GPU | 298 #if SK_SUPPORT_GPU |
299 #define kBogusGLContextType GrContextFactory::kNative_GLContextType | 299 #define kBogusGLContextType GrContextFactory::kNative_GLContextType |
300 #else | 300 #else |
301 #define kBogusGLContextType 0 | 301 #define kBogusGLContextType 0 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 info.fWidth = bench->getSize().fX; | 355 info.fWidth = bench->getSize().fX; |
356 info.fHeight = bench->getSize().fY; | 356 info.fHeight = bench->getSize().fY; |
357 | 357 |
358 Target* target = new Target(config); | 358 Target* target = new Target(config); |
359 | 359 |
360 if (Benchmark::kRaster_Backend == config.backend) { | 360 if (Benchmark::kRaster_Backend == config.backend) { |
361 target->surface.reset(SkSurface::NewRaster(info)); | 361 target->surface.reset(SkSurface::NewRaster(info)); |
362 } | 362 } |
363 #if SK_SUPPORT_GPU | 363 #if SK_SUPPORT_GPU |
364 else if (Benchmark::kGPU_Backend == config.backend) { | 364 else if (Benchmark::kGPU_Backend == config.backend) { |
365 target->surface.reset(SkSurface::NewRenderTarget(gGrFactory.get(config.c
txType), info, | 365 target->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(config.
ctxType), info, |
366 config.samples)); | 366 config.samples)); |
367 target->gl = gGrFactory.getGLContext(config.ctxType); | 367 target->gl = gGrFactory->getGLContext(config.ctxType); |
368 } | 368 } |
369 #endif | 369 #endif |
370 | 370 |
371 if (Benchmark::kNonRendering_Backend != config.backend && !target->surface.g
et()) { | 371 if (Benchmark::kNonRendering_Backend != config.backend && !target->surface.g
et()) { |
372 delete target; | 372 delete target; |
373 return NULL; | 373 return NULL; |
374 } | 374 } |
375 return target; | 375 return target; |
376 } | 376 } |
377 | 377 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 const char* fSourceType; | 521 const char* fSourceType; |
522 int fCurrentScale; | 522 int fCurrentScale; |
523 int fCurrentSKP; | 523 int fCurrentSKP; |
524 }; | 524 }; |
525 | 525 |
526 int nanobench_main(); | 526 int nanobench_main(); |
527 int nanobench_main() { | 527 int nanobench_main() { |
528 SetupCrashHandler(); | 528 SetupCrashHandler(); |
529 SkAutoGraphics ag; | 529 SkAutoGraphics ag; |
530 | 530 |
| 531 #if SK_SUPPORT_GPU |
| 532 gGrFactory.reset(SkNEW_ARGS(GrContextFactory, (GrContext::Options()))); |
| 533 #endif |
| 534 |
531 if (kAutoTuneLoops != FLAGS_loops) { | 535 if (kAutoTuneLoops != FLAGS_loops) { |
532 FLAGS_samples = 1; | 536 FLAGS_samples = 1; |
533 FLAGS_gpuFrameLag = 0; | 537 FLAGS_gpuFrameLag = 0; |
534 } | 538 } |
535 | 539 |
536 if (!FLAGS_writePath.isEmpty()) { | 540 if (!FLAGS_writePath.isEmpty()) { |
537 SkDebugf("Writing files to %s.\n", FLAGS_writePath[0]); | 541 SkDebugf("Writing files to %s.\n", FLAGS_writePath[0]); |
538 if (!sk_mkdir(FLAGS_writePath[0])) { | 542 if (!sk_mkdir(FLAGS_writePath[0])) { |
539 SkDebugf("Could not create %s. Files won't be written.\n", FLAGS_wri
tePath[0]); | 543 SkDebugf("Could not create %s. Files won't be written.\n", FLAGS_wri
tePath[0]); |
540 FLAGS_writePath.set(0, NULL); | 544 FLAGS_writePath.set(0, NULL); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 , stats.plot.c_str() | 668 , stats.plot.c_str() |
665 , config | 669 , config |
666 , bench->getName() | 670 , bench->getName() |
667 ); | 671 ); |
668 } | 672 } |
669 } | 673 } |
670 targets.deleteAll(); | 674 targets.deleteAll(); |
671 | 675 |
672 #if SK_SUPPORT_GPU | 676 #if SK_SUPPORT_GPU |
673 if (FLAGS_abandonGpuContext) { | 677 if (FLAGS_abandonGpuContext) { |
674 gGrFactory.abandonContexts(); | 678 gGrFactory->abandonContexts(); |
675 } | 679 } |
676 if (FLAGS_resetGpuContext || FLAGS_abandonGpuContext) { | 680 if (FLAGS_resetGpuContext || FLAGS_abandonGpuContext) { |
677 gGrFactory.destroyContexts(); | 681 gGrFactory->destroyContexts(); |
678 } | 682 } |
679 #endif | 683 #endif |
680 } | 684 } |
681 | 685 |
682 return 0; | 686 return 0; |
683 } | 687 } |
684 | 688 |
685 #if !defined SK_BUILD_FOR_IOS | 689 #if !defined SK_BUILD_FOR_IOS |
686 int main(int argc, char** argv) { | 690 int main(int argc, char** argv) { |
687 SkCommandLineFlags::Parse(argc, argv); | 691 SkCommandLineFlags::Parse(argc, argv); |
688 return nanobench_main(); | 692 return nanobench_main(); |
689 } | 693 } |
690 #endif | 694 #endif |
OLD | NEW |