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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 } | 140 } |
141 | 141 |
142 for (int entryIndex = 0; entryIndex < baselineEntries.count(); entryIndex++)
{ | 142 for (int entryIndex = 0; entryIndex < baselineEntries.count(); entryIndex++)
{ |
143 const char* baselineFilename = baselineEntries[entryIndex].c_str(); | 143 const char* baselineFilename = baselineEntries[entryIndex].c_str(); |
144 const char* testFilename = testEntries [entryIndex].c_str(); | 144 const char* testFilename = testEntries [entryIndex].c_str(); |
145 | 145 |
146 this->addDiff(baselineFilename, testFilename); | 146 this->addDiff(baselineFilename, testFilename); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 void SkDiffContext::outputRecords(SkWStream& stream) { | 150 void SkDiffContext::outputRecords(SkWStream& stream, bool useJSONP) { |
151 DiffRecord* currentRecord = fRecords; | 151 DiffRecord* currentRecord = fRecords; |
152 stream.writeText("{\n"); | 152 if (useJSONP) { |
| 153 stream.writeText("var SkPDiffRecords = {\n"); |
| 154 } |
| 155 else |
| 156 { |
| 157 stream.writeText("{\n"); |
| 158 } |
153 stream.writeText(" \"records\": [\n"); | 159 stream.writeText(" \"records\": [\n"); |
154 while (NULL != currentRecord) { | 160 while (NULL != currentRecord) { |
155 stream.writeText(" {\n"); | 161 stream.writeText(" {\n"); |
156 | 162 |
157 stream.writeText(" \"baselinePath\": \""); | 163 stream.writeText(" \"baselinePath\": \""); |
158 stream.writeText(currentRecord->fBaselinePath.c_str()); | 164 stream.writeText(currentRecord->fBaselinePath.c_str()); |
159 stream.writeText("\",\n"); | 165 stream.writeText("\",\n"); |
160 | 166 |
161 stream.writeText(" \"testPath\": \""); | 167 stream.writeText(" \"testPath\": \""); |
162 stream.writeText(currentRecord->fTestPath.c_str()); | 168 stream.writeText(currentRecord->fTestPath.c_str()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 213 |
208 // JSON does not allow trailing commas | 214 // JSON does not allow trailing commas |
209 if (NULL != currentRecord->fNext) | 215 if (NULL != currentRecord->fNext) |
210 { | 216 { |
211 stream.writeText(","); | 217 stream.writeText(","); |
212 } | 218 } |
213 stream.writeText("\n"); | 219 stream.writeText("\n"); |
214 currentRecord = currentRecord->fNext; | 220 currentRecord = currentRecord->fNext; |
215 } | 221 } |
216 stream.writeText(" ]\n"); | 222 stream.writeText(" ]\n"); |
217 stream.writeText("}\n"); | 223 if (useJSONP) { |
| 224 stream.writeText("};\n"); |
| 225 } |
| 226 else |
| 227 { |
| 228 stream.writeText("}\n"); |
| 229 } |
218 } | 230 } |
OLD | NEW |