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

Unified Diff: src/codec/SkCodecPriv.h

Issue 1641273003: Support decoding opaque to *premul (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: No need for alphaType parameter Created 4 years, 11 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
Index: src/codec/SkCodecPriv.h
diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
index 27e2a63722d8ff095911846ece0d45d46cc7479f..4ae049744c3017b4a1a87da9800845c2404df04c 100644
--- a/src/codec/SkCodecPriv.h
+++ b/src/codec/SkCodecPriv.h
@@ -75,11 +75,14 @@ inline bool is_coord_necessary(int srcCoord, int sampleFactor, int scaledDim) {
}
inline bool valid_alpha(SkAlphaType dstAlpha, SkAlphaType srcAlpha) {
- // Check for supported alpha types
+ if (kUnknown_SkAlphaType == dstAlpha) {
+ return false;
+ }
+
if (srcAlpha != dstAlpha) {
if (kOpaque_SkAlphaType == srcAlpha) {
- // If the source is opaque, we must decode to opaque
- return false;
+ // If the source is opaque, we can support any.
msarett 2016/01/29 14:50:38 Can we print a "Warning: This is a bad idea..." or
scroggo 2016/01/29 17:19:54 You'll invoke Cary's ire for adding print statemen
msarett 2016/01/29 19:17:05 What about SkCodecPrintf? I believe that's silent
scroggo 2016/01/29 19:31:22 Done.
+ return true;
}
// The source is not opaque
@@ -99,7 +102,8 @@ inline bool valid_alpha(SkAlphaType dstAlpha, SkAlphaType srcAlpha) {
/*
* Most of our codecs support the same conversions:
* - profileType must be the same
- * - opaque only to opaque (and 565 only if opaque)
+ * - opaque to any alpha type
+ * - 565 only if opaque
* - premul to unpremul and vice versa
* - always support N32
* - otherwise match the src color type

Powered by Google App Engine
This is Rietveld 408576698