Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: include/codec/SkCodec.h

Issue 1518743002: Add reallyHasAlpha() to SkAndroidCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Move fCodec to SkAndroidCodec Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/codec/SkAndroidCodec.h ('k') | src/codec/SkAndroidCodec.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 virtual bool onReallyHasAlpha() const {
490 // If the image indicates that it does have alpha, by default, we
scroggo 2015/12/10 18:45:44 Maybe add a comment that this is only called if th
msarett 2015/12/10 18:53:30 Done and yes.
491 // will assume this to be true. Subclasses may override this
492 // function if they intend to verify that the image actually has
493 // alpha.
494 return true;
495 }
490 496
491 /** 497 /**
492 * If the stream was previously read, attempt to rewind. 498 * If the stream was previously read, attempt to rewind.
493 * 499 *
494 * If the stream needed to be rewound, call onRewind. 500 * If the stream needed to be rewound, call onRewind.
495 * @returns true if the codec is at the right position and can be used. 501 * @returns true if the codec is at the right position and can be used.
496 * false if there was a failure to rewind. 502 * false if there was a failure to rewind.
497 * 503 *
498 * This is called by getPixels() and start(). Subclasses may call if they 504 * This is called by getPixels() and start(). Subclasses may call if they
499 * need to rewind at another time. 505 * need to rewind at another time.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 * not affect ownership. 647 * not affect ownership.
642 * 648 *
643 * Only valid during scanline decoding. 649 * Only valid during scanline decoding.
644 */ 650 */
645 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; } 651 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; }
646 652
647 friend class SkSampledCodec; 653 friend class SkSampledCodec;
648 friend class SkIcoCodec; 654 friend class SkIcoCodec;
649 }; 655 };
650 #endif // SkCodec_DEFINED 656 #endif // SkCodec_DEFINED
OLDNEW
« no previous file with comments | « include/codec/SkAndroidCodec.h ('k') | src/codec/SkAndroidCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698