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

Unified Diff: src/core/SkBitmap.cpp

Issue 164233006: ensure that opaque-only colortypes always report opaque-alphatype (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | « no previous file | no next file » | 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 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698