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 #ifndef SkScanlineDecoder_DEFINED | 8 #ifndef SkScanlineDecoder_DEFINED |
9 #define SkScanlineDecoder_DEFINED | 9 #define SkScanlineDecoder_DEFINED |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 * of the encoded data, but then never use any colors which have alpha | 68 * of the encoded data, but then never use any colors which have alpha |
69 * less than 100%. This function can be called *after* decoding to | 69 * less than 100%. This function can be called *after* decoding to |
70 * determine if such an image truly had alpha. Calling it before decoding | 70 * determine if such an image truly had alpha. Calling it before decoding |
71 * is undefined. | 71 * is undefined. |
72 * FIXME: see skbug.com/3582. | 72 * FIXME: see skbug.com/3582. |
73 */ | 73 */ |
74 bool reallyHasAlpha() const { | 74 bool reallyHasAlpha() const { |
75 return this->onReallyHasAlpha(); | 75 return this->onReallyHasAlpha(); |
76 } | 76 } |
77 | 77 |
78 /** | |
79 * Returns whether the image is interlaced | |
scroggo
2015/07/30 17:53:01
These comments should match the name of the functi
| |
80 * For an interlaced image, calling getScanlines once (regardless of the cou nt | |
81 * used) needs to read the entire image, therefore it is inefficient to call | |
82 * getScanlines more than once. Instead, it should only ever be called with all the | |
83 * rows needed. | |
msarett
2015/07/30 13:55:38
I think this comment (and the one with onIsHardToS
emmaleer
2015/07/30 17:50:39
Acknowledged.
| |
84 */ | |
85 bool isHardToSample() { | |
86 return this->onIsHardToSample(); | |
87 } | |
88 | |
78 protected: | 89 protected: |
79 SkScanlineDecoder(const SkImageInfo& requested) | 90 SkScanlineDecoder(const SkImageInfo& requested) |
80 : fDstInfo(requested) | 91 : fDstInfo(requested) |
81 , fCurrScanline(0) {} | 92 , fCurrScanline(0) {} |
82 | 93 |
83 virtual bool onReallyHasAlpha() const { return false; } | 94 virtual bool onReallyHasAlpha() const { return false; } |
84 | 95 |
96 /** | |
97 * returns true if the image type is hard to sample and must be scaled after reading, not during | |
98 * An example is interlaced pngs, where the entire image must be read for ea ch decode | |
99 */ | |
100 virtual bool onIsHardToSample() { return false; } | |
101 | |
85 const SkImageInfo& dstInfo() const { return fDstInfo; } | 102 const SkImageInfo& dstInfo() const { return fDstInfo; } |
86 | 103 |
87 private: | 104 private: |
88 const SkImageInfo fDstInfo; | 105 const SkImageInfo fDstInfo; |
89 int fCurrScanline; | 106 int fCurrScanline; |
90 | 107 |
91 // Naive default version just calls onGetScanlines on temp memory. | 108 // Naive default version just calls onGetScanlines on temp memory. |
92 virtual SkCodec::Result onSkipScanlines(int countLines) { | 109 virtual SkCodec::Result onSkipScanlines(int countLines) { |
93 SkAutoMalloc storage(fDstInfo.minRowBytes()); | 110 SkAutoMalloc storage(fDstInfo.minRowBytes()); |
94 // Note that we pass 0 to rowBytes so we continue to use the same memory . | 111 // Note that we pass 0 to rowBytes so we continue to use the same memory . |
95 // Also note that while getScanlines checks that rowBytes is big enough, | 112 // Also note that while getScanlines checks that rowBytes is big enough, |
96 // onGetScanlines bypasses that check. | 113 // onGetScanlines bypasses that check. |
97 // Calling the virtual method also means we do not double count | 114 // Calling the virtual method also means we do not double count |
98 // countLines. | 115 // countLines. |
99 return this->onGetScanlines(storage.get(), countLines, 0); | 116 return this->onGetScanlines(storage.get(), countLines, 0); |
100 } | 117 } |
101 | 118 |
102 virtual SkCodec::Result onGetScanlines(void* dst, int countLines, | 119 virtual SkCodec::Result onGetScanlines(void* dst, int countLines, |
103 size_t rowBytes) = 0; | 120 size_t rowBytes) = 0; |
104 | 121 |
105 }; | 122 }; |
106 #endif // SkScanlineDecoder_DEFINED | 123 #endif // SkScanlineDecoder_DEFINED |
OLD | NEW |