OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_GFX_CHROMEOS_CODEC_JPEG_CODEC_ROBUST_SLOW_H_ | |
6 #define UI_GFX_CHROMEOS_CODEC_JPEG_CODEC_ROBUST_SLOW_H_ | |
7 | |
8 #include <stddef.h> | |
9 #include <vector> | |
10 | |
11 #include "ui/gfx/gfx_export.h" | |
12 | |
13 class SkBitmap; | |
14 | |
15 namespace gfx { | |
16 | |
17 // Interface for encoding/decoding JPEG data. This is a wrapper around libjpeg, | |
18 // which has an inconvenient interface for callers. This is only used for | |
19 // servicing ChromeUtilityMsg_RobustJPEGDecodeImage and is currently unique | |
20 // to Chrome OS. | |
21 class GFX_EXPORT JPEGCodecRobustSlow { | |
22 public: | |
23 enum ColorFormat { | |
24 // 3 bytes per pixel (packed), in RGB order regardless of endianness. | |
25 // This is the native JPEG format. | |
26 FORMAT_RGB, | |
27 | |
28 // 4 bytes per pixel, in RGBA order in mem regardless of endianness. | |
29 FORMAT_RGBA, | |
30 | |
31 // 4 bytes per pixel, in BGRA order in mem regardless of endianness. | |
32 // This is the default Windows DIB order. | |
33 FORMAT_BGRA, | |
34 | |
35 // 4 bytes per pixel, it can be either RGBA or BGRA. It depends on the bit | |
36 // order in kARGB_8888_Config skia bitmap. | |
37 FORMAT_SkBitmap | |
38 }; | |
39 | |
40 // Decodes the JPEG data contained in input of length input_size. The | |
41 // decoded data will be placed in *output with the dimensions in *w and *h | |
42 // on success (returns true). This data will be written in the'format' | |
43 // format. On failure, the values of these output variables is undefined. | |
44 static bool Decode(const unsigned char* input, size_t input_size, | |
45 ColorFormat format, std::vector<unsigned char>* output, | |
46 int* w, int* h); | |
47 | |
48 // Decodes the JPEG data contained in input of length input_size. If | |
49 // successful, a SkBitmap is created and returned. It is up to the caller | |
50 // to delete the returned bitmap. | |
51 static SkBitmap* Decode(const unsigned char* input, size_t input_size); | |
52 }; | |
53 | |
54 } // namespace gfx | |
55 | |
56 #endif // UI_GFX_CHROMEOS_CODEC_JPEG_CODEC_ROBUST_SLOW_H_ | |
OLD | NEW |