Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: ui/gfx/chromeos/codec/jpeg_codec_robust_slow.h

Issue 569623002: Switch ChromeOS Chromium login to use IJG libjpeg (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: JPEGCodecRobustSlow Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
sky 2015/05/06 21:44:27 2015 and no c.
Ed Baker 2015/05/07 00:31:41 Done.
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_CHROMEOS_CODEC_JPEG_CODEC_ROBUST_SLOW_H_
6 #define UI_GFX_CODEC_JPEG_CODEC_H_ 6 #define UI_GFX_CHROMEOS_CODEC_JPEG_CODEC_ROBUST_SLOW_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ui/gfx/gfx_export.h" 11 #include "ui/gfx/gfx_export.h"
12 12
13 class SkBitmap; 13 class SkBitmap;
14 14
15 namespace gfx { 15 namespace gfx {
16 16
17 // Interface for encoding/decoding JPEG data. This is a wrapper around libjpeg, 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 UI 18 // which has an inconvenient interface for callers. This is only used for
19 // elements, WebKit has its own more complicated JPEG decoder which handles, 19 // servicing ChromeUtilityMsg_RobustJPEGDecodeImage and is currently unique
20 // among other things, partially downloaded data. 20 // to Chrome OS.
21 class GFX_EXPORT JPEGCodec { 21 class GFX_EXPORT JPEGCodecRobustSlow {
sky 2015/05/06 21:44:27 Similar comment about name.
Ed Baker 2015/05/07 00:31:41 Acknowledged.
22 public: 22 public:
23 enum ColorFormat { 23 enum ColorFormat {
24 // 3 bytes per pixel (packed), in RGB order regardless of endianness. 24 // 3 bytes per pixel (packed), in RGB order regardless of endianness.
25 // This is the native JPEG format. 25 // This is the native JPEG format.
26 FORMAT_RGB, 26 FORMAT_RGB,
27 27
28 // 4 bytes per pixel, in RGBA order in mem regardless of endianness. 28 // 4 bytes per pixel, in RGBA order in mem regardless of endianness.
29 FORMAT_RGBA, 29 FORMAT_RGBA,
30 30
31 // 4 bytes per pixel, in BGRA order in mem regardless of endianness. 31 // 4 bytes per pixel, in BGRA order in mem regardless of endianness.
32 // This is the default Windows DIB order. 32 // This is the default Windows DIB order.
33 FORMAT_BGRA, 33 FORMAT_BGRA,
34 34
35 // 4 bytes per pixel, it can be either RGBA or BGRA. It depends on the bit 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. 36 // order in kARGB_8888_Config skia bitmap.
37 FORMAT_SkBitmap 37 FORMAT_SkBitmap
38 }; 38 };
39 39
40 enum LibraryVariant {
41 SYSTEM_LIBJPEG = 0,
42 LIBJPEG_TURBO,
43 IJG_LIBJPEG,
44 };
45
46 // This method helps identify at run time which library chromium is using.
47 static LibraryVariant JpegLibraryVariant();
48
49 // Encodes the given raw 'input' data, with each pixel being represented as
50 // given in 'format'. The encoded JPEG data will be written into the supplied
51 // vector and true will be returned on success. On failure (false), the
52 // contents of the output buffer are undefined.
53 //
54 // w, h: dimensions of the image
55 // row_byte_width: the width in bytes of each row. This may be greater than
56 // w * bytes_per_pixel if there is extra padding at the end of each row
57 // (often, each row is padded to the next machine word).
58 // quality: an integer in the range 0-100, where 100 is the highest quality.
59 static bool Encode(const unsigned char* input, ColorFormat format,
60 int w, int h, int row_byte_width,
61 int quality, std::vector<unsigned char>* output);
62
63 // Decodes the JPEG data contained in input of length input_size. The 40 // Decodes the JPEG data contained in input of length input_size. The
64 // decoded data will be placed in *output with the dimensions in *w and *h 41 // decoded data will be placed in *output with the dimensions in *w and *h
65 // on success (returns true). This data will be written in the'format' 42 // on success (returns true). This data will be written in the'format'
66 // format. On failure, the values of these output variables is undefined. 43 // format. On failure, the values of these output variables is undefined.
67 static bool Decode(const unsigned char* input, size_t input_size, 44 static bool Decode(const unsigned char* input, size_t input_size,
68 ColorFormat format, std::vector<unsigned char>* output, 45 ColorFormat format, std::vector<unsigned char>* output,
69 int* w, int* h); 46 int* w, int* h);
70 47
71 // Decodes the JPEG data contained in input of length input_size. If 48 // Decodes the JPEG data contained in input of length input_size. If
72 // successful, a SkBitmap is created and returned. It is up to the caller 49 // successful, a SkBitmap is created and returned. It is up to the caller
73 // to delete the returned bitmap. 50 // to delete the returned bitmap.
74 static SkBitmap* Decode(const unsigned char* input, size_t input_size); 51 static SkBitmap* Decode(const unsigned char* input, size_t input_size);
75 }; 52 };
76 53
77 } // namespace gfx 54 } // namespace gfx
78 55
79 #endif // UI_GFX_CODEC_JPEG_CODEC_H_ 56 #endif // UI_GFX_CHROMEOS_CODEC_JPEG_CODEC_ROBUST_SLOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698