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 "nanobench.h" | 10 #include "nanobench.h" |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 } else { | 417 } else { |
418 SkDebugf("No context was available matching config type and options.
\n"); | 418 SkDebugf("No context was available matching config type and options.
\n"); |
419 return; | 419 return; |
420 } | 420 } |
421 | 421 |
422 Config target = { | 422 Config target = { |
423 gpuConfig->getTag(), | 423 gpuConfig->getTag(), |
424 Benchmark::kGPU_Backend, | 424 Benchmark::kGPU_Backend, |
425 kN32_SkColorType, | 425 kN32_SkColorType, |
426 kPremul_SkAlphaType, | 426 kPremul_SkAlphaType, |
427 nullptr, | 427 kLinear_SkColorProfileType, |
428 sampleCount, | 428 sampleCount, |
429 ctxType, | 429 ctxType, |
430 ctxOptions, | 430 ctxOptions, |
431 gpuConfig->getUseDIText() | 431 gpuConfig->getUseDIText() |
432 }; | 432 }; |
433 | 433 |
434 configs->push_back(target); | 434 configs->push_back(target); |
435 return; | 435 return; |
436 } | 436 } |
437 #endif | 437 #endif |
438 | 438 |
439 #define CPU_CONFIG(name, backend, color, alpha, colorSpace) \ | 439 #define CPU_CONFIG(name, backend, color, alpha, profile) \ |
440 if (config->getTag().equals(#name)) { \ | 440 if (config->getTag().equals(#name)) { \ |
441 Config config = { \ | 441 Config config = { \ |
442 SkString(#name), Benchmark::backend, color, alpha, colorSpace, \ | 442 SkString(#name), Benchmark::backend, color, alpha, profile, \ |
443 0, kBogusContextType, kBogusContextOptions, false \ | 443 0, kBogusContextType, kBogusContextOptions, false \ |
444 }; \ | 444 }; \ |
445 configs->push_back(config); \ | 445 configs->push_back(config); \ |
446 return; \ | 446 return; \ |
447 } | 447 } |
448 | 448 |
449 if (FLAGS_cpu) { | 449 if (FLAGS_cpu) { |
450 CPU_CONFIG(nonrendering, kNonRendering_Backend, | 450 CPU_CONFIG(nonrendering, kNonRendering_Backend, |
451 kUnknown_SkColorType, kUnpremul_SkAlphaType, nullptr) | 451 kUnknown_SkColorType, kUnpremul_SkAlphaType, kLinear_SkColorP
rofileType); |
452 | 452 |
453 CPU_CONFIG(8888, kRaster_Backend, | 453 CPU_CONFIG(8888, kRaster_Backend, |
454 kN32_SkColorType, kPremul_SkAlphaType, nullptr) | 454 kN32_SkColorType, kPremul_SkAlphaType, kLinear_SkColorProfile
Type) |
455 CPU_CONFIG(565, kRaster_Backend, | 455 CPU_CONFIG(565, kRaster_Backend, |
456 kRGB_565_SkColorType, kOpaque_SkAlphaType, nullptr) | 456 kRGB_565_SkColorType, kOpaque_SkAlphaType, kLinear_SkColorPro
fileType) |
457 auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); | |
458 CPU_CONFIG(srgb, kRaster_Backend, | 457 CPU_CONFIG(srgb, kRaster_Backend, |
459 kN32_SkColorType, kPremul_SkAlphaType, srgbColorSpace) | 458 kN32_SkColorType, kPremul_SkAlphaType, kSRGB_SkColorProfileT
ype) |
460 CPU_CONFIG(f16, kRaster_Backend, | 459 CPU_CONFIG(f16, kRaster_Backend, |
461 kRGBA_F16_SkColorType, kPremul_SkAlphaType, nullptr) | 460 kRGBA_F16_SkColorType, kPremul_SkAlphaType, kLinear_SkColorPr
ofileType) |
462 } | 461 } |
463 | 462 |
464 #undef CPU_CONFIG | 463 #undef CPU_CONFIG |
465 | 464 |
466 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 465 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
467 if (config->getTag().equals("hwui")) { | 466 if (config->getTag().equals("hwui")) { |
468 Config config = { SkString("hwui"), Benchmark::kHWUI_Backend, | 467 Config config = { SkString("hwui"), Benchmark::kHWUI_Backend, |
469 kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr, | 468 kRGBA_8888_SkColorType, kPremul_SkAlphaType, kLinear_S
kColorProfileType, |
470 0, kBogusContextType, kBogusContextOptions, false }; | 469 0, kBogusContextType, kBogusContextOptions, false }; |
471 configs->push_back(config); | 470 configs->push_back(config); |
472 } | 471 } |
473 #endif | 472 #endif |
474 } | 473 } |
475 | 474 |
476 // Append all configs that are enabled and supported. | 475 // Append all configs that are enabled and supported. |
477 void create_configs(SkTArray<Config>* configs) { | 476 void create_configs(SkTArray<Config>* configs) { |
478 SkCommandLineConfigArray array; | 477 SkCommandLineConfigArray array; |
479 ParseConfigs(FLAGS_config, &array); | 478 ParseConfigs(FLAGS_config, &array); |
480 for (int i = 0; i < array.count(); ++i) { | 479 for (int i = 0; i < array.count(); ++i) { |
481 create_config(array[i], configs); | 480 create_config(array[i], configs); |
482 } | 481 } |
483 } | 482 } |
484 | 483 |
485 // If bench is enabled for config, returns a Target* for it, otherwise nullptr. | 484 // If bench is enabled for config, returns a Target* for it, otherwise nullptr. |
486 static Target* is_enabled(Benchmark* bench, const Config& config) { | 485 static Target* is_enabled(Benchmark* bench, const Config& config) { |
487 if (!bench->isSuitableFor(config.backend)) { | 486 if (!bench->isSuitableFor(config.backend)) { |
488 return nullptr; | 487 return nullptr; |
489 } | 488 } |
490 | 489 |
491 SkImageInfo info = SkImageInfo::Make(bench->getSize().fX, bench->getSize().f
Y, | 490 SkImageInfo info = SkImageInfo::Make(bench->getSize().fX, bench->getSize().f
Y, |
492 config.color, config.alpha, config.colo
rSpace); | 491 config.color, config.alpha, config.prof
ile); |
493 | 492 |
494 Target* target = nullptr; | 493 Target* target = nullptr; |
495 | 494 |
496 switch (config.backend) { | 495 switch (config.backend) { |
497 #if SK_SUPPORT_GPU | 496 #if SK_SUPPORT_GPU |
498 case Benchmark::kGPU_Backend: | 497 case Benchmark::kGPU_Backend: |
499 target = new GPUTarget(config); | 498 target = new GPUTarget(config); |
500 break; | 499 break; |
501 #endif | 500 #endif |
502 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 501 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 | 1287 |
1289 return 0; | 1288 return 0; |
1290 } | 1289 } |
1291 | 1290 |
1292 #if !defined SK_BUILD_FOR_IOS | 1291 #if !defined SK_BUILD_FOR_IOS |
1293 int main(int argc, char** argv) { | 1292 int main(int argc, char** argv) { |
1294 SkCommandLineFlags::Parse(argc, argv); | 1293 SkCommandLineFlags::Parse(argc, argv); |
1295 return nanobench_main(); | 1294 return nanobench_main(); |
1296 } | 1295 } |
1297 #endif | 1296 #endif |
OLD | NEW |