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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 * FIXME: see skbug.com/3582. | 132 * FIXME: see skbug.com/3582. |
133 */ | 133 */ |
134 bool reallyHasAlpha() const { | 134 bool reallyHasAlpha() const { |
135 return this->onReallyHasAlpha(); | 135 return this->onReallyHasAlpha(); |
136 } | 136 } |
137 | 137 |
138 protected: | 138 protected: |
139 SkScanlineDecoder(const SkImageInfo& srcInfo) | 139 SkScanlineDecoder(const SkImageInfo& srcInfo) |
140 : fSrcInfo(srcInfo) | 140 : fSrcInfo(srcInfo) |
141 , fDstInfo() | 141 , fDstInfo() |
| 142 , fOptions() |
142 , fCurrScanline(0) {} | 143 , fCurrScanline(0) {} |
143 | 144 |
144 virtual bool onReallyHasAlpha() const { return false; } | 145 virtual bool onReallyHasAlpha() const { return false; } |
145 | 146 |
146 const SkImageInfo& dstInfo() const { return fDstInfo; } | 147 const SkImageInfo& dstInfo() const { return fDstInfo; } |
147 | 148 |
| 149 const SkCodec::Options& options() const { return fOptions; } |
| 150 |
148 private: | 151 private: |
149 const SkImageInfo fSrcInfo; | 152 const SkImageInfo fSrcInfo; |
150 SkImageInfo fDstInfo; | 153 SkImageInfo fDstInfo; |
| 154 SkCodec::Options fOptions; |
151 int fCurrScanline; | 155 int fCurrScanline; |
152 | 156 |
153 virtual SkCodec::Result onStart(const SkImageInfo& dstInfo, | 157 virtual SkCodec::Result onStart(const SkImageInfo& dstInfo, |
154 const SkCodec::Options& options, | 158 const SkCodec::Options& options, |
155 SkPMColor ctable[], int* ctableCount) = 0; | 159 SkPMColor ctable[], int* ctableCount) = 0; |
156 | 160 |
157 // Naive default version just calls onGetScanlines on temp memory. | 161 // Naive default version just calls onGetScanlines on temp memory. |
158 virtual SkCodec::Result onSkipScanlines(int countLines) { | 162 virtual SkCodec::Result onSkipScanlines(int countLines) { |
159 SkAutoMalloc storage(fDstInfo.minRowBytes()); | 163 SkAutoMalloc storage(fDstInfo.minRowBytes()); |
160 // Note that we pass 0 to rowBytes so we continue to use the same memory
. | 164 // Note that we pass 0 to rowBytes so we continue to use the same memory
. |
161 // Also note that while getScanlines checks that rowBytes is big enough, | 165 // Also note that while getScanlines checks that rowBytes is big enough, |
162 // onGetScanlines bypasses that check. | 166 // onGetScanlines bypasses that check. |
163 // Calling the virtual method also means we do not double count | 167 // Calling the virtual method also means we do not double count |
164 // countLines. | 168 // countLines. |
165 return this->onGetScanlines(storage.get(), countLines, 0); | 169 return this->onGetScanlines(storage.get(), countLines, 0); |
166 } | 170 } |
167 | 171 |
168 virtual SkCodec::Result onGetScanlines(void* dst, int countLines, | 172 virtual SkCodec::Result onGetScanlines(void* dst, int countLines, |
169 size_t rowBytes) = 0; | 173 size_t rowBytes) = 0; |
170 | 174 |
171 }; | 175 }; |
172 #endif // SkScanlineDecoder_DEFINED | 176 #endif // SkScanlineDecoder_DEFINED |
OLD | NEW |