OLD | NEW |
1 #include "DMWriteTask.h" | 1 #include "DMWriteTask.h" |
2 | 2 |
3 #include "DMUtil.h" | 3 #include "DMUtil.h" |
4 #include "SkColorPriv.h" | 4 #include "SkColorPriv.h" |
5 #include "SkCommonFlags.h" | 5 #include "SkCommonFlags.h" |
6 #include "SkImageEncoder.h" | 6 #include "SkImageEncoder.h" |
7 #include "SkMallocPixelRef.h" | 7 #include "SkMallocPixelRef.h" |
8 #include "SkStream.h" | 8 #include "SkStream.h" |
9 #include "SkString.h" | 9 #include "SkString.h" |
10 | 10 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 void WriteTask::draw() { | 130 void WriteTask::draw() { |
131 SkString dir(FLAGS_writePath[0]); | 131 SkString dir(FLAGS_writePath[0]); |
132 #if SK_BUILD_FOR_IOS | 132 #if SK_BUILD_FOR_IOS |
133 if (dir.equals("@")) { | 133 if (dir.equals("@")) { |
134 dir.set(FLAGS_resourcePath[0]); | 134 dir.set(FLAGS_resourcePath[0]); |
135 } | 135 } |
136 #endif | 136 #endif |
137 this->makeDirOrFail(dir); | 137 this->makeDirOrFail(dir); |
138 for (int i = 0; i < fSuffixes.count(); i++) { | 138 for (int i = 0; i < fSuffixes.count(); i++) { |
139 dir = SkOSPath::SkPathJoin(dir.c_str(), fSuffixes[i].c_str()); | 139 dir = SkOSPath::Join(dir.c_str(), fSuffixes[i].c_str()); |
140 this->makeDirOrFail(dir); | 140 this->makeDirOrFail(dir); |
141 } | 141 } |
142 | 142 |
143 SkString path = SkOSPath::SkPathJoin(dir.c_str(), fGmName.c_str()); | 143 SkString path = SkOSPath::Join(dir.c_str(), fGmName.c_str()); |
144 path.append(fExtension); | 144 path.append(fExtension); |
145 | 145 |
146 const bool ok = fData.get() ? save_data_to_file(fData, path.c_str()) | 146 const bool ok = fData.get() ? save_data_to_file(fData, path.c_str()) |
147 : PngAndRaw::Encode(fBitmap, path.c_str()); | 147 : PngAndRaw::Encode(fBitmap, path.c_str()); |
148 if (!ok) { | 148 if (!ok) { |
149 this->fail(); | 149 this->fail(); |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 SkString WriteTask::name() const { | 153 SkString WriteTask::name() const { |
(...skipping 12 matching lines...) Expand all Loading... |
166 static SkString path_to_expected_image(const char* root, const Task& task) { | 166 static SkString path_to_expected_image(const char* root, const Task& task) { |
167 SkString filename = task.name(); | 167 SkString filename = task.name(); |
168 | 168 |
169 // We know that all names passed in here belong to top-level Tasks, which ha
ve a single suffix | 169 // We know that all names passed in here belong to top-level Tasks, which ha
ve a single suffix |
170 // (8888, 565, gpu, etc.) indicating what subdirectory to look in. | 170 // (8888, 565, gpu, etc.) indicating what subdirectory to look in. |
171 SkTArray<SkString> suffixes; | 171 SkTArray<SkString> suffixes; |
172 const int suffixLength = split_suffixes(1, filename.c_str(), &suffixes); | 172 const int suffixLength = split_suffixes(1, filename.c_str(), &suffixes); |
173 SkASSERT(1 == suffixes.count()); | 173 SkASSERT(1 == suffixes.count()); |
174 | 174 |
175 // We'll look in root/suffix for images. | 175 // We'll look in root/suffix for images. |
176 const SkString dir = SkOSPath::SkPathJoin(root, suffixes[0].c_str()); | 176 const SkString dir = SkOSPath::Join(root, suffixes[0].c_str()); |
177 | 177 |
178 // Remove the suffix and tack on a .png. | 178 // Remove the suffix and tack on a .png. |
179 filename.remove(filename.size() - suffixLength, suffixLength); | 179 filename.remove(filename.size() - suffixLength, suffixLength); |
180 filename.append(".png"); | 180 filename.append(".png"); |
181 | 181 |
182 return SkOSPath::SkPathJoin(dir.c_str(), filename.c_str()); | 182 return SkOSPath::Join(dir.c_str(), filename.c_str()); |
183 } | 183 } |
184 | 184 |
185 bool WriteTask::Expectations::check(const Task& task, SkBitmap bitmap) const { | 185 bool WriteTask::Expectations::check(const Task& task, SkBitmap bitmap) const { |
186 if (!FLAGS_writePath.isEmpty() && 0 == strcmp(FLAGS_writePath[0], fRoot)) { | 186 if (!FLAGS_writePath.isEmpty() && 0 == strcmp(FLAGS_writePath[0], fRoot)) { |
187 SkDebugf("We seem to be reading and writing %s concurrently. This won't
work.\n", fRoot); | 187 SkDebugf("We seem to be reading and writing %s concurrently. This won't
work.\n", fRoot); |
188 return false; | 188 return false; |
189 } | 189 } |
190 | 190 |
191 const SkString path = path_to_expected_image(fRoot, task); | 191 const SkString path = path_to_expected_image(fRoot, task); |
192 SkBitmap expected; | 192 SkBitmap expected; |
193 if (!PngAndRaw::Decode(path.c_str(), bitmap.info(), &expected)) { | 193 if (!PngAndRaw::Decode(path.c_str(), bitmap.info(), &expected)) { |
194 return false; | 194 return false; |
195 } | 195 } |
196 | 196 |
197 return BitmapsEqual(expected, bitmap); | 197 return BitmapsEqual(expected, bitmap); |
198 } | 198 } |
199 | 199 |
200 } // namespace DM | 200 } // namespace DM |
OLD | NEW |