| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 && !diffData.fResult.poiAlphaMask.empty() | 156 && !diffData.fResult.poiAlphaMask.empty() |
| 157 && !newRecord->fCommonName.isEmpty()) { | 157 && !newRecord->fCommonName.isEmpty()) { |
| 158 | 158 |
| 159 newRecord->fAlphaMaskPath = SkOSPath::Join(fAlphaMaskDir.c_str(), | 159 newRecord->fAlphaMaskPath = SkOSPath::Join(fAlphaMaskDir.c_str(), |
| 160 newRecord->fCommonName.c_
str()); | 160 newRecord->fCommonName.c_
str()); |
| 161 | 161 |
| 162 // compute the image diff and output it | 162 // compute the image diff and output it |
| 163 SkBitmap copy; | 163 SkBitmap copy; |
| 164 diffData.fResult.poiAlphaMask.copyTo(©, kN32_SkColorType); | 164 diffData.fResult.poiAlphaMask.copyTo(©, kN32_SkColorType); |
| 165 SkImageEncoder::EncodeFile(newRecord->fAlphaMaskPath.c_str(), copy, | 165 SkImageEncoder::EncodeFile(newRecord->fAlphaMaskPath.c_str(), copy, |
| 166 SkImageEncoder::kPNG_Type, 100); | 166 kPNG_SkEncodedFormat, 100); |
| 167 | 167 |
| 168 // cleanup the existing bitmap to free up resources; | 168 // cleanup the existing bitmap to free up resources; |
| 169 diffData.fResult.poiAlphaMask.reset(); | 169 diffData.fResult.poiAlphaMask.reset(); |
| 170 | 170 |
| 171 bitmapsToCreate.alphaMask = false; | 171 bitmapsToCreate.alphaMask = false; |
| 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 http://skbug.com/2712 ('allow skpdiff to report different set
s |
| 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 kPNG_SkEncodedFormat, 100); |
| 193 diffData.fResult.rgbDiffBitmap.reset(); | 193 diffData.fResult.rgbDiffBitmap.reset(); |
| 194 bitmapsToCreate.rgbDiff = false; | 194 bitmapsToCreate.rgbDiff = false; |
| 195 } | 195 } |
| 196 | 196 |
| 197 if (bitmapsToCreate.whiteDiff | 197 if (bitmapsToCreate.whiteDiff |
| 198 && SkImageDiffer::RESULT_CORRECT != diffData.fResult.result | 198 && SkImageDiffer::RESULT_CORRECT != diffData.fResult.result |
| 199 && !diffData.fResult.whiteDiffBitmap.empty() | 199 && !diffData.fResult.whiteDiffBitmap.empty() |
| 200 && !newRecord->fCommonName.isEmpty()) { | 200 && !newRecord->fCommonName.isEmpty()) { |
| 201 newRecord->fWhiteDiffPath = SkOSPath::Join(fWhiteDiffDir.c_str(), | 201 newRecord->fWhiteDiffPath = SkOSPath::Join(fWhiteDiffDir.c_str(), |
| 202 newRecord->fCommonName.c_
str()); | 202 newRecord->fCommonName.c_
str()); |
| 203 SkImageEncoder::EncodeFile(newRecord->fWhiteDiffPath.c_str(), | 203 SkImageEncoder::EncodeFile(newRecord->fWhiteDiffPath.c_str(), |
| 204 diffData.fResult.whiteDiffBitmap, | 204 diffData.fResult.whiteDiffBitmap, |
| 205 SkImageEncoder::kPNG_Type, 100); | 205 kPNG_SkEncodedFormat, 100); |
| 206 diffData.fResult.whiteDiffBitmap.reset(); | 206 diffData.fResult.whiteDiffBitmap.reset(); |
| 207 bitmapsToCreate.whiteDiff = false; | 207 bitmapsToCreate.whiteDiff = false; |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 | 211 |
| 212 class SkThreadedDiff : public SkRunnable { | 212 class SkThreadedDiff : public SkRunnable { |
| 213 public: | 213 public: |
| 214 SkThreadedDiff() : fDiffContext(NULL) { } | 214 SkThreadedDiff() : fDiffContext(NULL) { } |
| 215 | 215 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 for (int i = 0; i < cntColumns; i++) { | 452 for (int i = 0; i < cntColumns; i++) { |
| 453 SkString str; | 453 SkString str; |
| 454 str.printf(", %f", values[i]); | 454 str.printf(", %f", values[i]); |
| 455 stream.writeText(str.c_str()); | 455 stream.writeText(str.c_str()); |
| 456 } | 456 } |
| 457 stream.writeText("\n"); | 457 stream.writeText("\n"); |
| 458 | 458 |
| 459 currentRecord = iter2.next(); | 459 currentRecord = iter2.next(); |
| 460 } | 460 } |
| 461 } | 461 } |
| OLD | NEW |