OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkImageDecoder.h" | 9 #include "SkImageDecoder.h" |
10 #include "SkOSFile.h" | 10 #include "SkOSFile.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 const char* testFilename = testEntries [entryIndex].c_str(); | 150 const char* testFilename = testEntries [entryIndex].c_str(); |
151 | 151 |
152 this->addDiff(baselineFilename, testFilename); | 152 this->addDiff(baselineFilename, testFilename); |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 void SkDiffContext::outputRecords(SkWStream& stream, bool useJSONP) { | 156 void SkDiffContext::outputRecords(SkWStream& stream, bool useJSONP) { |
157 DiffRecord* currentRecord = fRecords; | 157 DiffRecord* currentRecord = fRecords; |
158 if (useJSONP) { | 158 if (useJSONP) { |
159 stream.writeText("var SkPDiffRecords = {\n"); | 159 stream.writeText("var SkPDiffRecords = {\n"); |
160 } | 160 } else { |
161 else | |
162 { | |
163 stream.writeText("{\n"); | 161 stream.writeText("{\n"); |
164 } | 162 } |
165 stream.writeText(" \"records\": [\n"); | 163 stream.writeText(" \"records\": [\n"); |
166 while (NULL != currentRecord) { | 164 while (NULL != currentRecord) { |
167 stream.writeText(" {\n"); | 165 stream.writeText(" {\n"); |
168 | 166 |
169 stream.writeText(" \"baselinePath\": \""); | 167 stream.writeText(" \"baselinePath\": \""); |
170 stream.writeText(currentRecord->fBaselinePath.c_str()); | 168 stream.writeText(currentRecord->fBaselinePath.c_str()); |
171 stream.writeText("\",\n"); | 169 stream.writeText("\",\n"); |
172 | 170 |
(...skipping 18 matching lines...) Expand all Loading... |
191 for (int poiIndex = 0; poiIndex < data.fPointsOfInterest.cou
nt() && | 189 for (int poiIndex = 0; poiIndex < data.fPointsOfInterest.cou
nt() && |
192 poiIndex < kMaxPOI; poiIndex++) { | 190 poiIndex < kMaxPOI; poiIndex++) { |
193 SkIPoint poi = data.fPointsOfInterest[poiIndex]; | 191 SkIPoint poi = data.fPointsOfInterest[poiIndex]; |
194 stream.writeText(" ["); | 192 stream.writeText(" ["); |
195 stream.writeDecAsText(poi.x()); | 193 stream.writeDecAsText(poi.x()); |
196 stream.writeText(","); | 194 stream.writeText(","); |
197 stream.writeDecAsText(poi.y()); | 195 stream.writeDecAsText(poi.y()); |
198 stream.writeText("]"); | 196 stream.writeText("]"); |
199 | 197 |
200 // JSON does not allow trailing commas | 198 // JSON does not allow trailing commas |
201 if (poiIndex + 1 < data.fPointsOfInterest.count()) | 199 if (poiIndex + 1 < data.fPointsOfInterest.count() && |
202 { | 200 poiIndex + 1 < kMaxPOI) { |
203 stream.writeText(","); | 201 stream.writeText(","); |
204 } | 202 } |
205 stream.writeText("\n"); | 203 stream.writeText("\n"); |
206 } | 204 } |
207 stream.writeText(" ]\n"); | 205 stream.writeText(" ]\n"); |
208 stream.writeText(" }"); | 206 stream.writeText(" }"); |
209 | 207 |
210 // JSON does not allow trailing commas | 208 // JSON does not allow trailing commas |
211 if (diffIndex + 1 < currentRecord->fDiffs.count()) | 209 if (diffIndex + 1 < currentRecord->fDiffs.count()) { |
212 { | |
213 stream.writeText(","); | 210 stream.writeText(","); |
214 } | 211 } |
215 stream.writeText(" \n"); | 212 stream.writeText(" \n"); |
216 } | 213 } |
217 stream.writeText(" ]\n"); | 214 stream.writeText(" ]\n"); |
218 | 215 |
219 stream.writeText(" }"); | 216 stream.writeText(" }"); |
220 | 217 |
221 // JSON does not allow trailing commas | 218 // JSON does not allow trailing commas |
222 if (NULL != currentRecord->fNext) | 219 if (NULL != currentRecord->fNext) { |
223 { | |
224 stream.writeText(","); | 220 stream.writeText(","); |
225 } | 221 } |
226 stream.writeText("\n"); | 222 stream.writeText("\n"); |
227 currentRecord = currentRecord->fNext; | 223 currentRecord = currentRecord->fNext; |
228 } | 224 } |
229 stream.writeText(" ]\n"); | 225 stream.writeText(" ]\n"); |
230 if (useJSONP) { | 226 if (useJSONP) { |
231 stream.writeText("};\n"); | 227 stream.writeText("};\n"); |
232 } | 228 } else { |
233 else | |
234 { | |
235 stream.writeText("}\n"); | 229 stream.writeText("}\n"); |
236 } | 230 } |
237 } | 231 } |
238 | 232 |
239 void SkDiffContext::outputCsv(SkWStream& stream) { | 233 void SkDiffContext::outputCsv(SkWStream& stream) { |
240 SkTDict<int> columns(2); | 234 SkTDict<int> columns(2); |
241 int cntColumns = 0; | 235 int cntColumns = 0; |
242 | 236 |
243 stream.writeText("key"); | 237 stream.writeText("key"); |
244 | 238 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 for (int i = 0; i < cntColumns; i++) { | 281 for (int i = 0; i < cntColumns; i++) { |
288 SkString str; | 282 SkString str; |
289 str.printf(", %f", values[i]); | 283 str.printf(", %f", values[i]); |
290 stream.writeText(str.c_str()); | 284 stream.writeText(str.c_str()); |
291 } | 285 } |
292 stream.writeText("\n"); | 286 stream.writeText("\n"); |
293 | 287 |
294 currentRecord = currentRecord->fNext; | 288 currentRecord = currentRecord->fNext; |
295 } | 289 } |
296 } | 290 } |
OLD | NEW |