| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/webp_transcode/webp_decoder.h" | 5 #include "components/webp_transcode/webp_decoder.h" |
| 6 | 6 |
| 7 #import <CoreGraphics/CoreGraphics.h> | 7 #import <CoreGraphics/CoreGraphics.h> |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 | 11 |
| 12 #include <memory> |
| 13 |
| 12 #include "base/base_paths.h" | 14 #include "base/base_paths.h" |
| 13 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 14 #include "base/ios/ios_util.h" | 16 #include "base/ios/ios_util.h" |
| 15 #include "base/logging.h" | 17 #include "base/logging.h" |
| 16 #include "base/mac/scoped_cftyperef.h" | 18 #include "base/mac/scoped_cftyperef.h" |
| 17 #include "base/mac/scoped_nsobject.h" | 19 #include "base/mac/scoped_nsobject.h" |
| 18 #include "base/macros.h" | 20 #include "base/macros.h" |
| 19 #include "base/memory/ref_counted.h" | 21 #include "base/memory/ref_counted.h" |
| 20 #include "base/path_service.h" | 22 #include "base/path_service.h" |
| 21 #include "base/strings/sys_string_conversions.h" | 23 #include "base/strings/sys_string_conversions.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 difference += error; | 115 difference += error; |
| 114 } | 116 } |
| 115 double average_difference = double(difference) / double(size); | 117 double average_difference = double(difference) / double(size); |
| 116 DLOG(INFO) << "Average image difference: " << average_difference; | 118 DLOG(INFO) << "Average image difference: " << average_difference; |
| 117 return average_difference < 1.5; | 119 return average_difference < 1.5; |
| 118 } | 120 } |
| 119 | 121 |
| 120 bool CheckCompressedImagesEqual(NSData* data_1, | 122 bool CheckCompressedImagesEqual(NSData* data_1, |
| 121 NSData* data_2, | 123 NSData* data_2, |
| 122 WebpDecoder::DecodedImageFormat format) { | 124 WebpDecoder::DecodedImageFormat format) { |
| 123 scoped_ptr<std::vector<uint8_t>> uncompressed_1( | 125 std::unique_ptr<std::vector<uint8_t>> uncompressed_1( |
| 124 DecompressData(data_1, format)); | 126 DecompressData(data_1, format)); |
| 125 scoped_ptr<std::vector<uint8_t>> uncompressed_2( | 127 std::unique_ptr<std::vector<uint8_t>> uncompressed_2( |
| 126 DecompressData(data_2, format)); | 128 DecompressData(data_2, format)); |
| 127 if (uncompressed_1->size() != uncompressed_2->size()) { | 129 if (uncompressed_1->size() != uncompressed_2->size()) { |
| 128 DLOG(ERROR) << "Image sizes don't match"; | 130 DLOG(ERROR) << "Image sizes don't match"; |
| 129 return false; | 131 return false; |
| 130 } | 132 } |
| 131 return CompareUncompressedData(&uncompressed_1->front(), | 133 return CompareUncompressedData(&uncompressed_1->front(), |
| 132 &uncompressed_2->front(), | 134 &uncompressed_2->front(), |
| 133 uncompressed_1->size()); | 135 uncompressed_1->size()); |
| 134 } | 136 } |
| 135 | 137 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 EXPECT_EQ(0u, [delegate_->GetImage() length]); | 282 EXPECT_EQ(0u, [delegate_->GetImage() length]); |
| 281 } | 283 } |
| 282 | 284 |
| 283 TEST_F(WebpDecoderTest, DecodeAborted) { | 285 TEST_F(WebpDecoderTest, DecodeAborted) { |
| 284 EXPECT_CALL(*delegate_, OnFinishedDecoding(false)).Times(1); | 286 EXPECT_CALL(*delegate_, OnFinishedDecoding(false)).Times(1); |
| 285 decoder_->Stop(); | 287 decoder_->Stop(); |
| 286 EXPECT_EQ(0u, [delegate_->GetImage() length]); | 288 EXPECT_EQ(0u, [delegate_->GetImage() length]); |
| 287 } | 289 } |
| 288 | 290 |
| 289 } // namespace webp_transcode | 291 } // namespace webp_transcode |
| OLD | NEW |