| 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 "SkCommandLineFlags.h" | 8 #include "SkCommandLineFlags.h" |
| 9 #include "SkForceLinking.h" | 9 #include "SkForceLinking.h" |
| 10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 DEFINE_bool(skr, false, "Play via SkRecord instead of SkPicture."); | 23 DEFINE_bool(skr, false, "Play via SkRecord instead of SkPicture."); |
| 24 DEFINE_int32(tile, 1000000000, "Simulated tile size."); | 24 DEFINE_int32(tile, 1000000000, "Simulated tile size."); |
| 25 | 25 |
| 26 static void bench(SkPMColor* scratch, SkPicture& src, const char* name) { | 26 static void bench(SkPMColor* scratch, SkPicture& src, const char* name) { |
| 27 SkRecord record; | 27 SkRecord record; |
| 28 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, src.width(), src.h
eight()); | 28 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, src.width(), src.h
eight()); |
| 29 src.draw(&recorder); | 29 src.draw(&recorder); |
| 30 | 30 |
| 31 SkAutoTDelete<SkCanvas> canvas( | 31 SkAutoTDelete<SkCanvas> canvas( |
| 32 SkCanvas::NewRasterDirectN32(src.width(), src.height(), scratch, 0)); | 32 SkCanvas::NewRasterDirectN32(src.width(), src.height(), scratch, 0)); |
| 33 canvas->clipRect(SkRect::MakeWH(FLAGS_tile, FLAGS_tile)); | 33 canvas->clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), SkIntToScalar(FLA
GS_tile))); |
| 34 | 34 |
| 35 const SkMSec start = SkTime::GetMSecs(); | 35 const SkMSec start = SkTime::GetMSecs(); |
| 36 for (int i = 0; i < FLAGS_loops; i++) { | 36 for (int i = 0; i < FLAGS_loops; i++) { |
| 37 if (FLAGS_skr) { | 37 if (FLAGS_skr) { |
| 38 SkRecordDraw(record, canvas.get()); | 38 SkRecordDraw(record, canvas.get()); |
| 39 } else { | 39 } else { |
| 40 src.draw(canvas.get()); | 40 src.draw(canvas.get()); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 bench(scratch.get(), *src, filename.c_str()); | 84 bench(scratch.get(), *src, filename.c_str()); |
| 85 } | 85 } |
| 86 return failed ? 1 : 0; | 86 return failed ? 1 : 0; |
| 87 } | 87 } |
| 88 | 88 |
| 89 #if !defined SK_BUILD_FOR_IOS | 89 #if !defined SK_BUILD_FOR_IOS |
| 90 int main(int argc, char * const argv[]) { | 90 int main(int argc, char * const argv[]) { |
| 91 return tool_main(argc, (char**) argv); | 91 return tool_main(argc, (char**) argv); |
| 92 } | 92 } |
| 93 #endif | 93 #endif |
| OLD | NEW |