OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2015 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #ifndef SkJpegCodec_DEFINED | |
9 #define SkJpegCodec_DEFINED | |
10 | |
11 #include "SkCodec.h" | |
12 #include "SkImageInfo.h" | |
13 #include "SkJpegAutoClean.h" | |
14 #include "SkJpegUtility.h" | |
15 #include "SkStream.h" | |
16 #include "jpeglib.h" | |
scroggo
2015/04/14 13:10:33
nit: We might keep this separate from the other in
msarett
2015/04/14 19:30:36
I will make sure to do that. Also, it turns out w
scroggo
2015/04/15 00:31:05
I wonder if that is because we're stuck on an old
| |
17 | |
18 /* | |
19 * | |
20 * This class implements the decoding for jpeg images | |
21 * | |
22 */ | |
23 class SkJpegCodec : public SkCodec { | |
24 public: | |
25 | |
26 /* | |
27 * Checks the start of the stream to see if the image is a jpeg | |
28 * Does not take ownership of the stream | |
29 */ | |
30 static bool IsJpeg(SkStream*); | |
31 | |
32 /* | |
33 * Assumes IsJpeg was called and returned true | |
34 * Creates a jpeg decoder | |
35 * Takes ownership of the stream | |
36 */ | |
37 static SkCodec* NewFromStream(SkStream*); | |
38 | |
39 protected: | |
40 | |
41 /* | |
42 * Recommend a set of destination dimensions given a requested scale | |
43 */ | |
44 SkISize onGetScaledDimensions(float desiredScale) const override; | |
45 | |
46 /* | |
47 * Initiates the jpeg decode | |
48 */ | |
49 Result onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes , const Options&, | |
50 SkPMColor*, int*) override; | |
51 | |
52 SkEncodedFormat onGetEncodedFormat() const override { | |
53 return kJPEG_SkEncodedFormat; | |
54 } | |
55 | |
56 private: | |
57 | |
58 /* | |
59 * Read enough of the stream to initialize the SkJpegCodec. | |
60 * Returns a bool representing success or failure. | |
61 * | |
62 * @param codecOut | |
63 * If it returned true, and codecOut was not NULL, | |
64 * codecOut will be set to a new SkJpegCodec. | |
65 * | |
66 * @param decodeMgrOut | |
67 * If it returned true, and codecOut was NULL, | |
68 * decodeMgrOut must be non-NULL and decodeMgrOut will be set to a new | |
69 * JpegAutoClean pointer. | |
70 * | |
71 * @param stream | |
72 * Deleted on failure. | |
73 * codecOut will take ownership of it in the case where we created a codec. | |
74 * Ownership is unchanged when we set decodeMgrOut. | |
75 * | |
76 */ | |
77 static bool ReadHeader(SkStream* stream, SkCodec** codecOut, | |
78 JpegAutoClean** decodeMgrOut); | |
79 | |
80 /* | |
81 * Creates an instance of the decoder | |
82 * Called only by NewFromStream | |
83 * | |
84 * @param srcInfo contains the source width and height | |
85 * @param stream the encoded image data | |
86 */ | |
87 SkJpegCodec(const SkImageInfo& srcInfo, SkStream* stream, JpegAutoClean* dec odeMgr); | |
scroggo
2015/04/14 13:10:33
@param decodeMgr Holds jpeg_decompress_struct etc.
msarett
2015/04/14 19:30:36
Done.
| |
88 | |
89 SkAutoTDelete<JpegAutoClean> fDecodeMgr; | |
90 | |
91 typedef SkCodec INHERITED; | |
92 }; | |
93 | |
94 #endif | |
OLD | NEW |