SkMipmapAccessor::fResolvedMode doesn't need to persist, make it local

Change-Id: I9b22c628147fe3d66e3148351ef765bb8c2ebe50
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/497141
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2022-01-20 11:48:11 -05:00 committed by SkCQ
parent 7e8fdf4706
commit a9aa935808
2 changed files with 9 additions and 10 deletions

View File

@ -28,7 +28,7 @@ static sk_sp<const SkMipmap> try_load_mips(const SkImage_Base* image) {
SkMipmapAccessor::SkMipmapAccessor(const SkImage_Base* image, const SkMatrix& inv,
SkMipmapMode requestedMode) {
fResolvedMode = requestedMode;
SkMipmapMode resolvedMode = requestedMode;
fLowerWeight = 0;
auto load_upper_from_base = [&]() {
@ -44,11 +44,11 @@ SkMipmapAccessor::SkMipmapAccessor(const SkImage_Base* image, const SkMatrix& in
if (requestedMode != SkMipmapMode::kNone) {
SkSize scale;
if (!inv.decomposeScale(&scale, nullptr)) {
fResolvedMode = SkMipmapMode::kNone;
resolvedMode = SkMipmapMode::kNone;
} else {
level = SkMipmap::ComputeLevel({1/scale.width(), 1/scale.height()});
if (level <= 0) {
fResolvedMode = SkMipmapMode::kNone;
resolvedMode = SkMipmapMode::kNone;
level = 0;
}
}
@ -67,31 +67,31 @@ SkMipmapAccessor::SkMipmapAccessor(const SkImage_Base* image, const SkMatrix& in
load_upper_from_base();
}
// load fCurrMip if needed
if (levelNum > 0 || (fResolvedMode == SkMipmapMode::kLinear && lowerWeight > 0)) {
if (levelNum > 0 || (resolvedMode == SkMipmapMode::kLinear && lowerWeight > 0)) {
fCurrMip = try_load_mips(image);
if (!fCurrMip) {
load_upper_from_base();
fResolvedMode = SkMipmapMode::kNone;
resolvedMode = SkMipmapMode::kNone;
} else {
SkMipmap::Level levelRec;
SkASSERT(fResolvedMode != SkMipmapMode::kNone);
SkASSERT(resolvedMode != SkMipmapMode::kNone);
if (levelNum > 0) {
if (fCurrMip->getLevel(levelNum - 1, &levelRec)) {
fUpper = levelRec.fPixmap;
} else {
load_upper_from_base();
fResolvedMode = SkMipmapMode::kNone;
resolvedMode = SkMipmapMode::kNone;
}
}
if (fResolvedMode == SkMipmapMode::kLinear) {
if (resolvedMode == SkMipmapMode::kLinear) {
if (fCurrMip->getLevel(levelNum, &levelRec)) {
fLower = levelRec.fPixmap;
fLowerWeight = lowerWeight;
fLowerInv = post_scale(fLower);
} else {
fResolvedMode = SkMipmapMode::kNearest;
resolvedMode = SkMipmapMode::kNearest;
}
}
}

View File

@ -40,7 +40,6 @@ private:
float fLowerWeight; // lower * weight + upper * (1 - weight)
SkMatrix fUpperInv,
fLowerInv;
SkMipmapMode fResolvedMode;
// these manage lifetime for the buffers
SkBitmap fBaseStorage;