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 "chrome/utility/image_decoder_impl.h" | 5 #include "chrome/utility/image_decoder_impl.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 : max_message_size_(kMaxMessageSize), binding_(this, std::move(request)) { | 34 : max_message_size_(kMaxMessageSize), binding_(this, std::move(request)) { |
35 } | 35 } |
36 | 36 |
37 ImageDecoderImpl::~ImageDecoderImpl() { | 37 ImageDecoderImpl::~ImageDecoderImpl() { |
38 } | 38 } |
39 | 39 |
40 void ImageDecoderImpl::DecodeImage( | 40 void ImageDecoderImpl::DecodeImage( |
41 mojo::Array<uint8_t> encoded_data, | 41 mojo::Array<uint8_t> encoded_data, |
42 mojom::ImageCodec codec, | 42 mojom::ImageCodec codec, |
43 bool shrink_to_fit, | 43 bool shrink_to_fit, |
44 const DecodeImageCallback& callback) { | 44 const mojo::Callback<void(const SkBitmap&)>& callback) { |
45 if (encoded_data.size() == 0) { | 45 if (encoded_data.size() == 0) { |
46 callback.Run(SkBitmap()); | 46 callback.Run(SkBitmap()); |
47 return; | 47 return; |
48 } | 48 } |
49 | 49 |
50 SkBitmap decoded_image; | 50 SkBitmap decoded_image; |
51 #if defined(OS_CHROMEOS) | 51 #if defined(OS_CHROMEOS) |
52 if (codec == mojom::ImageCodec::ROBUST_JPEG) { | 52 if (codec == mojom::ImageCodec::ROBUST_JPEG) { |
53 // Our robust jpeg decoding is using IJG libjpeg. | 53 // Our robust jpeg decoding is using IJG libjpeg. |
54 if (encoded_data.size()) { | 54 if (encoded_data.size()) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 decoded_image, skia::ImageOperations::RESIZE_LANCZOS3, | 93 decoded_image, skia::ImageOperations::RESIZE_LANCZOS3, |
94 decoded_image.width() >> halves, decoded_image.height() >> halves); | 94 decoded_image.width() >> halves, decoded_image.height() >> halves); |
95 } else { | 95 } else { |
96 decoded_image.reset(); | 96 decoded_image.reset(); |
97 } | 97 } |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 callback.Run(decoded_image); | 101 callback.Run(decoded_image); |
102 } | 102 } |
OLD | NEW |