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 14 matching lines...) Expand all Loading... |
25 public: | 25 public: |
26 static bool IsPng(SkStream*); | 26 static bool IsPng(SkStream*); |
27 | 27 |
28 // Assume IsPng was called and returned true. | 28 // Assume IsPng was called and returned true. |
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*, 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 uint32_t onGetFillValue(SkColorType colorType, SkAlphaType alphaType) const
override; |
39 bool onReallyHasAlpha() const final; | 40 bool onReallyHasAlpha() const final; |
40 | 41 |
41 // Helper to set up swizzler and color table. Also calls png_read_update_inf
o. | 42 // Helper to set up swizzler and color table. Also calls png_read_update_inf
o. |
42 Result initializeSwizzler(const SkImageInfo& requestedInfo, const Options&, | 43 Result initializeSwizzler(const SkImageInfo& requestedInfo, const Options&, |
43 SkPMColor*, int* ctableCount); | 44 SkPMColor*, int* ctableCount); |
44 SkSampler* getSampler() override { return fSwizzler; } | 45 SkSampler* getSampler(bool createIfNecessary) override { |
| 46 SkASSERT(fSwizzler); |
| 47 return fSwizzler; |
| 48 } |
45 | 49 |
46 SkPngCodec(const SkImageInfo&, SkStream*, png_structp, png_infop, int, int); | 50 SkPngCodec(const SkImageInfo&, SkStream*, png_structp, png_infop, int, int); |
47 | 51 |
48 png_structp png_ptr() { return fPng_ptr; } | 52 png_structp png_ptr() { return fPng_ptr; } |
49 SkSwizzler* swizzler() { return fSwizzler; } | 53 SkSwizzler* swizzler() { return fSwizzler; } |
50 SkSwizzler::SrcConfig srcConfig() const { return fSrcConfig; } | 54 SkSwizzler::SrcConfig srcConfig() const { return fSrcConfig; } |
51 int numberPasses() const { return fNumberPasses; } | 55 int numberPasses() const { return fNumberPasses; } |
52 | 56 |
53 enum AlphaState { | 57 enum AlphaState { |
54 // This class has done no decoding, or threw away its knowledge (in | 58 // This class has done no decoding, or threw away its knowledge (in |
(...skipping 20 matching lines...) Expand all Loading... |
75 const int fNumberPasses; | 79 const int fNumberPasses; |
76 int fBitDepth; | 80 int fBitDepth; |
77 | 81 |
78 AlphaState fAlphaState; | 82 AlphaState fAlphaState; |
79 | 83 |
80 bool decodePalette(bool premultiply, int* ctableCount); | 84 bool decodePalette(bool premultiply, int* ctableCount); |
81 void destroyReadStruct(); | 85 void destroyReadStruct(); |
82 | 86 |
83 typedef SkCodec INHERITED; | 87 typedef SkCodec INHERITED; |
84 }; | 88 }; |
OLD | NEW |