Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 return true; | 46 return true; |
| 47 } | 47 } |
| 48 | 48 |
| 49 class Request { | 49 class Request { |
| 50 public: | 50 public: |
| 51 explicit Request(ImageDecoderImpl* decoder) : decoder_(decoder) {} | 51 explicit Request(ImageDecoderImpl* decoder) : decoder_(decoder) {} |
| 52 | 52 |
| 53 void DecodeImage(const std::vector<unsigned char>& image, bool shrink) { | 53 void DecodeImage(const std::vector<unsigned char>& image, bool shrink) { |
| 54 decoder_->DecodeImage( | 54 decoder_->DecodeImage( |
| 55 image, mojom::ImageCodec::DEFAULT, shrink, kTestMaxImageSize, | 55 image, mojom::ImageCodec::DEFAULT, shrink, kTestMaxImageSize, |
| 56 gfx::Size(), | |
|
Mathieu
2017/03/01 14:36:23
add a comment: no preferred size, want the biggest
tschumann
2017/03/01 19:40:08
it's actually the smallest :-) I added a comment -
| |
| 56 base::Bind(&Request::OnRequestDone, base::Unretained(this))); | 57 base::Bind(&Request::OnRequestDone, base::Unretained(this))); |
| 57 } | 58 } |
| 58 | 59 |
| 59 const SkBitmap& bitmap() const { return bitmap_; } | 60 const SkBitmap& bitmap() const { return bitmap_; } |
| 60 | 61 |
| 61 private: | 62 private: |
| 62 void OnRequestDone(const SkBitmap& result_image) { bitmap_ = result_image; } | 63 void OnRequestDone(const SkBitmap& result_image) { bitmap_ = result_image; } |
| 63 | 64 |
| 64 ImageDecoderImpl* decoder_; | 65 ImageDecoderImpl* decoder_; |
| 65 SkBitmap bitmap_; | 66 SkBitmap bitmap_; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 const char kRandomData[] = "u gycfy7xdjkhfgui bdui "; | 155 const char kRandomData[] = "u gycfy7xdjkhfgui bdui "; |
| 155 std::vector<unsigned char> jpg(kRandomData, | 156 std::vector<unsigned char> jpg(kRandomData, |
| 156 kRandomData + sizeof(kRandomData)); | 157 kRandomData + sizeof(kRandomData)); |
| 157 | 158 |
| 158 Request request(decoder()); | 159 Request request(decoder()); |
| 159 request.DecodeImage(jpg, false); | 160 request.DecodeImage(jpg, false); |
| 160 EXPECT_TRUE(request.bitmap().isNull()); | 161 EXPECT_TRUE(request.bitmap().isNull()); |
| 161 } | 162 } |
| 162 | 163 |
| 163 } // namespace image_decoder | 164 } // namespace image_decoder |
| OLD | NEW |