| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 UI_GFX_CODEC_JPEG_CODEC_H_ | 5 #ifndef UI_GFX_CODEC_JPEG_CODEC_H_ |
| 6 #define UI_GFX_CODEC_JPEG_CODEC_H_ | 6 #define UI_GFX_CODEC_JPEG_CODEC_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "ui/gfx/codec/codec_export.h" | 13 #include "ui/gfx/codec/codec_export.h" |
| 14 | 14 |
| 15 class SkBitmap; | 15 class SkBitmap; |
| 16 | 16 |
| 17 namespace gfx { | 17 namespace gfx { |
| 18 | 18 |
| 19 // Interface for encoding/decoding JPEG data. This is a wrapper around libjpeg, | 19 // Interface for encoding/decoding JPEG data. This is a wrapper around libjpeg, |
| 20 // which has an inconvenient interface for callers. This is only used for UI | 20 // which has an inconvenient interface for callers. This is only used for UI |
| 21 // elements, WebKit has its own more complicated JPEG decoder which handles, | 21 // elements, WebKit has its own more complicated JPEG decoder which handles, |
| 22 // among other things, partially downloaded data. | 22 // among other things, partially downloaded data. |
| 23 class CODEC_EXPORT JPEGCodec { | 23 class CODEC_EXPORT JPEGCodec { |
| 24 public: | 24 public: |
| 25 enum ColorFormat { | 25 enum ColorFormat { |
| 26 // 3 bytes per pixel (packed), in RGB order regardless of endianness. |
| 27 // This is the native JPEG format. |
| 28 FORMAT_RGB, |
| 29 |
| 26 // 4 bytes per pixel, in RGBA order in mem regardless of endianness. | 30 // 4 bytes per pixel, in RGBA order in mem regardless of endianness. |
| 27 FORMAT_RGBA, | 31 FORMAT_RGBA, |
| 28 | 32 |
| 29 // 4 bytes per pixel, in BGRA order in mem regardless of endianness. | 33 // 4 bytes per pixel, in BGRA order in mem regardless of endianness. |
| 30 // This is the default Windows DIB order. | 34 // This is the default Windows DIB order. |
| 31 FORMAT_BGRA, | 35 FORMAT_BGRA, |
| 32 | 36 |
| 33 // 4 bytes per pixel, it can be either RGBA or BGRA. It depends on the bit | 37 // 4 bytes per pixel, it can be either RGBA or BGRA. It depends on the bit |
| 34 // order in kARGB_8888_Config skia bitmap. | 38 // order in kARGB_8888_Config skia bitmap. |
| 35 FORMAT_SkBitmap | 39 FORMAT_SkBitmap |
| 36 }; | 40 }; |
| 37 | 41 |
| 42 enum LibraryVariant { |
| 43 SYSTEM_LIBJPEG = 0, |
| 44 LIBJPEG_TURBO, |
| 45 IJG_LIBJPEG, |
| 46 }; |
| 47 |
| 48 // This method helps identify at run time which library chromium is using. |
| 49 static LibraryVariant JpegLibraryVariant(); |
| 50 |
| 38 // Encodes the given raw 'input' data, with each pixel being represented as | 51 // Encodes the given raw 'input' data, with each pixel being represented as |
| 39 // given in 'format'. The encoded JPEG data will be written into the supplied | 52 // given in 'format'. The encoded JPEG data will be written into the supplied |
| 40 // vector and true will be returned on success. On failure (false), the | 53 // vector and true will be returned on success. On failure (false), the |
| 41 // contents of the output buffer are undefined. | 54 // contents of the output buffer are undefined. |
| 42 // | 55 // |
| 43 // w, h: dimensions of the image | 56 // w, h: dimensions of the image |
| 44 // row_byte_width: the width in bytes of each row. This may be greater than | 57 // row_byte_width: the width in bytes of each row. This may be greater than |
| 45 // w * bytes_per_pixel if there is extra padding at the end of each row | 58 // w * bytes_per_pixel if there is extra padding at the end of each row |
| 46 // (often, each row is padded to the next machine word). | 59 // (often, each row is padded to the next machine word). |
| 47 // quality: an integer in the range 0-100, where 100 is the highest quality. | 60 // quality: an integer in the range 0-100, where 100 is the highest quality. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 59 | 72 |
| 60 // Decodes the JPEG data contained in input of length input_size. If | 73 // Decodes the JPEG data contained in input of length input_size. If |
| 61 // successful, a SkBitmap is created and returned. | 74 // successful, a SkBitmap is created and returned. |
| 62 static std::unique_ptr<SkBitmap> Decode(const unsigned char* input, | 75 static std::unique_ptr<SkBitmap> Decode(const unsigned char* input, |
| 63 size_t input_size); | 76 size_t input_size); |
| 64 }; | 77 }; |
| 65 | 78 |
| 66 } // namespace gfx | 79 } // namespace gfx |
| 67 | 80 |
| 68 #endif // UI_GFX_CODEC_JPEG_CODEC_H_ | 81 #endif // UI_GFX_CODEC_JPEG_CODEC_H_ |
| OLD | NEW |