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

Unified Diff: src/codec/SkCodecPriv.h

Issue 1282073004: Support decoding opaque images to unpremul/premul (Closed) Base URL: https://skia.googlesource.com/skia.git@CodexTestCleanup
Patch Set: Created 5 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/codec/SkJpegCodec.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkCodecPriv.h
diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
index 2596787b9b7aadcf44819e23849467b137c48cc7..10719c96fc1f68ae7a06cb638a7f20016ad4f925 100644
--- a/src/codec/SkCodecPriv.h
+++ b/src/codec/SkCodecPriv.h
@@ -33,19 +33,22 @@
static inline bool valid_alpha(SkAlphaType dstAlpha, SkAlphaType srcAlpha) {
// Check for supported alpha types
if (srcAlpha != dstAlpha) {
- if (kOpaque_SkAlphaType == srcAlpha) {
- // If the source is opaque, we must decode to opaque
+ if (kOpaque_SkAlphaType == dstAlpha) {
return false;
}
- // The source is not opaque
switch (dstAlpha) {
+ case kOpaque_SkAlphaType:
+ // If the source is not opaque, we cannot decode to opaque
+ return false;
case kPremul_SkAlphaType:
case kUnpremul_SkAlphaType:
- // The source is not opaque, so either of these is okay
+ // Opaque can trivially be treated as both, so no conversion is
+ // actually necessary.
+ // Switching between premul and unpremul is supported.
break;
default:
- // We cannot decode a non-opaque image to opaque (or unknown)
+ // We cannot decode a non-opaque image to opaque (or unknown
return false;
}
}
« no previous file with comments | « no previous file | src/codec/SkJpegCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698