| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 254         SkDebugf("Baseline and test patterns do not yield corresponding number o
     f files\n"); | 254         SkDebugf("Baseline and test patterns do not yield corresponding number o
     f files\n"); | 
| 255         return; | 255         return; | 
| 256     } | 256     } | 
| 257 | 257 | 
| 258     sk_parallel_for(baselineEntries.count(), [&](int i) { | 258     sk_parallel_for(baselineEntries.count(), [&](int i) { | 
| 259         this->addDiff(baselineEntries[i].c_str(), testEntries[i].c_str()); | 259         this->addDiff(baselineEntries[i].c_str(), testEntries[i].c_str()); | 
| 260     }); | 260     }); | 
| 261 } | 261 } | 
| 262 | 262 | 
| 263 void SkDiffContext::outputRecords(SkWStream& stream, bool useJSONP) { | 263 void SkDiffContext::outputRecords(SkWStream& stream, bool useJSONP) { | 
| 264     SkTLList<DiffRecord>::Iter iter(fRecords, SkTLList<DiffRecord>::Iter::kHead_
     IterStart); | 264     RecordList::Iter iter(fRecords, RecordList::Iter::kHead_IterStart); | 
| 265     DiffRecord* currentRecord = iter.get(); | 265     DiffRecord* currentRecord = iter.get(); | 
| 266 | 266 | 
| 267     if (useJSONP) { | 267     if (useJSONP) { | 
| 268         stream.writeText("var SkPDiffRecords = {\n"); | 268         stream.writeText("var SkPDiffRecords = {\n"); | 
| 269     } else { | 269     } else { | 
| 270         stream.writeText("{\n"); | 270         stream.writeText("{\n"); | 
| 271     } | 271     } | 
| 272 | 272 | 
| 273     // TODO(djsollen): Would it be better to use the jsoncpp library to write ou
     t the JSON? | 273     // TODO(djsollen): Would it be better to use the jsoncpp library to write ou
     t the JSON? | 
| 274     // This manual approach is probably more efficient, but it sure is ugly. | 274     // This manual approach is probably more efficient, but it sure is ugly. | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 366         stream.writeText("}\n"); | 366         stream.writeText("}\n"); | 
| 367     } | 367     } | 
| 368 } | 368 } | 
| 369 | 369 | 
| 370 void SkDiffContext::outputCsv(SkWStream& stream) { | 370 void SkDiffContext::outputCsv(SkWStream& stream) { | 
| 371     SkTDict<int> columns(2); | 371     SkTDict<int> columns(2); | 
| 372     int cntColumns = 0; | 372     int cntColumns = 0; | 
| 373 | 373 | 
| 374     stream.writeText("key"); | 374     stream.writeText("key"); | 
| 375 | 375 | 
| 376     SkTLList<DiffRecord>::Iter iter(fRecords, SkTLList<DiffRecord>::Iter::kHead_
     IterStart); | 376     RecordList::Iter iter(fRecords, RecordList::Iter::kHead_IterStart); | 
| 377     DiffRecord* currentRecord = iter.get(); | 377     DiffRecord* currentRecord = iter.get(); | 
| 378 | 378 | 
| 379     // Write CSV header and create a dictionary of all columns. | 379     // Write CSV header and create a dictionary of all columns. | 
| 380     while (currentRecord) { | 380     while (currentRecord) { | 
| 381         for (int diffIndex = 0; diffIndex < currentRecord->fDiffs.count(); diffI
     ndex++) { | 381         for (int diffIndex = 0; diffIndex < currentRecord->fDiffs.count(); diffI
     ndex++) { | 
| 382             DiffData& data = currentRecord->fDiffs[diffIndex]; | 382             DiffData& data = currentRecord->fDiffs[diffIndex]; | 
| 383             if (!columns.find(data.fDiffName)) { | 383             if (!columns.find(data.fDiffName)) { | 
| 384                 columns.set(data.fDiffName, cntColumns); | 384                 columns.set(data.fDiffName, cntColumns); | 
| 385                 stream.writeText(", "); | 385                 stream.writeText(", "); | 
| 386                 stream.writeText(data.fDiffName); | 386                 stream.writeText(data.fDiffName); | 
| 387                 cntColumns++; | 387                 cntColumns++; | 
| 388             } | 388             } | 
| 389         } | 389         } | 
| 390         currentRecord = iter.next(); | 390         currentRecord = iter.next(); | 
| 391     } | 391     } | 
| 392     stream.writeText("\n"); | 392     stream.writeText("\n"); | 
| 393 | 393 | 
| 394     double values[100]; | 394     double values[100]; | 
| 395     SkASSERT(cntColumns < 100);  // Make the array larger, if we ever have so ma
     ny diff types. | 395     SkASSERT(cntColumns < 100);  // Make the array larger, if we ever have so ma
     ny diff types. | 
| 396 | 396 | 
| 397     SkTLList<DiffRecord>::Iter iter2(fRecords, SkTLList<DiffRecord>::Iter::kHead
     _IterStart); | 397     RecordList::Iter iter2(fRecords, RecordList::Iter::kHead_IterStart); | 
| 398     currentRecord = iter2.get(); | 398     currentRecord = iter2.get(); | 
| 399     while (currentRecord) { | 399     while (currentRecord) { | 
| 400         for (int i = 0; i < cntColumns; i++) { | 400         for (int i = 0; i < cntColumns; i++) { | 
| 401             values[i] = -1; | 401             values[i] = -1; | 
| 402         } | 402         } | 
| 403 | 403 | 
| 404         for (int diffIndex = 0; diffIndex < currentRecord->fDiffs.count(); diffI
     ndex++) { | 404         for (int diffIndex = 0; diffIndex < currentRecord->fDiffs.count(); diffI
     ndex++) { | 
| 405             DiffData& data = currentRecord->fDiffs[diffIndex]; | 405             DiffData& data = currentRecord->fDiffs[diffIndex]; | 
| 406             int index = -1; | 406             int index = -1; | 
| 407             SkAssertResult(columns.find(data.fDiffName, &index)); | 407             SkAssertResult(columns.find(data.fDiffName, &index)); | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 420         for (int i = 0; i < cntColumns; i++) { | 420         for (int i = 0; i < cntColumns; i++) { | 
| 421             SkString str; | 421             SkString str; | 
| 422             str.printf(", %f", values[i]); | 422             str.printf(", %f", values[i]); | 
| 423             stream.writeText(str.c_str()); | 423             stream.writeText(str.c_str()); | 
| 424         } | 424         } | 
| 425         stream.writeText("\n"); | 425         stream.writeText("\n"); | 
| 426 | 426 | 
| 427         currentRecord = iter2.next(); | 427         currentRecord = iter2.next(); | 
| 428     } | 428     } | 
| 429 } | 429 } | 
| OLD | NEW | 
|---|