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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 if (encoded_data.size() == 0) { | 46 if (encoded_data.size() == 0) { |
47 callback.Run(nullptr); | 47 callback.Run(nullptr); |
48 return; | 48 return; |
49 } | 49 } |
50 | 50 |
51 SkBitmap decoded_image; | 51 SkBitmap decoded_image; |
52 #if defined(OS_CHROMEOS) | 52 #if defined(OS_CHROMEOS) |
53 if (codec == mojom::ImageCodec::ROBUST_JPEG) { | 53 if (codec == mojom::ImageCodec::ROBUST_JPEG) { |
54 // Our robust jpeg decoding is using IJG libjpeg. | 54 // Our robust jpeg decoding is using IJG libjpeg. |
55 if (encoded_data.size()) { | 55 if (encoded_data.size()) { |
56 scoped_ptr<SkBitmap> decoded_jpeg( | 56 std::unique_ptr<SkBitmap> decoded_jpeg(gfx::JPEGCodecRobustSlow::Decode( |
57 gfx::JPEGCodecRobustSlow::Decode(encoded_data.storage().data(), | 57 encoded_data.storage().data(), encoded_data.size())); |
58 encoded_data.size())); | |
59 if (decoded_jpeg.get() && !decoded_jpeg->empty()) | 58 if (decoded_jpeg.get() && !decoded_jpeg->empty()) |
60 decoded_image = *decoded_jpeg; | 59 decoded_image = *decoded_jpeg; |
61 } | 60 } |
62 } else if (codec == mojom::ImageCodec::ROBUST_PNG) { | 61 } else if (codec == mojom::ImageCodec::ROBUST_PNG) { |
63 // Our robust PNG decoding is using libpng. | 62 // Our robust PNG decoding is using libpng. |
64 if (encoded_data.size()) { | 63 if (encoded_data.size()) { |
65 SkBitmap decoded_png; | 64 SkBitmap decoded_png; |
66 if (gfx::PNGCodec::Decode(encoded_data.storage().data(), | 65 if (gfx::PNGCodec::Decode(encoded_data.storage().data(), |
67 encoded_data.size(), &decoded_png)) { | 66 encoded_data.size(), &decoded_png)) { |
68 decoded_image = decoded_png; | 67 decoded_image = decoded_png; |
(...skipping 27 matching lines...) Expand all Loading... |
96 decoded_image.reset(); | 95 decoded_image.reset(); |
97 } | 96 } |
98 } | 97 } |
99 } | 98 } |
100 | 99 |
101 if (decoded_image.isNull()) | 100 if (decoded_image.isNull()) |
102 callback.Run(nullptr); | 101 callback.Run(nullptr); |
103 else | 102 else |
104 callback.Run(skia::mojom::Bitmap::From(decoded_image)); | 103 callback.Run(skia::mojom::Bitmap::From(decoded_image)); |
105 } | 104 } |
OLD | NEW |