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

Unified Diff: src/core/SkBitmap.cpp

Issue 346593003: Adjust the alpha type for pixelRefs. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix alignment. Created 6 years, 6 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 | « include/core/SkImageInfo.h ('k') | src/core/SkImageInfo.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « include/core/SkImageInfo.h ('k') | src/core/SkImageInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698