Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: experimental/skpdiff/SkDiffContext.cpp

Issue 19693010: revert unreviewed 10194, will send to review (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | experimental/skpdiff/main.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkCommandLineFlags.h"
10 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
11 #include "SkOSFile.h" 10 #include "SkOSFile.h"
12 #include "SkStream.h" 11 #include "SkStream.h"
13 12
14 #include "SkDiffContext.h" 13 #include "SkDiffContext.h"
15 #include "SkImageDiffer.h" 14 #include "SkImageDiffer.h"
16 #include "skpdiff_util.h" 15 #include "skpdiff_util.h"
17 16
18 DECLARE_string(csv);
19
20 SkDiffContext::SkDiffContext() { 17 SkDiffContext::SkDiffContext() {
21 fRecords = NULL; 18 fRecords = NULL;
22 fDiffers = NULL; 19 fDiffers = NULL;
23 fDifferCount = 0; 20 fDifferCount = 0;
24 } 21 }
25 22
26 SkDiffContext::~SkDiffContext() { 23 SkDiffContext::~SkDiffContext() {
27 // Delete the record linked list 24 // Delete the record linked list
28 DiffRecord* currentRecord = fRecords; 25 DiffRecord* currentRecord = fRecords;
29 while (NULL != currentRecord) { 26 while (NULL != currentRecord) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 return; 61 return;
65 } 62 }
66 63
67 // Setup a record for this diff 64 // Setup a record for this diff
68 DiffRecord* newRecord = SkNEW(DiffRecord); 65 DiffRecord* newRecord = SkNEW(DiffRecord);
69 newRecord->fBaselinePath = baselinePath; 66 newRecord->fBaselinePath = baselinePath;
70 newRecord->fTestPath = testPath; 67 newRecord->fTestPath = testPath;
71 newRecord->fNext = fRecords; 68 newRecord->fNext = fRecords;
72 fRecords = newRecord; 69 fRecords = newRecord;
73 70
74 FILE* csvFile = NULL;
75 if (!FLAGS_csv.isEmpty()) {
76 csvFile = fopen(FLAGS_csv[0], "a");
77 SkASSERT(csvFile);
78 if (ftell(csvFile) == 0) {
79 fprintf(csvFile, "%s", "skp");
80 for (int differIndex = 0; differIndex < fDifferCount; differIndex++) {
81 SkImageDiffer* differ = fDiffers[differIndex];
82 fprintf(csvFile, ", %s", differ->getName());
83 }
84 fprintf(csvFile, "\n");
85 }
86 }
87
88 if (csvFile) {
89 const char* filename = baselinePath + strlen(baselinePath) - 1;
90 while (filename > baselinePath && *(filename - 1) != '/') {
91 filename--;
92 }
93 fprintf(csvFile, "%s", filename);
94 }
95
96 // Perform each diff 71 // Perform each diff
97 for (int differIndex = 0; differIndex < fDifferCount; differIndex++) { 72 for (int differIndex = 0; differIndex < fDifferCount; differIndex++) {
98 SkImageDiffer* differ = fDiffers[differIndex]; 73 SkImageDiffer* differ = fDiffers[differIndex];
99 int diffID = differ->queueDiff(&baselineBitmap, &testBitmap); 74 int diffID = differ->queueDiff(&baselineBitmap, &testBitmap);
100 if (diffID >= 0) { 75 if (diffID >= 0) {
101 76
102 // Copy the results into data for this record 77 // Copy the results into data for this record
103 DiffData& diffData = newRecord->fDiffs.push_back(); 78 DiffData& diffData = newRecord->fDiffs.push_back();
104 79
105 diffData.fDiffName = differ->getName(); 80 diffData.fDiffName = differ->getName();
106 diffData.fResult = differ->getResult(diffID); 81 diffData.fResult = differ->getResult(diffID);
107 82
108 if (csvFile) {
109 fprintf(csvFile, ", %f", diffData.fResult);
110 }
111
112 int poiCount = differ->getPointsOfInterestCount(diffID); 83 int poiCount = differ->getPointsOfInterestCount(diffID);
113 SkIPoint* poi = differ->getPointsOfInterest(diffID); 84 SkIPoint* poi = differ->getPointsOfInterest(diffID);
114 diffData.fPointsOfInterest.append(poiCount, poi); 85 diffData.fPointsOfInterest.append(poiCount, poi);
115 86
116 // Because we are doing everything synchronously for now, we are don e with the diff 87 // Because we are doing everything synchronously for now, we are don e with the diff
117 // after reading it. 88 // after reading it.
118 differ->deleteDiff(diffID); 89 differ->deleteDiff(diffID);
119 } else {
120 if (csvFile) {
121 fprintf(csvFile, ", -1");
122 }
123 } 90 }
124 } 91 }
125
126 if (csvFile) {
127 fprintf(csvFile, "\n");
128 fclose(csvFile);
129 }
130 } 92 }
131 93
132 94
133 void SkDiffContext::diffDirectories(const char baselinePath[], const char testPa th[]) { 95 void SkDiffContext::diffDirectories(const char baselinePath[], const char testPa th[]) {
134 // Get the files in the baseline, we will then look for those inside the tes t path 96 // Get the files in the baseline, we will then look for those inside the tes t path
135 SkTArray<SkString> baselineEntries; 97 SkTArray<SkString> baselineEntries;
136 if (!get_directory(baselinePath, &baselineEntries)) { 98 if (!get_directory(baselinePath, &baselineEntries)) {
137 SkDebugf("Unable to open path \"%s\"\n", baselinePath); 99 SkDebugf("Unable to open path \"%s\"\n", baselinePath);
138 return; 100 return;
139 } 101 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 223 }
262 stream.writeText(" ]\n"); 224 stream.writeText(" ]\n");
263 if (useJSONP) { 225 if (useJSONP) {
264 stream.writeText("};\n"); 226 stream.writeText("};\n");
265 } 227 }
266 else 228 else
267 { 229 {
268 stream.writeText("}\n"); 230 stream.writeText("}\n");
269 } 231 }
270 } 232 }
OLDNEW
« no previous file with comments | « no previous file | experimental/skpdiff/main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698