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" |
11 #include "SkOSFile.h" | 11 #include "SkOSFile.h" |
12 #include "SkPicture.h" | 12 #include "SkPicture.h" |
13 #include "SkQuadTreePicture.h" | 13 #include "SkQuadTreePicture.h" |
14 #include "SkStream.h" | 14 #include "SkStream.h" |
15 #include "SkString.h" | 15 #include "SkString.h" |
16 #include "SkTileGridPicture.h" | 16 #include "SkTileGridPicture.h" |
17 #include "SkTime.h" | 17 #include "SkTime.h" |
| 18 #include "LazyDecodeBitmap.h" |
18 | 19 |
19 __SK_FORCE_IMAGE_DECODER_LINKING; | 20 __SK_FORCE_IMAGE_DECODER_LINKING; |
20 | 21 |
21 // 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 |
22 // 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 |
23 // recording, and this should take ~20 seconds to run. | 24 // recording, and this should take ~20 seconds to run. |
24 | 25 |
25 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
."); |
26 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."); |
27 DEFINE_int32(flags, SkPicture::kUsePathBoundsForClip_RecordingFlag, "RecordingFl
ags to use."); | 28 DEFINE_int32(flags, SkPicture::kUsePathBoundsForClip_RecordingFlag, "RecordingFl
ags to use."); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 bool failed = false; | 110 bool failed = false; |
110 while (it.next(&filename)) { | 111 while (it.next(&filename)) { |
111 const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str
()); | 112 const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str
()); |
112 | 113 |
113 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str())); | 114 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str())); |
114 if (!stream) { | 115 if (!stream) { |
115 SkDebugf("Could not read %s.\n", path.c_str()); | 116 SkDebugf("Could not read %s.\n", path.c_str()); |
116 failed = true; | 117 failed = true; |
117 continue; | 118 continue; |
118 } | 119 } |
119 SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream)); | 120 SkAutoTUnref<SkPicture> src( |
| 121 SkPicture::CreateFromStream(stream, sk_tools::LazyDecodeBitmap)); |
120 if (!src) { | 122 if (!src) { |
121 SkDebugf("Could not read %s as an SkPicture.\n", path.c_str()); | 123 SkDebugf("Could not read %s as an SkPicture.\n", path.c_str()); |
122 failed = true; | 124 failed = true; |
123 continue; | 125 continue; |
124 } | 126 } |
125 bench_record(src, filename.c_str(), pictureFactory); | 127 bench_record(src, filename.c_str(), pictureFactory); |
126 } | 128 } |
127 return failed ? 1 : 0; | 129 return failed ? 1 : 0; |
128 } | 130 } |
129 | 131 |
130 #if !defined SK_BUILD_FOR_IOS | 132 #if !defined SK_BUILD_FOR_IOS |
131 int main(int argc, char * const argv[]) { | 133 int main(int argc, char * const argv[]) { |
132 return tool_main(argc, (char**) argv); | 134 return tool_main(argc, (char**) argv); |
133 } | 135 } |
134 #endif | 136 #endif |
OLD | NEW |