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

Unified Diff: src/core/SkBitmap.cpp

Issue 357073003: correctly plumb through explicit rowbytes for allocPixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/SkPixelRef.h ('k') | src/core/SkMallocPixelRef.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 82e0b4c92b834f2739a3dacd65f6e56955622d56..316878bad0efd1ee0323f2acda3df44ac3e8a952 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -177,7 +177,7 @@ bool SkBitmap::setInfo(const SkImageInfo& origInfo, size_t rowBytes) {
rowBytes = 0;
} else if (0 == rowBytes) {
rowBytes = (size_t)mrb;
- } else if (rowBytes < info.minRowBytes()) {
+ } else if (!info.validRowBytes(rowBytes)) {
return reset_return_false(this);
}
@@ -339,19 +339,18 @@ bool SkBitmap::allocPixels(const SkImageInfo& requestedInfo, size_t rowBytes) {
if (kIndex_8_SkColorType == requestedInfo.colorType()) {
return reset_return_false(this);
}
- if (!this->setInfo(requestedInfo)) {
+ if (!this->setInfo(requestedInfo, rowBytes)) {
return reset_return_false(this);
}
// setInfo may have corrected info (e.g. 565 is always opaque).
const SkImageInfo& correctedInfo = this->info();
- if (!correctedInfo.validRowBytes(rowBytes)) {
- return reset_return_false(this);
- }
-
+ // setInfo may have computed a valid rowbytes if 0 were passed in
+ rowBytes = this->rowBytes();
+
SkMallocPixelRef::PRFactory defaultFactory;
- SkPixelRef* pr = defaultFactory.create(correctedInfo, NULL);
+ SkPixelRef* pr = defaultFactory.create(correctedInfo, rowBytes, NULL);
if (NULL == pr) {
return reset_return_false(this);
}
@@ -382,7 +381,7 @@ bool SkBitmap::allocPixels(const SkImageInfo& requestedInfo, SkPixelRefFactory*
factory = &defaultFactory;
}
- SkPixelRef* pr = factory->create(correctedInfo, ctable);
+ SkPixelRef* pr = factory->create(correctedInfo, correctedInfo.minRowBytes(), ctable);
if (NULL == pr) {
return reset_return_false(this);
}
« no previous file with comments | « include/core/SkPixelRef.h ('k') | src/core/SkMallocPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698