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 "SkColorSpaceXform.h" | 9 #include "SkColorSpaceXform.h" |
10 #include "SkColorTable.h" | 10 #include "SkColorTable.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 void* fPtr; | 39 void* fPtr; |
40 }; | 40 }; |
41 | 41 |
42 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo lor*, int*, int*) | 42 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo lor*, int*, int*) |
43 override; | 43 override; |
44 SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedF ormat; } | 44 SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedF ormat; } |
45 bool onRewind() override; | 45 bool onRewind() override; |
46 uint32_t onGetFillValue(SkColorType) const override; | 46 uint32_t onGetFillValue(SkColorType) const override; |
47 | 47 |
48 // Helper to set up swizzler, color xforms, and color table. Also calls png_ read_update_info. | 48 // Helper to set up swizzler, color xforms, and color table. Also calls png_ read_update_info. |
49 bool initializeXforms(const SkImageInfo& requestedInfo, const Options&, SkPM Color* colorPtr, | 49 bool initializeXforms(const SkImageInfo& dstInfo, const Options&, SkPMColor* colorPtr, |
50 int* colorCount); | 50 int* colorCount); |
51 SkSampler* getSampler(bool createIfNecessary) override { | 51 void initializeSwizzler(const SkImageInfo& dstInfo, const Options&); |
52 SkASSERT(fSwizzler); | 52 SkSampler* getSampler(bool createIfNecessary) override; |
53 return fSwizzler; | 53 void allocateStorage(const SkImageInfo& dstInfo); |
54 } | 54 void applyXformRow(void* dst, const void* src, SkColorType, SkAlphaType, int width); |
55 void allocateStorage(); | |
56 | 55 |
57 virtual int readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, int count, | 56 virtual int readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, int count, |
58 int startRow) = 0; | 57 int startRow) = 0; |
59 | 58 |
60 SkPngCodec(const SkEncodedInfo&, const SkImageInfo&, SkStream*, SkPngChunkRe ader*, | 59 SkPngCodec(const SkEncodedInfo&, const SkImageInfo&, SkStream*, SkPngChunkRe ader*, |
61 void* png_ptr, void* info_ptr, int, int); | 60 void* png_ptr, void* info_ptr, int, int); |
62 | 61 |
63 SkAutoTUnref<SkPngChunkReader> fPngChunkReader; | 62 SkAutoTUnref<SkPngChunkReader> fPngChunkReader; |
64 voidp fPng_ptr; | 63 voidp fPng_ptr; |
65 voidp fInfo_ptr; | 64 voidp fInfo_ptr; |
66 | 65 |
67 // These are stored here so they can be used both by normal decoding and sca nline decoding. | 66 // These are stored here so they can be used both by normal decoding and sca nline decoding. |
68 SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul. | 67 SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul. |
69 SkAutoTDelete<SkSwizzler> fSwizzler; | 68 SkAutoTDelete<SkSwizzler> fSwizzler; |
70 std::unique_ptr<SkColorSpaceXform> fColorXform; | 69 std::unique_ptr<SkColorSpaceXform> fColorXform; |
71 SkAutoTMalloc<uint8_t> fStorage; | 70 SkAutoTMalloc<uint8_t> fStorage; |
72 uint8_t* fSwizzlerSrcRow; | 71 uint8_t* fSwizzlerSrcRow; |
73 uint32_t* fColorXformSrcRow; | 72 uint32_t* fColorXformSrcRow; |
74 size_t fSrcRowBytes; | 73 size_t fSrcRowBytes; |
75 | 74 |
76 const int fNumberPasses; | 75 const int fNumberPasses; |
77 int fBitDepth; | 76 int fBitDepth; |
78 | 77 |
79 private: | 78 private: |
79 | |
80 enum XformMode { | |
msarett
2016/08/26 16:37:45
There are two more cases where we are not quite op
| |
81 // Requires only a swizzle pass. | |
82 kSwizzleOnly_XformMode, | |
83 | |
84 // Requires only a color xform pass. | |
85 kColorOnly_XformMode, | |
86 | |
87 // Requires a swizzle and a color xform. | |
88 kSwizzleColor_XformMode, | |
89 }; | |
90 | |
80 bool createColorTable(const SkImageInfo& dstInfo, int* ctableCount); | 91 bool createColorTable(const SkImageInfo& dstInfo, int* ctableCount); |
81 void destroyReadStruct(); | 92 void destroyReadStruct(); |
82 | 93 |
94 XformMode fXformMode; | |
95 | |
83 typedef SkCodec INHERITED; | 96 typedef SkCodec INHERITED; |
84 }; | 97 }; |
OLD | NEW |