| 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" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 } | 270 } |
| 271 | 271 |
| 272 struct Config { | 272 struct Config { |
| 273 const char* name; | 273 const char* name; |
| 274 Benchmark::Backend backend; | 274 Benchmark::Backend backend; |
| 275 SkColorType color; | 275 SkColorType color; |
| 276 SkAlphaType alpha; | 276 SkAlphaType alpha; |
| 277 int samples; | 277 int samples; |
| 278 #if SK_SUPPORT_GPU | 278 #if SK_SUPPORT_GPU |
| 279 GrContextFactory::GLContextType ctxType; | 279 GrContextFactory::GLContextType ctxType; |
| 280 bool useDFText; | |
| 281 #else | 280 #else |
| 282 int bogusInt; | 281 int bogusInt; |
| 283 bool bogusBool; | |
| 284 #endif | 282 #endif |
| 285 }; | 283 }; |
| 286 | 284 |
| 287 struct Target { | 285 struct Target { |
| 288 explicit Target(const Config& c) : config(c) {} | 286 explicit Target(const Config& c) : config(c) {} |
| 289 const Config config; | 287 const Config config; |
| 290 SkAutoTDelete<SkSurface> surface; | 288 SkAutoTDelete<SkSurface> surface; |
| 291 #if SK_SUPPORT_GPU | 289 #if SK_SUPPORT_GPU |
| 292 SkGLContext* gl; | 290 SkGLContext* gl; |
| 293 #endif | 291 #endif |
| (...skipping 22 matching lines...) Expand all Loading... |
| 316 #endif | 314 #endif |
| 317 | 315 |
| 318 #if SK_SUPPORT_GPU | 316 #if SK_SUPPORT_GPU |
| 319 #define kBogusGLContextType GrContextFactory::kNative_GLContextType | 317 #define kBogusGLContextType GrContextFactory::kNative_GLContextType |
| 320 #else | 318 #else |
| 321 #define kBogusGLContextType 0 | 319 #define kBogusGLContextType 0 |
| 322 #endif | 320 #endif |
| 323 | 321 |
| 324 // Append all configs that are enabled and supported. | 322 // Append all configs that are enabled and supported. |
| 325 static void create_configs(SkTDArray<Config>* configs) { | 323 static void create_configs(SkTDArray<Config>* configs) { |
| 326 #define CPU_CONFIG(name, backend, color, alpha) \ | 324 #define CPU_CONFIG(name, backend, color, alpha)
\ |
| 327 if (is_cpu_config_allowed(#name)) { \ | 325 if (is_cpu_config_allowed(#name)) {
\ |
| 328 Config config = { #name, Benchmark::backend, color, alpha, 0, \ | 326 Config config = { #name, Benchmark::backend, color, alpha, 0, kBogus
GLContextType }; \ |
| 329 kBogusGLContextType, false }; \ | 327 configs->push(config);
\ |
| 330 configs->push(config); \ | |
| 331 } | 328 } |
| 332 | 329 |
| 333 if (FLAGS_cpu) { | 330 if (FLAGS_cpu) { |
| 334 CPU_CONFIG(nonrendering, kNonRendering_Backend, kUnknown_SkColorType, kU
npremul_SkAlphaType) | 331 CPU_CONFIG(nonrendering, kNonRendering_Backend, kUnknown_SkColorType, kU
npremul_SkAlphaType) |
| 335 CPU_CONFIG(8888, kRaster_Backend, kN32_SkColorType, kPremul_SkAlphaType) | 332 CPU_CONFIG(8888, kRaster_Backend, kN32_SkColorType, kPremul_SkAlphaType) |
| 336 CPU_CONFIG(565, kRaster_Backend, kRGB_565_SkColorType, kOpaque_SkAlphaTy
pe) | 333 CPU_CONFIG(565, kRaster_Backend, kRGB_565_SkColorType, kOpaque_SkAlphaTy
pe) |
| 337 } | 334 } |
| 338 | 335 |
| 339 #if SK_SUPPORT_GPU | 336 #if SK_SUPPORT_GPU |
| 340 #define GPU_CONFIG(name, ctxType, samples, useDFText)
\ | 337 #define GPU_CONFIG(name, ctxType, samples)
\ |
| 341 if (is_gpu_config_allowed(#name, GrContextFactory::ctxType, samples)) {
\ | 338 if (is_gpu_config_allowed(#name, GrContextFactory::ctxType, samples)) {
\ |
| 342 Config config = {
\ | 339 Config config = {
\ |
| 343 #name,
\ | 340 #name,
\ |
| 344 Benchmark::kGPU_Backend,
\ | 341 Benchmark::kGPU_Backend,
\ |
| 345 kN32_SkColorType,
\ | 342 kN32_SkColorType,
\ |
| 346 kPremul_SkAlphaType,
\ | 343 kPremul_SkAlphaType,
\ |
| 347 samples,
\ | 344 samples,
\ |
| 348 GrContextFactory::ctxType,
\ | 345 GrContextFactory::ctxType };
\ |
| 349 useDFText };
\ | |
| 350 configs->push(config);
\ | 346 configs->push(config);
\ |
| 351 } | 347 } |
| 352 | 348 |
| 353 if (FLAGS_gpu) { | 349 if (FLAGS_gpu) { |
| 354 GPU_CONFIG(gpu, kNative_GLContextType, 0, false) | 350 GPU_CONFIG(gpu, kNative_GLContextType, 0) |
| 355 GPU_CONFIG(msaa4, kNative_GLContextType, 4, false) | 351 GPU_CONFIG(msaa4, kNative_GLContextType, 4) |
| 356 GPU_CONFIG(msaa16, kNative_GLContextType, 16, false) | 352 GPU_CONFIG(msaa16, kNative_GLContextType, 16) |
| 357 GPU_CONFIG(nvprmsaa4, kNVPR_GLContextType, 4, false) | 353 GPU_CONFIG(nvprmsaa4, kNVPR_GLContextType, 4) |
| 358 GPU_CONFIG(nvprmsaa16, kNVPR_GLContextType, 16, false) | 354 GPU_CONFIG(nvprmsaa16, kNVPR_GLContextType, 16) |
| 359 GPU_CONFIG(gpudft, kNative_GLContextType, 0, true) | 355 GPU_CONFIG(debug, kDebug_GLContextType, 0) |
| 360 GPU_CONFIG(debug, kDebug_GLContextType, 0, false) | 356 GPU_CONFIG(nullgpu, kNull_GLContextType, 0) |
| 361 GPU_CONFIG(nullgpu, kNull_GLContextType, 0, false) | |
| 362 #ifdef SK_ANGLE | 357 #ifdef SK_ANGLE |
| 363 GPU_CONFIG(angle, kANGLE_GLContextType, 0) | 358 GPU_CONFIG(angle, kANGLE_GLContextType, 0) |
| 364 #endif | 359 #endif |
| 365 } | 360 } |
| 366 #endif | 361 #endif |
| 367 } | 362 } |
| 368 | 363 |
| 369 // If bench is enabled for config, returns a Target* for it, otherwise NULL. | 364 // If bench is enabled for config, returns a Target* for it, otherwise NULL. |
| 370 static Target* is_enabled(Benchmark* bench, const Config& config) { | 365 static Target* is_enabled(Benchmark* bench, const Config& config) { |
| 371 if (!bench->isSuitableFor(config.backend)) { | 366 if (!bench->isSuitableFor(config.backend)) { |
| 372 return NULL; | 367 return NULL; |
| 373 } | 368 } |
| 374 | 369 |
| 375 SkImageInfo info = SkImageInfo::Make(bench->getSize().fX, bench->getSize().f
Y, | 370 SkImageInfo info = SkImageInfo::Make(bench->getSize().fX, bench->getSize().f
Y, |
| 376 config.color, config.alpha); | 371 config.color, config.alpha); |
| 377 | 372 |
| 378 Target* target = new Target(config); | 373 Target* target = new Target(config); |
| 379 | 374 |
| 380 if (Benchmark::kRaster_Backend == config.backend) { | 375 if (Benchmark::kRaster_Backend == config.backend) { |
| 381 target->surface.reset(SkSurface::NewRaster(info)); | 376 target->surface.reset(SkSurface::NewRaster(info)); |
| 382 } | 377 } |
| 383 #if SK_SUPPORT_GPU | 378 #if SK_SUPPORT_GPU |
| 384 else if (Benchmark::kGPU_Backend == config.backend) { | 379 else if (Benchmark::kGPU_Backend == config.backend) { |
| 385 uint32_t flags = config.useDFText ? SkSurfaceProps::kUseDistanceFieldFon
ts_Flag : 0; | |
| 386 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); | |
| 387 target->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(config.
ctxType), info, | 380 target->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(config.
ctxType), info, |
| 388 config.samples, &props)
); | 381 config.samples)); |
| 389 target->gl = gGrFactory->getGLContext(config.ctxType); | 382 target->gl = gGrFactory->getGLContext(config.ctxType); |
| 390 } | 383 } |
| 391 #endif | 384 #endif |
| 392 | 385 |
| 393 if (Benchmark::kNonRendering_Backend != config.backend && !target->surface.g
et()) { | 386 if (Benchmark::kNonRendering_Backend != config.backend && !target->surface.g
et()) { |
| 394 delete target; | 387 delete target; |
| 395 return NULL; | 388 return NULL; |
| 396 } | 389 } |
| 397 return target; | 390 return target; |
| 398 } | 391 } |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 | 738 |
| 746 return 0; | 739 return 0; |
| 747 } | 740 } |
| 748 | 741 |
| 749 #if !defined SK_BUILD_FOR_IOS | 742 #if !defined SK_BUILD_FOR_IOS |
| 750 int main(int argc, char** argv) { | 743 int main(int argc, char** argv) { |
| 751 SkCommandLineFlags::Parse(argc, argv); | 744 SkCommandLineFlags::Parse(argc, argv); |
| 752 return nanobench_main(); | 745 return nanobench_main(); |
| 753 } | 746 } |
| 754 #endif | 747 #endif |
| OLD | NEW |