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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 279 |
280 /** | 280 /** |
281 * Some images may initially report that they have alpha due to the format | 281 * Some images may initially report that they have alpha due to the format |
282 * of the encoded data, but then never use any colors which have alpha | 282 * of the encoded data, but then never use any colors which have alpha |
283 * less than 100%. This function can be called *after* decoding to | 283 * less than 100%. This function can be called *after* decoding to |
284 * determine if such an image truly had alpha. Calling it before decoding | 284 * determine if such an image truly had alpha. Calling it before decoding |
285 * is undefined. | 285 * is undefined. |
286 * FIXME: see skbug.com/3582. | 286 * FIXME: see skbug.com/3582. |
287 */ | 287 */ |
288 bool reallyHasAlpha() const { | 288 bool reallyHasAlpha() const { |
289 return this->onReallyHasAlpha(); | 289 return kOpaque_SkAlphaType != this->getInfo().alphaType() && this->onRea
llyHasAlpha(); |
290 } | 290 } |
291 | 291 |
292 /** | 292 /** |
293 * The remaining functions revolve around decoding scanlines. | 293 * The remaining functions revolve around decoding scanlines. |
294 */ | 294 */ |
295 | 295 |
296 /** | 296 /** |
297 * Prepare for a scanline decode with the specified options. | 297 * Prepare for a scanline decode with the specified options. |
298 * | 298 * |
299 * After this call, this class will be ready to decode the first scanline. | 299 * After this call, this class will be ready to decode the first scanline. |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 virtual Result onGetPixels(const SkImageInfo& info, | 479 virtual Result onGetPixels(const SkImageInfo& info, |
480 void* pixels, size_t rowBytes, const Options&, | 480 void* pixels, size_t rowBytes, const Options&, |
481 SkPMColor ctable[], int* ctableCount, | 481 SkPMColor ctable[], int* ctableCount, |
482 int* rowsDecoded) = 0; | 482 int* rowsDecoded) = 0; |
483 | 483 |
484 virtual bool onGetValidSubset(SkIRect* /* desiredSubset */) const { | 484 virtual bool onGetValidSubset(SkIRect* /* desiredSubset */) const { |
485 // By default, subsets are not supported. | 485 // By default, subsets are not supported. |
486 return false; | 486 return false; |
487 } | 487 } |
488 | 488 |
489 virtual bool onReallyHasAlpha() const { return false; } | 489 /** |
| 490 * This is only called if the image indicates that it is not opaque. |
| 491 * By default we will assume that the image is in fact non-opaque. |
| 492 * Subclasses may override this function if they intend to verify |
| 493 * that the image actually has alpha. |
| 494 */ |
| 495 virtual bool onReallyHasAlpha() const { |
| 496 return true; |
| 497 } |
490 | 498 |
491 /** | 499 /** |
492 * If the stream was previously read, attempt to rewind. | 500 * If the stream was previously read, attempt to rewind. |
493 * | 501 * |
494 * If the stream needed to be rewound, call onRewind. | 502 * If the stream needed to be rewound, call onRewind. |
495 * @returns true if the codec is at the right position and can be used. | 503 * @returns true if the codec is at the right position and can be used. |
496 * false if there was a failure to rewind. | 504 * false if there was a failure to rewind. |
497 * | 505 * |
498 * This is called by getPixels() and start(). Subclasses may call if they | 506 * This is called by getPixels() and start(). Subclasses may call if they |
499 * need to rewind at another time. | 507 * need to rewind at another time. |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 * not affect ownership. | 649 * not affect ownership. |
642 * | 650 * |
643 * Only valid during scanline decoding. | 651 * Only valid during scanline decoding. |
644 */ | 652 */ |
645 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr;
} | 653 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr;
} |
646 | 654 |
647 friend class SkSampledCodec; | 655 friend class SkSampledCodec; |
648 friend class SkIcoCodec; | 656 friend class SkIcoCodec; |
649 }; | 657 }; |
650 #endif // SkCodec_DEFINED | 658 #endif // SkCodec_DEFINED |
OLD | NEW |