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

Side by Side Diff: src/codec/SkJpegCodec.h

Issue 1076923002: SkJpegCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@gif-real
Patch Set: SkJpegCodec Created 5 years, 8 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
(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 "SkStream.h"
15 extern "C" {
16 #include "jpeglib.h"
17 }
18
19 /*
20 *
21 * This class implements the decoding for jpeg images
22 *
23 */
24 class SkJpegCodec : public SkCodec {
25 public:
26
27 /*
28 * Checks the start of the stream to see if the image is a jpeg
29 * Does not take ownership of the stream
30 */
31 static bool IsJpeg(SkStream*);
32
33 /*
34 * Assumes IsJpeg was called and returned true
35 * Creates a jpeg decoder
36 * Takes ownership of the stream
37 */
38 static SkCodec* NewFromStream(SkStream*);
39
40
41 protected:
42
43 /*
44 * Recommend a set of destination dimensions given a requested scale
45 */
46 SkISize onGetScaledDimensions(float desiredScale) const override;
47
48 /*
49 * Initiates the jpeg decode
50 */
51 Result onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes , const Options&,
52 SkPMColor*, int*) override;
53
54 SkEncodedFormat onGetEncodedFormat() const override {
55 return kJPEG_SkEncodedFormat;
56 }
57
58 private:
59
60 /*
61 * Read enough of the stream to initialize the SkJpegCodec.
62 * Returns a bool representing success or failure.
63 *
64 * @param codecOut
65 * If it returned true, and codecOut was not NULL,
66 * codecOut will be set to a new SkJpegCodec.
67 *
68 * @param jpegInfoOut
69 * If it returned true, and codecOut was NULL,
70 * jpegInfoOut must be non-NULL and jpegInfoOut will be set to a new
71 * jpeg_decompress_struct pointer.
72 *
73 * @param stream
74 * Deleted on failure.
75 * codecOut will take ownership of it in the case where we created a codec.
76 * Ownership is unchanged when we return a jpegInfoOut.
77 *
78 */
79 static bool ReadHeader(SkStream* stream, SkCodec** codecOut,
80 jpeg_decompress_struct** jpegInfoOut);
81
82 /*
83 * Creates an instance of the decoder
84 * Called only by NewFromStream
85 *
86 * @param srcInfo contains the source width and height
87 * @param stream the encoded image data
88 */
89 SkJpegCodec(const SkImageInfo& srcInfo, SkStream* stream, jpeg_decompress_st ruct* jpegInfo);
90
91 JpegAutoClean fJpegInfo;
92
93 typedef SkCodec INHERITED;
94 };
95
96 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698