Chromium Code Reviews| 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 GrContextFactory* gGrFactory; |
| 30 #endif | 30 #endif |
|
bsalomon
2014/08/13 00:49:33
Maybe just make this the autotdelete? I think it h
krajcevski
2014/08/13 14:46:00
Done.
| |
| 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 |
| 40 kAutoTuneLoops; | 40 kAutoTuneLoops; |
| (...skipping 240 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 // Setup GrContextFactory | |
| 533 SkAutoTDelete<GrContextFactory> gGrFactoryPtr; | |
| 534 gGrFactoryPtr.reset(SkNEW_ARGS(GrContextFactory, (GrContext::Options()))); | |
| 535 gGrFactory = gGrFactoryPtr.get(); | |
| 536 #endif | |
| 537 | |
| 531 if (kAutoTuneLoops != FLAGS_loops) { | 538 if (kAutoTuneLoops != FLAGS_loops) { |
| 532 FLAGS_samples = 1; | 539 FLAGS_samples = 1; |
| 533 FLAGS_gpuFrameLag = 0; | 540 FLAGS_gpuFrameLag = 0; |
| 534 } | 541 } |
| 535 | 542 |
| 536 if (!FLAGS_writePath.isEmpty()) { | 543 if (!FLAGS_writePath.isEmpty()) { |
| 537 SkDebugf("Writing files to %s.\n", FLAGS_writePath[0]); | 544 SkDebugf("Writing files to %s.\n", FLAGS_writePath[0]); |
| 538 if (!sk_mkdir(FLAGS_writePath[0])) { | 545 if (!sk_mkdir(FLAGS_writePath[0])) { |
| 539 SkDebugf("Could not create %s. Files won't be written.\n", FLAGS_wri tePath[0]); | 546 SkDebugf("Could not create %s. Files won't be written.\n", FLAGS_wri tePath[0]); |
| 540 FLAGS_writePath.set(0, NULL); | 547 FLAGS_writePath.set(0, NULL); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 664 , stats.plot.c_str() | 671 , stats.plot.c_str() |
| 665 , config | 672 , config |
| 666 , bench->getName() | 673 , bench->getName() |
| 667 ); | 674 ); |
| 668 } | 675 } |
| 669 } | 676 } |
| 670 targets.deleteAll(); | 677 targets.deleteAll(); |
| 671 | 678 |
| 672 #if SK_SUPPORT_GPU | 679 #if SK_SUPPORT_GPU |
| 673 if (FLAGS_abandonGpuContext) { | 680 if (FLAGS_abandonGpuContext) { |
| 674 gGrFactory.abandonContexts(); | 681 gGrFactory->abandonContexts(); |
| 675 } | 682 } |
| 676 if (FLAGS_resetGpuContext || FLAGS_abandonGpuContext) { | 683 if (FLAGS_resetGpuContext || FLAGS_abandonGpuContext) { |
| 677 gGrFactory.destroyContexts(); | 684 gGrFactory->destroyContexts(); |
| 678 } | 685 } |
| 679 #endif | 686 #endif |
| 680 } | 687 } |
| 681 | 688 |
| 682 return 0; | 689 return 0; |
| 683 } | 690 } |
| 684 | 691 |
| 685 #if !defined SK_BUILD_FOR_IOS | 692 #if !defined SK_BUILD_FOR_IOS |
| 686 int main(int argc, char** argv) { | 693 int main(int argc, char** argv) { |
| 687 SkCommandLineFlags::Parse(argc, argv); | 694 SkCommandLineFlags::Parse(argc, argv); |
| 688 return nanobench_main(); | 695 return nanobench_main(); |
| 689 } | 696 } |
| 690 #endif | 697 #endif |
| OLD | NEW |