aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmap.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-07-01 12:48:11 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-01 12:48:11 -0700
commitf0aed97aec3fa1c7f6460d8d6327358f3dcbabe6 (patch)
treebed25aabeca446338941bdf4fa9d2725ae9c4f52 /src/core/SkBitmap.cpp
parentc846f4a96bcde1ffeaf17afc1469db6f2cbd1ad3 (diff)
correctly plumb through explicit rowbytes for allocPixels
BUG=skia: R=caryclark@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/357073003
Diffstat (limited to 'src/core/SkBitmap.cpp')
-rw-r--r--src/core/SkBitmap.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 82e0b4c92b..316878bad0 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);
}