Index: src/core/SkBitmap.cpp |
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp |
index 38df07c75f7b5651ce4da727ca29141a1dc426d0..82e0b4c92b834f2739a3dacd65f6e56955622d56 100644 |
--- a/src/core/SkBitmap.cpp |
+++ b/src/core/SkBitmap.cpp |
@@ -152,42 +152,11 @@ void SkBitmap::getBounds(SkIRect* bounds) const { |
/////////////////////////////////////////////////////////////////////////////// |
-static bool validate_alphaType(SkColorType colorType, SkAlphaType alphaType, |
- SkAlphaType* canonical = NULL) { |
- switch (colorType) { |
- case kUnknown_SkColorType: |
- alphaType = kIgnore_SkAlphaType; |
- break; |
- case kAlpha_8_SkColorType: |
- if (kUnpremul_SkAlphaType == alphaType) { |
- alphaType = kPremul_SkAlphaType; |
- } |
- // fall-through |
- case kIndex_8_SkColorType: |
- case kARGB_4444_SkColorType: |
- case kRGBA_8888_SkColorType: |
- case kBGRA_8888_SkColorType: |
- if (kIgnore_SkAlphaType == alphaType) { |
- return false; |
- } |
- break; |
- case kRGB_565_SkColorType: |
- alphaType = kOpaque_SkAlphaType; |
- break; |
- default: |
- return false; |
- } |
- if (canonical) { |
- *canonical = alphaType; |
- } |
- return true; |
-} |
- |
bool SkBitmap::setInfo(const SkImageInfo& origInfo, size_t rowBytes) { |
SkImageInfo info = origInfo; |
- if (!validate_alphaType(info.fColorType, info.fAlphaType, |
- &info.fAlphaType)) { |
+ if (!SkColorTypeValidateAlphaType(info.fColorType, info.fAlphaType, |
+ &info.fAlphaType)) { |
return reset_return_false(this); |
} |
@@ -228,7 +197,7 @@ bool SkBitmap::setConfig(Config config, int width, int height, size_t rowBytes, |
#endif |
bool SkBitmap::setAlphaType(SkAlphaType alphaType) { |
- if (!validate_alphaType(fInfo.fColorType, alphaType, &alphaType)) { |
+ if (!SkColorTypeValidateAlphaType(fInfo.fColorType, alphaType, &alphaType)) { |
return false; |
} |
if (fInfo.fAlphaType != alphaType) { |
@@ -1332,7 +1301,7 @@ void SkBitmap::legacyUnflatten(SkReadBuffer& buffer) { |
if (!buffer.validate((info.width() >= 0) && (info.height() >= 0) && |
SkColorTypeIsValid(info.fColorType) && |
SkAlphaTypeIsValid(info.fAlphaType) && |
- validate_alphaType(info.fColorType, info.fAlphaType) && |
+ SkColorTypeValidateAlphaType(info.fColorType, info.fAlphaType) && |
info.validRowBytes(rowBytes))) { |
return; |
} |