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 #ifndef SERVICES_IMAGE_DECODER_PUBLIC_CPP_DECODE_H_ | 5 #ifndef SERVICES_DATA_DECODER_PUBLIC_CPP_DECODE_H_ |
6 #define SERVICES_IMAGE_DECODER_PUBLIC_CPP_DECODE_H_ | 6 #define SERVICES_DATA_DECODER_PUBLIC_CPP_DECODE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "services/image_decoder/public/interfaces/image_decoder.mojom.h" | 12 #include "services/data_decoder/public/interfaces/image_decoder.mojom.h" |
13 | 13 |
14 namespace gfx { | 14 namespace gfx { |
15 class Size; | 15 class Size; |
16 } | 16 } |
17 | 17 |
18 namespace service_manager { | 18 namespace service_manager { |
19 class Connector; | 19 class Connector; |
20 } | 20 } |
21 | 21 |
22 namespace image_decoder { | 22 namespace data_decoder { |
23 | 23 |
24 const uint64_t kDefaultMaxSizeInBytes = 128 * 1024 * 1024; | 24 const uint64_t kDefaultMaxSizeInBytes = 128 * 1024 * 1024; |
25 | 25 |
26 // Helper function to decode an image via the image_decoder service. For images | 26 // Helper function to decode an image via the data_decoder service. For images |
27 // with multiple frames (e.g. ico files), a frame with a size as close as | 27 // with multiple frames (e.g. ico files), a frame with a size as close as |
28 // possible to |desired_image_frame_size| is chosen (tries to take one in larger | 28 // possible to |desired_image_frame_size| is chosen (tries to take one in larger |
29 // size if there's no precise match). Passing gfx::Size() as | 29 // size if there's no precise match). Passing gfx::Size() as |
30 // |desired_image_frame_size| is also supported and will result in chosing the | 30 // |desired_image_frame_size| is also supported and will result in chosing the |
31 // smallest available size. | 31 // smallest available size. |
32 // Upon completion, |callback| is invoked on the calling thread TaskRunner with | 32 // Upon completion, |callback| is invoked on the calling thread TaskRunner with |
33 // an SkBitmap argument. The SkBitmap will be null on failure and non-null on | 33 // an SkBitmap argument. The SkBitmap will be null on failure and non-null on |
34 // success. | 34 // success. |
35 void Decode(service_manager::Connector* connector, | 35 void DecodeImage(service_manager::Connector* connector, |
36 const std::vector<uint8_t>& encoded_bytes, | 36 const std::vector<uint8_t>& encoded_bytes, |
37 mojom::ImageCodec codec, | 37 mojom::ImageCodec codec, |
38 bool shrink_to_fit, | 38 bool shrink_to_fit, |
39 uint64_t max_size_in_bytes, | 39 uint64_t max_size_in_bytes, |
40 const gfx::Size& desired_image_frame_size, | 40 const gfx::Size& desired_image_frame_size, |
41 const mojom::ImageDecoder::DecodeImageCallback& callback); | 41 const mojom::ImageDecoder::DecodeImageCallback& callback); |
42 | 42 |
43 } // namespace image_decoder | 43 } // namespace data_decoder |
44 | 44 |
45 #endif // SERVICES_IMAGE_DECODER_PUBLIC_CPP_DECODE_H_ | 45 #endif // SERVICES_DATA_DECODER_PUBLIC_CPP_DECODE_H_ |
OLD | NEW |