OLD | NEW |
1 #include "DMWriteTask.h" | 1 #include "DMWriteTask.h" |
2 | 2 |
3 #include "DMJsonWriter.h" | 3 #include "DMJsonWriter.h" |
4 #include "DMUtil.h" | 4 #include "DMUtil.h" |
5 #include "SkColorPriv.h" | 5 #include "SkColorPriv.h" |
6 #include "SkCommonFlags.h" | 6 #include "SkCommonFlags.h" |
7 #include "SkData.h" | 7 #include "SkData.h" |
8 #include "SkImageEncoder.h" | 8 #include "SkImageEncoder.h" |
9 #include "SkMD5.h" | 9 #include "SkMD5.h" |
10 #include "SkMallocPixelRef.h" | 10 #include "SkMallocPixelRef.h" |
11 #include "SkOSFile.h" | 11 #include "SkOSFile.h" |
12 #include "SkStream.h" | 12 #include "SkStream.h" |
13 #include "SkString.h" | 13 #include "SkString.h" |
14 | 14 |
15 DEFINE_bool(nameByHash, false, "If true, write .../hash.png instead of .../mode/
config/name.png"); | 15 DEFINE_bool(nameByHash, false, "If true, write .../hash.png instead of .../mode/
config/name.png"); |
16 | 16 |
17 namespace DM { | 17 namespace DM { |
18 | 18 |
19 // Splits off the last N suffixes of name (splitting on _) and appends them to o
ut. | 19 // Splits off the last N suffixes of name (splitting on _) and appends them to o
ut. |
20 // Returns the total number of characters consumed. | 20 // Returns the total number of characters consumed. |
21 static int split_suffixes(int N, const char* name, SkTArray<SkString>* out) { | 21 static int split_suffixes(int N, const char* name, SkTArray<SkString>* out) { |
22 SkTArray<SkString> split; | 22 SkTArray<SkString> split; |
23 SkStrSplit(name, "_", &split); | 23 SkStrSplit(name, "_", &split); |
24 int consumed = 0; | 24 int consumed = 0; |
25 for (int i = 0; i < N; i++) { | 25 for (int i = 0; i < N; i++) { |
26 // We're splitting off suffixes from the back to front. | 26 // We're splitting off suffixes from the back to front. |
27 out->push_back(split[split.count()-i-1]); | 27 out->push_back(split[split.count()-i-1]); |
28 consumed += out->back().size() + 1; // Add one for the _. | 28 consumed += SkToInt(out->back().size() + 1); // Add one for the _. |
29 } | 29 } |
30 return consumed; | 30 return consumed; |
31 } | 31 } |
32 | 32 |
33 inline static SkString find_base_name(const Task& parent, SkTArray<SkString>* su
ffixList) { | 33 inline static SkString find_base_name(const Task& parent, SkTArray<SkString>* su
ffixList) { |
34 const int suffixes = parent.depth() + 1; | 34 const int suffixes = parent.depth() + 1; |
35 const SkString& name = parent.name(); | 35 const SkString& name = parent.name(); |
36 const int totalSuffixLength = split_suffixes(suffixes, name.c_str(), suffixL
ist); | 36 const int totalSuffixLength = split_suffixes(suffixes, name.c_str(), suffixL
ist); |
37 return SkString(name.c_str(), name.size() - totalSuffixLength); | 37 return SkString(name.c_str(), name.size() - totalSuffixLength); |
38 } | 38 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 166 } |
167 name.append(fBaseName.c_str()); | 167 name.append(fBaseName.c_str()); |
168 return name; | 168 return name; |
169 } | 169 } |
170 | 170 |
171 bool WriteTask::shouldSkip() const { | 171 bool WriteTask::shouldSkip() const { |
172 return FLAGS_writePath.isEmpty(); | 172 return FLAGS_writePath.isEmpty(); |
173 } | 173 } |
174 | 174 |
175 } // namespace DM | 175 } // namespace DM |
OLD | NEW |