| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 SkDebugf("WARNING: clamping loops from %d to FLAGS_maxLoops, %d.\n", loo
ps, FLAGS_maxLoops); | 126 SkDebugf("WARNING: clamping loops from %d to FLAGS_maxLoops, %d.\n", loo
ps, FLAGS_maxLoops); |
| 127 return FLAGS_maxLoops; | 127 return FLAGS_maxLoops; |
| 128 } | 128 } |
| 129 return loops; | 129 return loops; |
| 130 } | 130 } |
| 131 | 131 |
| 132 static bool write_canvas_png(SkCanvas* canvas, const SkString& filename) { | 132 static bool write_canvas_png(SkCanvas* canvas, const SkString& filename) { |
| 133 if (filename.isEmpty()) { | 133 if (filename.isEmpty()) { |
| 134 return false; | 134 return false; |
| 135 } | 135 } |
| 136 if (kUnknown_SkColorType == canvas->imageInfo().fColorType) { | 136 if (kUnknown_SkColorType == canvas->imageInfo().colorType()) { |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 SkBitmap bmp; | 139 SkBitmap bmp; |
| 140 bmp.setInfo(canvas->imageInfo()); | 140 bmp.setInfo(canvas->imageInfo()); |
| 141 if (!canvas->readPixels(&bmp, 0, 0)) { | 141 if (!canvas->readPixels(&bmp, 0, 0)) { |
| 142 SkDebugf("Can't read canvas pixels.\n"); | 142 SkDebugf("Can't read canvas pixels.\n"); |
| 143 return false; | 143 return false; |
| 144 } | 144 } |
| 145 SkString dir = SkOSPath::Dirname(filename.c_str()); | 145 SkString dir = SkOSPath::Dirname(filename.c_str()); |
| 146 if (!sk_mkdir(dir.c_str())) { | 146 if (!sk_mkdir(dir.c_str())) { |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 } | 350 } |
| 351 #endif | 351 #endif |
| 352 } | 352 } |
| 353 | 353 |
| 354 // If bench is enabled for config, returns a Target* for it, otherwise NULL. | 354 // If bench is enabled for config, returns a Target* for it, otherwise NULL. |
| 355 static Target* is_enabled(Benchmark* bench, const Config& config) { | 355 static Target* is_enabled(Benchmark* bench, const Config& config) { |
| 356 if (!bench->isSuitableFor(config.backend)) { | 356 if (!bench->isSuitableFor(config.backend)) { |
| 357 return NULL; | 357 return NULL; |
| 358 } | 358 } |
| 359 | 359 |
| 360 SkImageInfo info; | 360 SkImageInfo info = SkImageInfo::Make(bench->getSize().fX, bench->getSize().f
Y, |
| 361 info.fAlphaType = config.alpha; | 361 config.color, config.alpha); |
| 362 info.fColorType = config.color; | |
| 363 info.fWidth = bench->getSize().fX; | |
| 364 info.fHeight = bench->getSize().fY; | |
| 365 | 362 |
| 366 Target* target = new Target(config); | 363 Target* target = new Target(config); |
| 367 | 364 |
| 368 if (Benchmark::kRaster_Backend == config.backend) { | 365 if (Benchmark::kRaster_Backend == config.backend) { |
| 369 target->surface.reset(SkSurface::NewRaster(info)); | 366 target->surface.reset(SkSurface::NewRaster(info)); |
| 370 } | 367 } |
| 371 #if SK_SUPPORT_GPU | 368 #if SK_SUPPORT_GPU |
| 372 else if (Benchmark::kGPU_Backend == config.backend) { | 369 else if (Benchmark::kGPU_Backend == config.backend) { |
| 373 target->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(config.
ctxType), info, | 370 target->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(config.
ctxType), info, |
| 374 config.samples)); | 371 config.samples)); |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 | 690 |
| 694 return 0; | 691 return 0; |
| 695 } | 692 } |
| 696 | 693 |
| 697 #if !defined SK_BUILD_FOR_IOS | 694 #if !defined SK_BUILD_FOR_IOS |
| 698 int main(int argc, char** argv) { | 695 int main(int argc, char** argv) { |
| 699 SkCommandLineFlags::Parse(argc, argv); | 696 SkCommandLineFlags::Parse(argc, argv); |
| 700 return nanobench_main(); | 697 return nanobench_main(); |
| 701 } | 698 } |
| 702 #endif | 699 #endif |
| OLD | NEW |