| 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 "BenchTimer.h" | 8 #include "BenchTimer.h" |
| 9 #include "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
| 10 #include "SkForceLinking.h" | 10 #include "SkForceLinking.h" |
| 11 #include "SkGraphics.h" | 11 #include "SkGraphics.h" |
| 12 #include "SkOSFile.h" | 12 #include "SkOSFile.h" |
| 13 #include "SkPicture.h" | 13 #include "SkPicture.h" |
| 14 #include "SkPictureRecorder.h" | 14 #include "SkPictureRecorder.h" |
| 15 #include "SkRecording.h" | 15 #include "SkRecording.h" |
| 16 #include "SkStream.h" | 16 #include "SkStream.h" |
| 17 #include "SkString.h" | 17 #include "SkString.h" |
| 18 #include "LazyDecodeBitmap.h" | 18 #include "LazyDecodeBitmap.h" |
| 19 | 19 |
| 20 __SK_FORCE_IMAGE_DECODER_LINKING; | 20 __SK_FORCE_IMAGE_DECODER_LINKING; |
| 21 | 21 |
| 22 // Just reading all the SKPs takes about 2 seconds for me, which is the same as
about 100 loops of | 22 // Just reading all the SKPs takes about 2 seconds for me, which is the same as
about 100 loops of |
| 23 // rerecording all the SKPs. So we default to --loops=900, which makes ~90% of
our time spent in | 23 // rerecording all the SKPs. So we default to --loops=900, which makes ~90% of
our time spent in |
| 24 // recording, and this should take ~20 seconds to run. | 24 // recording, and this should take ~20 seconds to run. |
| 25 | 25 |
| 26 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record
."); | 26 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record
."); |
| 27 DEFINE_int32(loops, 900, "Number of times to re-record each SKP."); | 27 DEFINE_int32(loops, 900, "Number of times to re-record each SKP."); |
| 28 DEFINE_int32(flags, 0, "RecordingFlags to use."); | |
| 29 DEFINE_bool(endRecording, true, "If false, don't time SkPicture::endRecording()"
); | 28 DEFINE_bool(endRecording, true, "If false, don't time SkPicture::endRecording()"
); |
| 30 DEFINE_int32(nullSize, 1000, "Pretend dimension of null source picture."); | 29 DEFINE_int32(nullSize, 1000, "Pretend dimension of null source picture."); |
| 31 DEFINE_int32(tileGridSize, 512, "Set the tile grid size. Has no effect if bbh is
not set to tilegrid."); | 30 DEFINE_int32(tileGridSize, 512, "Set the tile grid size. Has no effect if bbh is
not set to tilegrid."); |
| 32 DEFINE_string(bbh, "", "Turn on the bbh and select the type, one of rtree, tileg
rid, quadtree"); | 31 DEFINE_string(bbh, "", "Turn on the bbh and select the type, one of rtree, tileg
rid, quadtree"); |
| 33 DEFINE_bool(skr, false, "Record SKR instead of SKP."); | 32 DEFINE_bool(skr, false, "Record SKR instead of SKP."); |
| 34 DEFINE_string(match, "", "The usual filters on file names of SKPs to bench."); | 33 DEFINE_string(match, "", "The usual filters on file names of SKPs to bench."); |
| 35 DEFINE_string(timescale, "us", "Print times in ms, us, or ns"); | 34 DEFINE_string(timescale, "us", "Print times in ms, us, or ns"); |
| 36 | 35 |
| 37 static double scale_time(double ms) { | 36 static double scale_time(double ms) { |
| 38 if (FLAGS_timescale.contains("us")) ms *= 1000; | 37 if (FLAGS_timescale.contains("us")) ms *= 1000; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 for (int i = 0; i < FLAGS_loops; i++) { | 70 for (int i = 0; i < FLAGS_loops; i++) { |
| 72 if (FLAGS_skr) { | 71 if (FLAGS_skr) { |
| 73 EXPERIMENTAL::SkRecording recording(width, height); | 72 EXPERIMENTAL::SkRecording recording(width, height); |
| 74 if (NULL != src) { | 73 if (NULL != src) { |
| 75 src->draw(recording.canvas()); | 74 src->draw(recording.canvas()); |
| 76 } | 75 } |
| 77 // Release and delete the SkPlayback so that recording optimizes its
SkRecord. | 76 // Release and delete the SkPlayback so that recording optimizes its
SkRecord. |
| 78 SkDELETE(recording.releasePlayback()); | 77 SkDELETE(recording.releasePlayback()); |
| 79 } else { | 78 } else { |
| 80 SkPictureRecorder recorder; | 79 SkPictureRecorder recorder; |
| 81 SkCanvas* canvas = recorder.beginRecording(width, height, bbhFactory
, FLAGS_flags); | 80 SkCanvas* canvas = recorder.beginRecording(width, height, bbhFactory
); |
| 82 if (NULL != src) { | 81 if (NULL != src) { |
| 83 src->draw(canvas); | 82 src->draw(canvas); |
| 84 } | 83 } |
| 85 if (FLAGS_endRecording) { | 84 if (FLAGS_endRecording) { |
| 86 SkAutoTUnref<SkPicture> dst(recorder.endRecording()); | 85 SkAutoTUnref<SkPicture> dst(recorder.endRecording()); |
| 87 } | 86 } |
| 88 } | 87 } |
| 89 } | 88 } |
| 90 timer.end(); | 89 timer.end(); |
| 91 | 90 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 bench_record(src, filename.c_str(), bbhFactory.get()); | 134 bench_record(src, filename.c_str(), bbhFactory.get()); |
| 136 } | 135 } |
| 137 return failed ? 1 : 0; | 136 return failed ? 1 : 0; |
| 138 } | 137 } |
| 139 | 138 |
| 140 #if !defined SK_BUILD_FOR_IOS | 139 #if !defined SK_BUILD_FOR_IOS |
| 141 int main(int argc, char * const argv[]) { | 140 int main(int argc, char * const argv[]) { |
| 142 return tool_main(argc, (char**) argv); | 141 return tool_main(argc, (char**) argv); |
| 143 } | 142 } |
| 144 #endif | 143 #endif |
| OLD | NEW |