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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 for (int differIndex = 0; differIndex < fDifferCount; differIndex++) { | 138 for (int differIndex = 0; differIndex < fDifferCount; differIndex++) { |
139 SkImageDiffer* differ = fDiffers[differIndex]; | 139 SkImageDiffer* differ = fDiffers[differIndex]; |
140 | 140 |
141 // Copy the results into data for this record | 141 // Copy the results into data for this record |
142 DiffData& diffData = newRecord->fDiffs.push_back(); | 142 DiffData& diffData = newRecord->fDiffs.push_back(); |
143 diffData.fDiffName = differ->getName(); | 143 diffData.fDiffName = differ->getName(); |
144 | 144 |
145 if (!differ->diff(&baselineBitmap, &testBitmap, bitmapsToCreate, &diffDa
ta.fResult)) { | 145 if (!differ->diff(&baselineBitmap, &testBitmap, bitmapsToCreate, &diffDa
ta.fResult)) { |
146 // if the diff failed, record -1 as the result | 146 // if the diff failed, record -1 as the result |
147 // TODO(djsollen): Record more detailed information about exactly wh
at failed. | 147 // TODO(djsollen): Record more detailed information about exactly wh
at failed. |
148 // (Image dimension mismatch? etc.) See http://skbug.com/2710 ('mak
e skpdiff | 148 // (Image dimension mismatch? etc.) See https://bug.skia.org/2710 (
'make skpdiff |
149 // report more detail when it fails to compare two images') | 149 // report more detail when it fails to compare two images') |
150 diffData.fResult.result = -1; | 150 diffData.fResult.result = -1; |
151 continue; | 151 continue; |
152 } | 152 } |
153 | 153 |
154 if (bitmapsToCreate.alphaMask | 154 if (bitmapsToCreate.alphaMask |
155 && SkImageDiffer::RESULT_CORRECT != diffData.fResult.result | 155 && SkImageDiffer::RESULT_CORRECT != diffData.fResult.result |
156 && !diffData.fResult.poiAlphaMask.empty() | 156 && !diffData.fResult.poiAlphaMask.empty() |
157 && !newRecord->fCommonName.isEmpty()) { | 157 && !newRecord->fCommonName.isEmpty()) { |
158 | 158 |
(...skipping 13 matching lines...) Expand all Loading... |
172 } | 172 } |
173 | 173 |
174 if (bitmapsToCreate.rgbDiff | 174 if (bitmapsToCreate.rgbDiff |
175 && SkImageDiffer::RESULT_CORRECT != diffData.fResult.result | 175 && SkImageDiffer::RESULT_CORRECT != diffData.fResult.result |
176 && !diffData.fResult.rgbDiffBitmap.empty() | 176 && !diffData.fResult.rgbDiffBitmap.empty() |
177 && !newRecord->fCommonName.isEmpty()) { | 177 && !newRecord->fCommonName.isEmpty()) { |
178 // TODO(djsollen): Rather than taking the max r/g/b diffs that come
back from | 178 // TODO(djsollen): Rather than taking the max r/g/b diffs that come
back from |
179 // a particular differ and storing them as toplevel fields within | 179 // a particular differ and storing them as toplevel fields within |
180 // newRecord, we should extend outputRecords() to report optional | 180 // newRecord, we should extend outputRecords() to report optional |
181 // fields for each differ (not just "result" and "pointsOfInterest")
. | 181 // fields for each differ (not just "result" and "pointsOfInterest")
. |
182 // See http://skbug.com/2712 ('allow skpdiff to report different set
s | 182 // See https://bug.skia.org/2712 ('allow skpdiff to report different
sets |
183 // of result fields for different comparison algorithms') | 183 // of result fields for different comparison algorithms') |
184 newRecord->fMaxRedDiff = diffData.fResult.maxRedDiff; | 184 newRecord->fMaxRedDiff = diffData.fResult.maxRedDiff; |
185 newRecord->fMaxGreenDiff = diffData.fResult.maxGreenDiff; | 185 newRecord->fMaxGreenDiff = diffData.fResult.maxGreenDiff; |
186 newRecord->fMaxBlueDiff = diffData.fResult.maxBlueDiff; | 186 newRecord->fMaxBlueDiff = diffData.fResult.maxBlueDiff; |
187 | 187 |
188 newRecord->fRgbDiffPath = SkOSPath::Join(fRgbDiffDir.c_str(), | 188 newRecord->fRgbDiffPath = SkOSPath::Join(fRgbDiffDir.c_str(), |
189 newRecord->fCommonName.c_st
r()); | 189 newRecord->fCommonName.c_st
r()); |
190 SkImageEncoder::EncodeFile(newRecord->fRgbDiffPath.c_str(), | 190 SkImageEncoder::EncodeFile(newRecord->fRgbDiffPath.c_str(), |
191 diffData.fResult.rgbDiffBitmap, | 191 diffData.fResult.rgbDiffBitmap, |
192 SkImageEncoder::kPNG_Type, 100); | 192 SkImageEncoder::kPNG_Type, 100); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
275 // See http://skbug.com/2713 ('make skpdiff use jsoncpp library to write out | 275 // See https://bug.skia.org/2713 ('make skpdiff use jsoncpp library to write
out |
276 // JSON output, instead of manual writeText() calls?') | 276 // JSON output, instead of manual writeText() calls?') |
277 stream.writeText(" \"records\": [\n"); | 277 stream.writeText(" \"records\": [\n"); |
278 while (currentRecord) { | 278 while (currentRecord) { |
279 stream.writeText(" {\n"); | 279 stream.writeText(" {\n"); |
280 | 280 |
281 SkString baselineAbsPath = get_absolute_path(currentRecord->fBaselin
ePath); | 281 SkString baselineAbsPath = get_absolute_path(currentRecord->fBaselin
ePath); |
282 SkString testAbsPath = get_absolute_path(currentRecord->fTestPath); | 282 SkString testAbsPath = get_absolute_path(currentRecord->fTestPath); |
283 | 283 |
284 stream.writeText(" \"commonName\": \""); | 284 stream.writeText(" \"commonName\": \""); |
285 stream.writeText(currentRecord->fCommonName.c_str()); | 285 stream.writeText(currentRecord->fCommonName.c_str()); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |