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 SkCodec_DEFINED | 8 #ifndef SkCodec_DEFINED |
9 #define SkCodec_DEFINED | 9 #define SkCodec_DEFINED |
10 | 10 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 * of the encoded data, but then never use any colors which have alpha | 218 * of the encoded data, but then never use any colors which have alpha |
219 * less than 100%. This function can be called *after* decoding to | 219 * less than 100%. This function can be called *after* decoding to |
220 * determine if such an image truly had alpha. Calling it before decoding | 220 * determine if such an image truly had alpha. Calling it before decoding |
221 * is undefined. | 221 * is undefined. |
222 * FIXME: see skbug.com/3582. | 222 * FIXME: see skbug.com/3582. |
223 */ | 223 */ |
224 bool reallyHasAlpha() const { | 224 bool reallyHasAlpha() const { |
225 return this->onReallyHasAlpha(); | 225 return this->onReallyHasAlpha(); |
226 } | 226 } |
227 | 227 |
228 /** | |
229 * @return the value with which to fill uninitialized pixels. | |
230 * | |
231 * This is used when onGetScanlines() returns kIncompleteInput. | |
232 * | |
233 * Note that we can interpret the return value as an SkPMColor, a 16-bit 565 color, | |
234 * an 8-bit gray color, or an 8-bit index into a color table, depending on t he color | |
235 * type specified in dstInfo. | |
236 */ | |
237 uint32_t getFillValue(const SkImageInfo& dstInfo) const { | |
scroggo
2015/09/22 18:02:48
I assume the implementation only needs color type
msarett
2015/09/23 13:22:39
Yes, I will add a comment explaining this.
As an
scroggo
2015/09/25 15:55:05
I think only passing the information needed by the
msarett
2015/10/01 12:44:51
Done.
| |
238 return this->onGetFillValue(dstInfo); | |
239 } | |
240 | |
241 /** | |
242 * @param dstStart Pointer to the start of destination memory | |
243 * @param dstRowBytes Stride length in destination memory | |
244 * @param decodedScanlines Number of scanlines decoded successfully | |
245 * @return Pointer to the destination memory that we need to fill | |
246 */ | |
247 void* getFillDst(void* dstStart, size_t rowBytes, uint32_t decodedScanlines) const { | |
scroggo
2015/09/22 18:02:48
Could you add a comment with an overview of what t
msarett
2015/09/23 13:22:39
Yes this needs clarification.
| |
248 return this->onGetFillDst(dstStart, rowBytes, decodedScanlines); | |
249 } | |
250 | |
228 protected: | 251 protected: |
229 SkCodec(const SkImageInfo&, SkStream*); | 252 SkCodec(const SkImageInfo&, SkStream*); |
230 | 253 |
231 virtual SkISize onGetScaledDimensions(float /* desiredScale */) const { | 254 virtual SkISize onGetScaledDimensions(float /* desiredScale */) const { |
232 // By default, scaling is not supported. | 255 // By default, scaling is not supported. |
233 return this->getInfo().dimensions(); | 256 return this->getInfo().dimensions(); |
234 } | 257 } |
235 | 258 |
236 virtual SkEncodedFormat onGetEncodedFormat() const = 0; | 259 virtual SkEncodedFormat onGetEncodedFormat() const = 0; |
237 | 260 |
(...skipping 24 matching lines...) Expand all Loading... | |
262 /** | 285 /** |
263 * Called by rewindIfNeeded, if the stream needed to be rewound. | 286 * Called by rewindIfNeeded, if the stream needed to be rewound. |
264 * | 287 * |
265 * Subclasses should do any set up needed after a rewind. | 288 * Subclasses should do any set up needed after a rewind. |
266 */ | 289 */ |
267 virtual bool onRewind() { | 290 virtual bool onRewind() { |
268 return true; | 291 return true; |
269 } | 292 } |
270 | 293 |
271 /** | 294 /** |
295 * Some subclasses will override this function, but this is a useful default for the color | |
296 * types that we support. Note that for color types that do not use the ful l 32-bits, | |
297 * we will simply take the low bits of the fill value. | |
298 * | |
299 * kN32_SkColorType: Transparent or Black | |
300 * kRGB_565_SkColorType: Black | |
301 * kGray_8_SkColorType: Black | |
302 * kIndex_8_SkColorType: First color in color table | |
303 */ | |
304 virtual uint32_t onGetFillValue(const SkImageInfo& dstInfo) const { | |
305 return kOpaque_SkAlphaType == dstInfo.alphaType() ? SK_ColorBLACK : SK_C olorTRANSPARENT; | |
306 } | |
307 | |
308 /** | |
309 * The will only need to be overridden for images where the rows are not | |
scroggo
2015/09/22 18:02:48
This*
msarett
2015/09/23 13:22:39
Done.
| |
310 * decoded in top down order. | |
311 */ | |
312 virtual void* onGetFillDst(void* dstStart, size_t rowBytes, uint32_t decoded Scanlines) const { | |
313 return SkTAddOffset<void>(dstStart, rowBytes * decodedScanlines); | |
314 } | |
315 | |
316 /* | |
317 * Allows the subclass to indicate how many scanlines it failed to decode du e to an | |
318 * incomplete input image. This value tells us how many uninitialized scanl ines to fill | |
319 * in destination memory. | |
320 */ | |
321 void setIncompleteScanlines(uint32_t incompleteScanlines) { | |
scroggo
2015/09/22 18:02:48
Maybe this should be returned by getPixels (in an
msarett
2015/09/23 13:22:40
Good idea! I like this better than what I have.
| |
322 fIncompleteScanlines = incompleteScanlines; | |
323 } | |
324 | |
325 /** | |
272 * Get method for the input stream | 326 * Get method for the input stream |
273 */ | 327 */ |
274 SkStream* stream() { | 328 SkStream* stream() { |
275 return fStream.get(); | 329 return fStream.get(); |
276 } | 330 } |
277 | 331 |
278 private: | 332 private: |
279 const SkImageInfo fInfo; | 333 const SkImageInfo fInfo; |
280 SkAutoTDelete<SkStream> fStream; | 334 SkAutoTDelete<SkStream> fStream; |
281 bool fNeedsRewind; | 335 bool fNeedsRewind; |
336 uint32_t fIncompleteScanlines; | |
282 }; | 337 }; |
283 #endif // SkCodec_DEFINED | 338 #endif // SkCodec_DEFINED |
OLD | NEW |