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