Adjust the alpha type for pixelRefs.
Move SkBitmap's validate_alphaType to SkImageInfo, with the new
name SkColorTypeValidateAlphaType. Use it in SkPixelRef's constructors,
as well as in SkDecodingImageGenerator. This fixes a bug where an
SkPixelRef's SkAlphaType could get out of sync with its SkBitmap,
when both were assigned the same SkAlphaType.
R=reed@google.com, halcanary@google.com
Author: scroggo@google.com
Review URL: https://codereview.chromium.org/346593003
diff --git a/src/images/SkDecodingImageGenerator.cpp b/src/images/SkDecodingImageGenerator.cpp
index 88cdef9..dfa093b 100644
--- a/src/images/SkDecodingImageGenerator.cpp
+++ b/src/images/SkDecodingImageGenerator.cpp
@@ -246,6 +246,11 @@
if (opts.fRequireUnpremul && info.fAlphaType != kOpaque_SkAlphaType) {
info.fAlphaType = kUnpremul_SkAlphaType;
}
+
+ if (!SkColorTypeValidateAlphaType(info.fColorType, info.fAlphaType, &info.fAlphaType)) {
+ return NULL;
+ }
+
return SkNEW_ARGS(DecodingImageGenerator,
(data, autoStream.detach(), info,
opts.fSampleSize, opts.fDitherImage));