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

Unified Diff: src/core/SkBitmap.cpp

Issue 120063003: assert in setPixelRef that the pr matches the bitmap's config (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 12 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 | tests/SerializationTest.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 ee741c3df09f4cf0a96b87d17e24d2482d59dcbe..c0d93957aca11292e2f6e52b17e9f7aa92783de7 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -402,6 +402,31 @@ SkPixelRef* SkBitmap::setPixelRef(SkPixelRef* pr, size_t offset) {
if (NULL == pr) {
offset = 0;
}
+#ifdef SK_DEBUG
+ else {
+ SkImageInfo info;
+ if (this->asImageInfo(&info)) {
+ const SkImageInfo& prInfo = pr->info();
+ SkASSERT(info.fWidth <= prInfo.fWidth);
+ SkASSERT(info.fHeight <= prInfo.fHeight);
+ SkASSERT(info.fColorType == prInfo.fColorType);
+ switch (prInfo.fAlphaType) {
+ case kIgnore_SkAlphaType:
+ SkASSERT(fAlphaType == kIgnore_SkAlphaType);
+ break;
+ case kOpaque_SkAlphaType:
+ case kPremul_SkAlphaType:
hal.canary 2014/01/02 22:36:01 Under what circumstances will the alphatypes be !=
+ SkASSERT(info.fAlphaType == kOpaque_SkAlphaType ||
+ info.fAlphaType == kPremul_SkAlphaType);
+ break;
+ case kUnpremul_SkAlphaType:
+ SkASSERT(info.fAlphaType == kOpaque_SkAlphaType ||
+ info.fAlphaType == kUnpremul_SkAlphaType);
+ break;
+ }
+ }
+ }
+#endif
if (fPixelRef != pr || fPixelRefOffset != offset) {
if (fPixelRef != pr) {
« no previous file with comments | « no previous file | tests/SerializationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698