Index: src/core/SkBitmap.cpp |
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp |
index 3418fad7f197e1014fe63243a1571ee083178363..951bb6fe9883ba8d02ea7fb921c2e900e0b4d556 100644 |
--- a/src/core/SkBitmap.cpp |
+++ b/src/core/SkBitmap.cpp |
@@ -253,7 +253,14 @@ static bool validate_alphaType(SkColorType colorType, SkAlphaType alphaType, |
return true; |
} |
-bool SkBitmap::setConfig(const SkImageInfo& info, size_t rowBytes) { |
+bool SkBitmap::setConfig(const SkImageInfo& origInfo, size_t rowBytes) { |
+ SkImageInfo info = origInfo; |
+ |
+ if (!validate_alphaType(info.fColorType, info.fAlphaType, |
+ &info.fAlphaType)) { |
+ return reset_return_false(this); |
+ } |
+ |
// require that rowBytes fit in 31bits |
int64_t mrb = info.minRowBytes64(); |
if ((int32_t)mrb != mrb) { |
@@ -1619,6 +1626,13 @@ SkBitmap::RLEPixels::~RLEPixels() { |
#ifdef SK_DEBUG |
void SkBitmap::validate() const { |
fInfo.validate(); |
+ |
+ // ImageInfo may not require this, but Bitmap ensures that opaque-only |
+ // colorTypes report opaque for their alphatype |
+ if (kRGB_565_SkColorType == fInfo.colorType()) { |
+ SkASSERT(kOpaque_SkAlphaType == fInfo.alphaType()); |
+ } |
+ |
SkASSERT(fInfo.validRowBytes(fRowBytes)); |
uint8_t allFlags = kImageIsOpaque_Flag | kImageIsVolatile_Flag | kImageIsImmutable_Flag; |
#ifdef SK_BUILD_FOR_ANDROID |