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 15 matching lines...) Expand all Loading... |
26 // recording, and this should take ~20 seconds to run. | 26 // recording, and this should take ~20 seconds to run. |
27 | 27 |
28 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record
."); | 28 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record
."); |
29 DEFINE_int32(loops, 900, "Number of times to re-record each SKP."); | 29 DEFINE_int32(loops, 900, "Number of times to re-record each SKP."); |
30 DEFINE_int32(flags, SkPicture::kUsePathBoundsForClip_RecordingFlag, "RecordingFl
ags to use."); | 30 DEFINE_int32(flags, SkPicture::kUsePathBoundsForClip_RecordingFlag, "RecordingFl
ags to use."); |
31 DEFINE_bool(endRecording, true, "If false, don't time SkPicture::endRecording()"
); | 31 DEFINE_bool(endRecording, true, "If false, don't time SkPicture::endRecording()"
); |
32 DEFINE_int32(nullSize, 1000, "Pretend dimension of null source picture."); | 32 DEFINE_int32(nullSize, 1000, "Pretend dimension of null source picture."); |
33 DEFINE_int32(tileGridSize, 512, "Set the tile grid size. Has no effect if bbh is
not set to tilegrid."); | 33 DEFINE_int32(tileGridSize, 512, "Set the tile grid size. Has no effect if bbh is
not set to tilegrid."); |
34 DEFINE_string(bbh, "", "Turn on the bbh and select the type, one of rtree, tileg
rid, quadtree"); | 34 DEFINE_string(bbh, "", "Turn on the bbh and select the type, one of rtree, tileg
rid, quadtree"); |
35 DEFINE_bool(skr, false, "Record SKR instead of SKP."); | 35 DEFINE_bool(skr, false, "Record SKR instead of SKP."); |
| 36 DEFINE_string(match, "", "The usual filters on file names of SKPs to bench."); |
36 | 37 |
37 static SkBBHFactory* parse_FLAGS_bbh() { | 38 static SkBBHFactory* parse_FLAGS_bbh() { |
38 if (FLAGS_bbh.isEmpty()) { | 39 if (FLAGS_bbh.isEmpty()) { |
39 return NULL; | 40 return NULL; |
40 } | 41 } |
41 | 42 |
42 if (FLAGS_bbh.contains("rtree")) { | 43 if (FLAGS_bbh.contains("rtree")) { |
43 return SkNEW(SkRTreeFactory); | 44 return SkNEW(SkRTreeFactory); |
44 } | 45 } |
45 if (FLAGS_bbh.contains("tilegrid")) { | 46 if (FLAGS_bbh.contains("tilegrid")) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 SkAutoTDelete<SkBBHFactory> bbhFactory(parse_FLAGS_bbh()); | 100 SkAutoTDelete<SkBBHFactory> bbhFactory(parse_FLAGS_bbh()); |
100 bench_record(NULL, "NULL", bbhFactory.get()); | 101 bench_record(NULL, "NULL", bbhFactory.get()); |
101 if (FLAGS_skps.isEmpty()) { | 102 if (FLAGS_skps.isEmpty()) { |
102 return 0; | 103 return 0; |
103 } | 104 } |
104 | 105 |
105 SkOSFile::Iter it(FLAGS_skps[0], ".skp"); | 106 SkOSFile::Iter it(FLAGS_skps[0], ".skp"); |
106 SkString filename; | 107 SkString filename; |
107 bool failed = false; | 108 bool failed = false; |
108 while (it.next(&filename)) { | 109 while (it.next(&filename)) { |
| 110 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, filename.c_str())) { |
| 111 continue; |
| 112 } |
| 113 |
109 const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str
()); | 114 const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str
()); |
110 | 115 |
111 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str())); | 116 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str())); |
112 if (!stream) { | 117 if (!stream) { |
113 SkDebugf("Could not read %s.\n", path.c_str()); | 118 SkDebugf("Could not read %s.\n", path.c_str()); |
114 failed = true; | 119 failed = true; |
115 continue; | 120 continue; |
116 } | 121 } |
117 SkAutoTUnref<SkPicture> src( | 122 SkAutoTUnref<SkPicture> src( |
118 SkPicture::CreateFromStream(stream, sk_tools::LazyDecodeBitmap)); | 123 SkPicture::CreateFromStream(stream, sk_tools::LazyDecodeBitmap)); |
119 if (!src) { | 124 if (!src) { |
120 SkDebugf("Could not read %s as an SkPicture.\n", path.c_str()); | 125 SkDebugf("Could not read %s as an SkPicture.\n", path.c_str()); |
121 failed = true; | 126 failed = true; |
122 continue; | 127 continue; |
123 } | 128 } |
124 bench_record(src, filename.c_str(), bbhFactory.get()); | 129 bench_record(src, filename.c_str(), bbhFactory.get()); |
125 } | 130 } |
126 return failed ? 1 : 0; | 131 return failed ? 1 : 0; |
127 } | 132 } |
128 | 133 |
129 #if !defined SK_BUILD_FOR_IOS | 134 #if !defined SK_BUILD_FOR_IOS |
130 int main(int argc, char * const argv[]) { | 135 int main(int argc, char * const argv[]) { |
131 return tool_main(argc, (char**) argv); | 136 return tool_main(argc, (char**) argv); |
132 } | 137 } |
133 #endif | 138 #endif |
OLD | NEW |