| 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 #define kBogusGLContextOptions 0 | 389 #define kBogusGLContextOptions 0 |
| 390 #endif | 390 #endif |
| 391 | 391 |
| 392 static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
onfigs) { | 392 static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
onfigs) { |
| 393 | 393 |
| 394 #if SK_SUPPORT_GPU | 394 #if SK_SUPPORT_GPU |
| 395 if (const auto* gpuConfig = config->asConfigGpu()) { | 395 if (const auto* gpuConfig = config->asConfigGpu()) { |
| 396 if (!FLAGS_gpu) | 396 if (!FLAGS_gpu) |
| 397 return; | 397 return; |
| 398 | 398 |
| 399 const auto ctxOptions = gpuConfig->getUseNVPR() ? GrContextFactory::kEna
bleNVPR_GLContextOptions | 399 const auto ctxOptions = gpuConfig->getUseNVPR() ? GrContextFactory::kEna
bleNVPR_GLContextOptions |
| 400 : GrContextFactory::kNon
e_GLContextOptions; | 400 : GrContextFactory::kNon
e_GLContextOptions; |
| 401 const auto ctxType = gpuConfig->getContextType(); | 401 const auto ctxType = gpuConfig->getContextType(); |
| 402 const auto sampleCount = gpuConfig->getSamples(); | 402 const auto sampleCount = gpuConfig->getSamples(); |
| 403 | 403 |
| 404 if (const GrContext* ctx = gGrFactory->get(ctxType, ctxOptions)) { | 404 if (const GrContext* ctx = gGrFactory->get(ctxType, ctxOptions)) { |
| 405 const auto maxSampleCount = ctx->caps()->maxSampleCount(); | 405 const auto maxSampleCount = ctx->caps()->maxSampleCount(); |
| 406 if (sampleCount > ctx->caps()->maxSampleCount()) { | 406 if (sampleCount > ctx->caps()->maxSampleCount()) { |
| 407 SkDebugf("Configuration sample count %d exceeds maximum %d.\n", | 407 SkDebugf("Configuration sample count %d exceeds maximum %d.\n", |
| 408 sampleCount, maxSampleCount); | 408 sampleCount, maxSampleCount); |
| 409 return; | 409 return; |
| 410 } | 410 } |
| 411 } else { | 411 } else { |
| 412 SkDebugf("No context was available matching config type and options.
\n"); | 412 SkDebugf("No context was available matching config type and options.
\n"); |
| 413 return; | 413 return; |
| 414 } | 414 } |
| 415 | 415 |
| 416 Config target = { | 416 Config target = { |
| 417 gpuConfig->getTag(), | 417 gpuConfig->getTag(), |
| 418 Benchmark::kGPU_Backend, | 418 Benchmark::kGPU_Backend, |
| 419 kN32_SkColorType, | 419 kN32_SkColorType, |
| 420 kPremul_SkAlphaType, | 420 kPremul_SkAlphaType, |
| 421 kLinear_SkColorProfileType, |
| 421 sampleCount, | 422 sampleCount, |
| 422 ctxType, | 423 ctxType, |
| 423 ctxOptions, | 424 ctxOptions, |
| 424 gpuConfig->getUseDIText() | 425 gpuConfig->getUseDIText() |
| 425 }; | 426 }; |
| 426 | 427 |
| 427 configs->push_back(target); | 428 configs->push_back(target); |
| 428 return; | 429 return; |
| 429 } | 430 } |
| 430 #endif | 431 #endif |
| 431 | 432 |
| 432 #define CPU_CONFIG(name, backend, color, alpha)
\ | 433 #define CPU_CONFIG(name, backend, color, alpha, profile) \ |
| 433 if (config->getTag().equals(#name)) {
\ | 434 if (config->getTag().equals(#name)) { \ |
| 434 Config config = { SkString(#name), Benchmark::backend, color, alpha,
0, \ | 435 Config config = { \ |
| 435 kBogusGLContextType, kBogusGLContextOptions,
\ | 436 SkString(#name), Benchmark::backend, color, alpha, profile, \ |
| 436 false };
\ | 437 0, kBogusGLContextType, kBogusGLContextOptions, false \ |
| 437 configs->push_back(config);
\ | 438 }; \ |
| 438 return;
\ | 439 configs->push_back(config); \ |
| 440 return; \ |
| 439 } | 441 } |
| 440 | 442 |
| 441 if (FLAGS_cpu) { | 443 if (FLAGS_cpu) { |
| 442 CPU_CONFIG(nonrendering, kNonRendering_Backend, kUnknown_SkColorType, kU
npremul_SkAlphaType) | 444 CPU_CONFIG(nonrendering, kNonRendering_Backend, |
| 443 CPU_CONFIG(8888, kRaster_Backend, kN32_SkColorType, kPremul_SkAlphaType) | 445 kUnknown_SkColorType, kUnpremul_SkAlphaType, kLinear_SkColorP
rofileType); |
| 444 CPU_CONFIG(565, kRaster_Backend, kRGB_565_SkColorType, kOpaque_SkAlphaTy
pe) | 446 |
| 447 CPU_CONFIG(8888, kRaster_Backend, |
| 448 kN32_SkColorType, kPremul_SkAlphaType, kLinear_SkColorProfile
Type) |
| 449 CPU_CONFIG(565, kRaster_Backend, |
| 450 kRGB_565_SkColorType, kOpaque_SkAlphaType, kLinear_SkColorPro
fileType) |
| 451 CPU_CONFIG(srgb, kRaster_Backend, |
| 452 kN32_SkColorType, kPremul_SkAlphaType, kSRGB_SkColorProfileT
ype) |
| 453 CPU_CONFIG(f16, kRaster_Backend, |
| 454 kRGBA_F16_SkColorType, kPremul_SkAlphaType, kLinear_SkColorPr
ofileType) |
| 445 } | 455 } |
| 446 | 456 |
| 447 #undef CPU_CONFIG | 457 #undef CPU_CONFIG |
| 448 | 458 |
| 449 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 459 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 450 if (config->getTag().equals("hwui")) { | 460 if (config->getTag().equals("hwui")) { |
| 451 Config config = { SkString("hwui"), Benchmark::kHWUI_Backend, kRGBA_8888
_SkColorType, | 461 Config config = { SkString("hwui"), Benchmark::kHWUI_Backend, |
| 452 kPremul_SkAlphaType, 0, kBogusGLContextType, kBogusGLC
ontextOptions, | 462 kRGBA_8888_SkColorType, kPremul_SkAlphaType, kLinear_S
kColorProfileType, |
| 453 false }; | 463 0, kBogusGLContextType, kBogusGLContextOptions, false
}; |
| 454 configs->push_back(config); | 464 configs->push_back(config); |
| 455 } | 465 } |
| 456 #endif | 466 #endif |
| 457 } | 467 } |
| 458 | 468 |
| 459 // Append all configs that are enabled and supported. | 469 // Append all configs that are enabled and supported. |
| 460 void create_configs(SkTArray<Config>* configs) { | 470 void create_configs(SkTArray<Config>* configs) { |
| 461 SkCommandLineConfigArray array; | 471 SkCommandLineConfigArray array; |
| 462 ParseConfigs(FLAGS_config, &array); | 472 ParseConfigs(FLAGS_config, &array); |
| 463 for (int i = 0; i < array.count(); ++i) { | 473 for (int i = 0; i < array.count(); ++i) { |
| 464 create_config(array[i], configs); | 474 create_config(array[i], configs); |
| 465 } | 475 } |
| 466 } | 476 } |
| 467 | 477 |
| 468 // If bench is enabled for config, returns a Target* for it, otherwise nullptr. | 478 // If bench is enabled for config, returns a Target* for it, otherwise nullptr. |
| 469 static Target* is_enabled(Benchmark* bench, const Config& config) { | 479 static Target* is_enabled(Benchmark* bench, const Config& config) { |
| 470 if (!bench->isSuitableFor(config.backend)) { | 480 if (!bench->isSuitableFor(config.backend)) { |
| 471 return nullptr; | 481 return nullptr; |
| 472 } | 482 } |
| 473 | 483 |
| 474 SkImageInfo info = SkImageInfo::Make(bench->getSize().fX, bench->getSize().f
Y, | 484 SkImageInfo info = SkImageInfo::Make(bench->getSize().fX, bench->getSize().f
Y, |
| 475 config.color, config.alpha); | 485 config.color, config.alpha, config.prof
ile); |
| 476 | 486 |
| 477 Target* target = nullptr; | 487 Target* target = nullptr; |
| 478 | 488 |
| 479 switch (config.backend) { | 489 switch (config.backend) { |
| 480 #if SK_SUPPORT_GPU | 490 #if SK_SUPPORT_GPU |
| 481 case Benchmark::kGPU_Backend: | 491 case Benchmark::kGPU_Backend: |
| 482 target = new GPUTarget(config); | 492 target = new GPUTarget(config); |
| 483 break; | 493 break; |
| 484 #endif | 494 #endif |
| 485 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 495 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 | 1286 |
| 1277 return 0; | 1287 return 0; |
| 1278 } | 1288 } |
| 1279 | 1289 |
| 1280 #if !defined SK_BUILD_FOR_IOS | 1290 #if !defined SK_BUILD_FOR_IOS |
| 1281 int main(int argc, char** argv) { | 1291 int main(int argc, char** argv) { |
| 1282 SkCommandLineFlags::Parse(argc, argv); | 1292 SkCommandLineFlags::Parse(argc, argv); |
| 1283 return nanobench_main(); | 1293 return nanobench_main(); |
| 1284 } | 1294 } |
| 1285 #endif | 1295 #endif |
| OLD | NEW |