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" |
11 #include "SkStream.h" | 11 #include "SkStream.h" |
12 #include "SkTDict.h" | 12 #include "SkTDict.h" |
13 | 13 |
14 #include "SkDiffContext.h" | 14 #include "SkDiffContext.h" |
15 #include "SkImageDiffer.h" | 15 #include "SkImageDiffer.h" |
16 #include "skpdiff_util.h" | 16 #include "skpdiff_util.h" |
17 | 17 |
| 18 // Truncates the number of points of interests in JSON output to not freeze the
parser |
| 19 static const int kMaxPOI = 100; |
| 20 |
18 SkDiffContext::SkDiffContext() { | 21 SkDiffContext::SkDiffContext() { |
19 fRecords = NULL; | 22 fRecords = NULL; |
20 fDiffers = NULL; | 23 fDiffers = NULL; |
21 fDifferCount = 0; | 24 fDifferCount = 0; |
22 } | 25 } |
23 | 26 |
24 SkDiffContext::~SkDiffContext() { | 27 SkDiffContext::~SkDiffContext() { |
25 // Delete the record linked list | 28 // Delete the record linked list |
26 DiffRecord* currentRecord = fRecords; | 29 DiffRecord* currentRecord = fRecords; |
27 while (NULL != currentRecord) { | 30 while (NULL != currentRecord) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 181 |
179 stream.writeText(" \"differName\": \""); | 182 stream.writeText(" \"differName\": \""); |
180 stream.writeText(data.fDiffName); | 183 stream.writeText(data.fDiffName); |
181 stream.writeText("\",\n"); | 184 stream.writeText("\",\n"); |
182 | 185 |
183 stream.writeText(" \"result\": "); | 186 stream.writeText(" \"result\": "); |
184 stream.writeScalarAsText((SkScalar)data.fResult); | 187 stream.writeScalarAsText((SkScalar)data.fResult); |
185 stream.writeText(",\n"); | 188 stream.writeText(",\n"); |
186 | 189 |
187 stream.writeText(" \"pointsOfInterest\":
[\n"); | 190 stream.writeText(" \"pointsOfInterest\":
[\n"); |
188 for (int poiIndex = 0; poiIndex < data.fPointsOfInterest.cou
nt(); poiIndex++) { | 191 for (int poiIndex = 0; poiIndex < data.fPointsOfInterest.cou
nt() && |
| 192 poiIndex < kMaxPOI; poiIndex++) { |
189 SkIPoint poi = data.fPointsOfInterest[poiIndex]; | 193 SkIPoint poi = data.fPointsOfInterest[poiIndex]; |
190 stream.writeText(" ["); | 194 stream.writeText(" ["); |
191 stream.writeDecAsText(poi.x()); | 195 stream.writeDecAsText(poi.x()); |
192 stream.writeText(","); | 196 stream.writeText(","); |
193 stream.writeDecAsText(poi.y()); | 197 stream.writeDecAsText(poi.y()); |
194 stream.writeText("]"); | 198 stream.writeText("]"); |
195 | 199 |
196 // JSON does not allow trailing commas | 200 // JSON does not allow trailing commas |
197 if (poiIndex + 1 < data.fPointsOfInterest.count()) | 201 if (poiIndex + 1 < data.fPointsOfInterest.count()) |
198 { | 202 { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 for (int i = 0; i < cntColumns; i++) { | 287 for (int i = 0; i < cntColumns; i++) { |
284 SkString str; | 288 SkString str; |
285 str.printf(", %f", values[i]); | 289 str.printf(", %f", values[i]); |
286 stream.writeText(str.c_str()); | 290 stream.writeText(str.c_str()); |
287 } | 291 } |
288 stream.writeText("\n"); | 292 stream.writeText("\n"); |
289 | 293 |
290 currentRecord = currentRecord->fNext; | 294 currentRecord = currentRecord->fNext; |
291 } | 295 } |
292 } | 296 } |
OLD | NEW |