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