| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/login/users/avatar/user_image_manager_test_uti
l.h" | 5 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager_test_uti
l.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 SkAutoLockPixels second_pixel_lock(*second_bitmap); | 37 SkAutoLockPixels second_pixel_lock(*second_bitmap); |
| 38 uint8_t* first_data = reinterpret_cast<uint8_t*>(first_bitmap->getPixels()); | 38 uint8_t* first_data = reinterpret_cast<uint8_t*>(first_bitmap->getPixels()); |
| 39 uint8_t* second_data = reinterpret_cast<uint8_t*>(second_bitmap->getPixels()); | 39 uint8_t* second_data = reinterpret_cast<uint8_t*>(second_bitmap->getPixels()); |
| 40 for (size_t i = 0; i < size; ++i) { | 40 for (size_t i = 0; i < size; ++i) { |
| 41 if (first_data[i] != second_data[i]) | 41 if (first_data[i] != second_data[i]) |
| 42 return false; | 42 return false; |
| 43 } | 43 } |
| 44 return true; | 44 return true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 ImageLoader::ImageLoader(const base::FilePath& path) : path_(path) { | 47 ImageLoader::ImageLoader(const base::FilePath& path) |
| 48 : Delegate(base::MessageLoopProxy::current()), path_(path) { |
| 48 } | 49 } |
| 49 | 50 |
| 50 ImageLoader::~ImageLoader() { | 51 ImageLoader::~ImageLoader() { |
| 51 } | 52 } |
| 52 | 53 |
| 53 scoped_ptr<gfx::ImageSkia> ImageLoader::Load() { | 54 scoped_ptr<gfx::ImageSkia> ImageLoader::Load() { |
| 54 std::string image_data; | 55 std::string image_data; |
| 55 ReadFileToString(path_, &image_data); | 56 ReadFileToString(path_, &image_data); |
| 56 scoped_refptr<ImageDecoder> image_decoder = new ImageDecoder( | 57 ImageDecoder::Start(this, image_data, ImageDecoder::ROBUST_JPEG_CODEC, false); |
| 57 this, | |
| 58 image_data, | |
| 59 ImageDecoder::ROBUST_JPEG_CODEC); | |
| 60 image_decoder->Start(base::MessageLoopProxy::current()); | |
| 61 run_loop_.Run(); | 58 run_loop_.Run(); |
| 62 return decoded_image_.Pass(); | 59 return decoded_image_.Pass(); |
| 63 } | 60 } |
| 64 | 61 |
| 65 void ImageLoader::OnImageDecoded(const ImageDecoder* decoder, | 62 void ImageLoader::OnImageDecoded(const SkBitmap& decoded_image) { |
| 66 const SkBitmap& decoded_image) { | |
| 67 decoded_image_.reset( | 63 decoded_image_.reset( |
| 68 new gfx::ImageSkia(gfx::ImageSkiaRep(decoded_image, 1.0f))); | 64 new gfx::ImageSkia(gfx::ImageSkiaRep(decoded_image, 1.0f))); |
| 69 run_loop_.Quit(); | 65 run_loop_.Quit(); |
| 70 } | 66 } |
| 71 | 67 |
| 72 void ImageLoader::OnDecodeImageFailed(const ImageDecoder* decoder) { | 68 void ImageLoader::OnDecodeImageFailed() { |
| 73 run_loop_.Quit(); | 69 run_loop_.Quit(); |
| 74 } | 70 } |
| 75 | 71 |
| 76 } // namespace test | 72 } // namespace test |
| 77 } // namespace chromeos | 73 } // namespace chromeos |
| OLD | NEW |