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 12 matching lines...) Expand all Loading... |
23 | 23 |
24 class SkPngCodec : public SkCodec { | 24 class SkPngCodec : public SkCodec { |
25 public: | 25 public: |
26 // Assumes IsPng was called and returned true. | 26 // Assumes IsPng was called and returned true. |
27 static SkCodec* NewFromStream(SkStream*); | 27 static SkCodec* NewFromStream(SkStream*); |
28 static bool IsPng(SkStream*); | 28 static bool IsPng(SkStream*); |
29 protected: | 29 protected: |
30 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo
lor*, int*) | 30 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo
lor*, int*) |
31 override; | 31 override; |
32 SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedF
ormat; } | 32 SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedF
ormat; } |
33 SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo) override
; | 33 SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo, const Op
tions& options, |
| 34 SkPMColor ctable[], int* ctableCount
) override; |
34 bool onReallyHasAlpha() const override { return fReallyHasAlpha; } | 35 bool onReallyHasAlpha() const override { return fReallyHasAlpha; } |
35 private: | 36 private: |
36 png_structp fPng_ptr; | 37 png_structp fPng_ptr; |
37 png_infop fInfo_ptr; | 38 png_infop fInfo_ptr; |
38 | 39 |
39 // These are stored here so they can be used both by normal decoding and sca
nline decoding. | 40 // These are stored here so they can be used both by normal decoding and sca
nline decoding. |
40 SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul. | 41 SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul. |
41 SkAutoTDelete<SkSwizzler> fSwizzler; | 42 SkAutoTDelete<SkSwizzler> fSwizzler; |
42 | 43 |
43 SkSwizzler::SrcConfig fSrcConfig; | 44 SkSwizzler::SrcConfig fSrcConfig; |
44 int fNumberPasses; | 45 int fNumberPasses; |
45 bool fReallyHasAlpha; | 46 bool fReallyHasAlpha; |
46 | 47 |
47 SkPngCodec(const SkImageInfo&, SkStream*, png_structp, png_infop); | 48 SkPngCodec(const SkImageInfo&, SkStream*, png_structp, png_infop); |
48 ~SkPngCodec(); | 49 ~SkPngCodec(); |
49 | 50 |
50 // Helper to set up swizzler and color table. Also calls png_read_update_inf
o. | 51 // Helper to set up swizzler and color table. Also calls png_read_update_inf
o. |
51 Result initializeSwizzler(const SkImageInfo& requestedInfo, void* dst, | 52 Result initializeSwizzler(const SkImageInfo& requestedInfo, void* dst, |
52 size_t rowBytes, const Options&, int* ctableCount)
; | 53 size_t rowBytes, const Options&, SkPMColor*, int*
ctableCount); |
53 // Calls rewindIfNeeded, and returns true if the decoder can continue. | 54 // Calls rewindIfNeeded, and returns true if the decoder can continue. |
54 bool handleRewind(); | 55 bool handleRewind(); |
55 bool decodePalette(bool premultiply, int bitDepth, int* ctableCount); | 56 bool decodePalette(bool premultiply, int bitDepth, int* ctableCount); |
56 void finish(); | 57 void finish(); |
57 void destroyReadStruct(); | 58 void destroyReadStruct(); |
58 | 59 |
59 friend class SkPngScanlineDecoder; | 60 friend class SkPngScanlineDecoder; |
60 | 61 |
61 typedef SkCodec INHERITED; | 62 typedef SkCodec INHERITED; |
62 }; | 63 }; |
OLD | NEW |