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 #include "SkCodec.h" | 8 #include "SkCodec.h" |
9 #include "SkColorTable.h" | 9 #include "SkColorTable.h" |
10 #include "SkEncodedFormat.h" | 10 #include "SkEncodedFormat.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
29 static SkCodec* NewFromStream(SkStream*); | 29 static SkCodec* NewFromStream(SkStream*); |
30 static SkScanlineDecoder* NewSDFromStream(SkStream*); | 30 static SkScanlineDecoder* NewSDFromStream(SkStream*); |
31 | 31 |
32 virtual ~SkPngCodec(); | 32 virtual ~SkPngCodec(); |
33 | 33 |
34 protected: | 34 protected: |
35 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo lor*, int*) | 35 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo lor*, int*) |
36 override; | 36 override; |
37 SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedF ormat; } | 37 SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedF ormat; } |
38 bool onRewind() override; | 38 bool onRewind() override; |
39 bool onReallyHasAlpha() const override { return fReallyHasAlpha; } | 39 bool onReallyHasAlpha() const final; |
40 | |
41 // Helper to set up swizzler and color table. Also calls png_read_update_inf o. | |
42 Result initializeSwizzler(const SkImageInfo& requestedInfo, const Options&, | |
43 SkPMColor*, int* ctableCount); | |
44 | |
45 SkPngCodec(const SkImageInfo&, SkStream*, png_structp, png_infop, int, int); | |
46 | |
47 png_structp png_ptr() { return fPng_ptr; } | |
48 // FIXME: I think the subclass does not need this. | |
49 //png_infop info_ptr() { return fInfo_ptr; } | |
scroggo
2015/09/25 16:07:50
Will remove in next patch set.
| |
50 SkSwizzler* swizzler() { return fSwizzler; } | |
51 SkSwizzler::SrcConfig srcConfig() const { return fSrcConfig; } | |
52 int numberPasses() const { return fNumberPasses; } | |
53 | |
54 enum AlphaState { | |
msarett
2015/09/28 14:48:50
I think this is good.
Not in this CL, but maybe i
scroggo
2015/09/28 16:01:52
Yeah, no other codecs currently do any checking, b
| |
55 // This class has done no decoding, or threw away its knowledge (in | |
56 // scanline decodes). | |
57 kUnknown_AlphaState, | |
58 // This class found the image (possibly partial, in the case of a | |
59 // scanline decode) to be opaque. | |
60 kOpaque_AlphaState, | |
61 // Ths class found the image to have alpha. | |
62 kHasAlpha_AlphaState, | |
63 }; | |
64 | |
65 virtual AlphaState alphaInScanlineDecode() const = 0; | |
40 | 66 |
41 private: | 67 private: |
42 png_structp fPng_ptr; | 68 png_structp fPng_ptr; |
43 png_infop fInfo_ptr; | 69 png_infop fInfo_ptr; |
44 | 70 |
45 // These are stored here so they can be used both by normal decoding and sca nline decoding. | 71 // These are stored here so they can be used both by normal decoding and sca nline decoding. |
46 SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul. | 72 SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul. |
47 SkAutoTDelete<SkSwizzler> fSwizzler; | 73 SkAutoTDelete<SkSwizzler> fSwizzler; |
48 | 74 |
49 SkSwizzler::SrcConfig fSrcConfig; | 75 SkSwizzler::SrcConfig fSrcConfig; |
50 int fNumberPasses; | 76 const int fNumberPasses; |
51 bool fReallyHasAlpha; | |
52 int fBitDepth; | 77 int fBitDepth; |
53 | 78 |
54 SkPngCodec(const SkImageInfo&, SkStream*, png_structp, png_infop, int); | 79 AlphaState fAlphaState; |
55 | |
56 // Helper to set up swizzler and color table. Also calls png_read_update_inf o. | |
57 Result initializeSwizzler(const SkImageInfo& requestedInfo, const Options&, | |
58 SkPMColor*, int* ctableCount); | |
59 | 80 |
60 bool decodePalette(bool premultiply, int* ctableCount); | 81 bool decodePalette(bool premultiply, int* ctableCount); |
61 void destroyReadStruct(); | 82 void destroyReadStruct(); |
62 | 83 |
63 friend class SkPngScanlineDecoder; | |
64 friend class SkPngInterlacedScanlineDecoder; | |
65 | |
66 typedef SkCodec INHERITED; | 84 typedef SkCodec INHERITED; |
67 }; | 85 }; |
OLD | NEW |