OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkJpegCodec_DEFINED | 8 #ifndef SkJpegCodec_DEFINED |
9 #define SkJpegCodec_DEFINED | 9 #define SkJpegCodec_DEFINED |
10 | 10 |
11 #include "SkCodec.h" | 11 #include "SkCodec.h" |
12 #include "SkImageInfo.h" | 12 #include "SkImageInfo.h" |
13 #include "SkJpegDecoderMgr.h" | 13 #include "SkJpegDecoderMgr.h" |
14 #include "SkJpegUtility_codec.h" | 14 #include "SkJpegUtility_codec.h" |
15 #include "SkStream.h" | 15 #include "SkStream.h" |
16 | 16 |
17 extern "C" { | 17 extern "C" { |
18 #include "jpeglib.h" | 18 #include "jpeglib.h" |
19 } | 19 } |
20 | 20 |
| 21 class SkScanlineDecoder; |
| 22 |
21 /* | 23 /* |
22 * | 24 * |
23 * This class implements the decoding for jpeg images | 25 * This class implements the decoding for jpeg images |
24 * | 26 * |
25 */ | 27 */ |
26 class SkJpegCodec : public SkCodec { | 28 class SkJpegCodec : public SkCodec { |
27 public: | 29 public: |
28 | 30 |
29 /* | 31 /* |
30 * Checks the start of the stream to see if the image is a jpeg | 32 * Checks the start of the stream to see if the image is a jpeg |
31 * Does not take ownership of the stream | 33 * Does not take ownership of the stream |
32 */ | 34 */ |
33 static bool IsJpeg(SkStream*); | 35 static bool IsJpeg(SkStream*); |
34 | 36 |
35 /* | 37 /* |
36 * Assumes IsJpeg was called and returned true | 38 * Assumes IsJpeg was called and returned true |
37 * Creates a jpeg decoder | 39 * Creates a jpeg decoder |
38 * Takes ownership of the stream | 40 * Takes ownership of the stream |
39 */ | 41 */ |
40 static SkCodec* NewFromStream(SkStream*); | 42 static SkCodec* NewFromStream(SkStream*); |
41 | 43 |
| 44 /* |
| 45 * Assumes IsJpeg was called and returned true |
| 46 * Creates a jpeg scanline decoder |
| 47 * Takes ownership of the stream |
| 48 */ |
| 49 static SkScanlineDecoder* NewSDFromStream(SkStream*); |
| 50 |
42 protected: | 51 protected: |
43 | 52 |
44 /* | 53 /* |
45 * Recommend a set of destination dimensions given a requested scale | 54 * Recommend a set of destination dimensions given a requested scale |
46 */ | 55 */ |
47 SkISize onGetScaledDimensions(float desiredScale) const override; | 56 SkISize onGetScaledDimensions(float desiredScale) const override; |
48 | 57 |
49 /* | 58 /* |
50 * Initiates the jpeg decode | 59 * Initiates the jpeg decode |
51 */ | 60 */ |
52 Result onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes
, const Options&, | 61 Result onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes
, const Options&, |
53 SkPMColor*, int*) override; | 62 SkPMColor*, int*) override; |
54 | 63 |
55 SkEncodedFormat onGetEncodedFormat() const override { | 64 SkEncodedFormat onGetEncodedFormat() const override { |
56 return kJPEG_SkEncodedFormat; | 65 return kJPEG_SkEncodedFormat; |
57 } | 66 } |
58 | 67 |
59 SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo, const Op
tions& options, | |
60 SkPMColor ctable[], int* ctableCount) override; | |
61 | |
62 private: | 68 private: |
63 | 69 |
64 /* | 70 /* |
65 * Read enough of the stream to initialize the SkJpegCodec. | 71 * Read enough of the stream to initialize the SkJpegCodec. |
66 * Returns a bool representing success or failure. | 72 * Returns a bool representing success or failure. |
67 * | 73 * |
68 * @param codecOut | 74 * @param codecOut |
69 * If this returns true, and codecOut was not NULL, | 75 * If this returns true, and codecOut was not NULL, |
70 * codecOut will be set to a new SkJpegCodec. | 76 * codecOut will be set to a new SkJpegCodec. |
71 * | 77 * |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 const Options& options); | 125 const Options& options); |
120 | 126 |
121 SkAutoTDelete<JpegDecoderMgr> fDecoderMgr; | 127 SkAutoTDelete<JpegDecoderMgr> fDecoderMgr; |
122 | 128 |
123 friend class SkJpegScanlineDecoder; | 129 friend class SkJpegScanlineDecoder; |
124 | 130 |
125 typedef SkCodec INHERITED; | 131 typedef SkCodec INHERITED; |
126 }; | 132 }; |
127 | 133 |
128 #endif | 134 #endif |
OLD | NEW |