aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmap.cpp
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-04-27 16:52:29 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-27 21:19:32 +0000
commit2cbb6662e329981840f90ef4edd62f70f69e6030 (patch)
tree63e5d20cba696369a6ca15495fafd6afac14a866 /src/core/SkBitmap.cpp
parent0122af08f6af0dee490e1a4f35b552377d0d4753 (diff)
Only store width and height on SkPixelRef
Bug: skia:6535 Change-Id: Id91e8d1e82f593be7d4b23ca5abde752f2666a77 Reviewed-on: https://skia-review.googlesource.com/14105 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Mike Reed <reed@google.com>
Diffstat (limited to 'src/core/SkBitmap.cpp')
-rw-r--r--src/core/SkBitmap.cpp38
1 files changed, 9 insertions, 29 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 8f131d15f5..0c1bc7d70b 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -171,9 +171,6 @@ bool SkBitmap::setAlphaType(SkAlphaType newAlphaType) {
}
if (fInfo.alphaType() != newAlphaType) {
fInfo = fInfo.makeAlphaType(newAlphaType);
- if (fPixelRef) {
- fPixelRef->changeAlphaType(newAlphaType);
- }
}
SkDEBUGCODE(this->validate();)
return true;
@@ -198,32 +195,15 @@ void SkBitmap::setPixelRef(sk_sp<SkPixelRef> pr, int dx, int dy) {
#ifdef SK_DEBUG
if (pr) {
if (kUnknown_SkColorType != fInfo.colorType()) {
- const SkImageInfo& prInfo = pr->info();
- SkASSERT(fInfo.width() <= prInfo.width());
- SkASSERT(fInfo.height() <= prInfo.height());
- SkASSERT(fInfo.colorType() == prInfo.colorType());
- switch (prInfo.alphaType()) {
- case kUnknown_SkAlphaType:
- SkASSERT(fInfo.alphaType() == kUnknown_SkAlphaType);
- break;
- case kOpaque_SkAlphaType:
- case kPremul_SkAlphaType:
- SkASSERT(fInfo.alphaType() == kOpaque_SkAlphaType ||
- fInfo.alphaType() == kPremul_SkAlphaType);
- break;
- case kUnpremul_SkAlphaType:
- SkASSERT(fInfo.alphaType() == kOpaque_SkAlphaType ||
- fInfo.alphaType() == kUnpremul_SkAlphaType);
- break;
- }
+ SkASSERT(fInfo.width() <= pr->width());
+ SkASSERT(fInfo.height() <= pr->height());
}
}
#endif
fPixelRef = std::move(pr);
if (fPixelRef) {
- const SkImageInfo& info = fPixelRef->info();
- fPixelRefOrigin.set(SkTPin(dx, 0, info.width()), SkTPin(dy, 0, info.height()));
+ fPixelRefOrigin.set(SkTPin(dx, 0, fPixelRef->width()), SkTPin(dy, 0, fPixelRef->height()));
this->updatePixelsFromRef();
} else {
// ignore dx,dy if there is no pixelref
@@ -677,9 +657,9 @@ bool SkBitmap::internalCopyTo(SkBitmap* dst, SkColorType dstColorType, Allocator
// if (src_pixelref->info == dst_pixelref->info)
//
if (srcPM.colorType() == dstColorType && tmpDst.getSize() == srcPM.getSize64()) {
- SkPixelRef* dstPixelRef = tmpDst.pixelRef();
- if (dstPixelRef->info() == fPixelRef->info()) {
- dstPixelRef->cloneGenID(*fPixelRef);
+ if (tmpDst.info() == this->info() && tmpDst.pixelRef()->width() == fPixelRef->width() &&
+ tmpDst.pixelRef()->height() == fPixelRef->height()) {
+ tmpDst.pixelRef()->cloneGenID(*fPixelRef);
}
}
@@ -916,7 +896,7 @@ bool SkBitmap::ReadRawPixels(SkReadBuffer* buffer, SkBitmap* bitmap) {
if (!pr) {
return false;
}
- bitmap->setInfo(pr->info());
+ bitmap->setInfo(info);
bitmap->setPixelRef(std::move(pr), 0, 0);
return true;
}
@@ -956,8 +936,8 @@ void SkBitmap::validate() const {
SkASSERT(fPixelRef->rowBytes() == fRowBytes);
SkASSERT(fPixelRefOrigin.fX >= 0);
SkASSERT(fPixelRefOrigin.fY >= 0);
- SkASSERT(fPixelRef->info().width() >= (int)this->width() + fPixelRefOrigin.fX);
- SkASSERT(fPixelRef->info().height() >= (int)this->height() + fPixelRefOrigin.fY);
+ SkASSERT(fPixelRef->width() >= (int)this->width() + fPixelRefOrigin.fX);
+ SkASSERT(fPixelRef->height() >= (int)this->height() + fPixelRefOrigin.fY);
SkASSERT(fPixelRef->rowBytes() >= fInfo.minRowBytes());
}
}