Recreate the bitmap cache when it is smaller than needed

fix:32780212

Test: Existing CTS and attached repro apk.

Change-Id: Ib908319af6539b2438b850f7a50d5a539cef8368
This commit is contained in:
Teng-Hui Zhu
2016-11-16 10:29:39 -08:00
committed by ztenghui
parent c8d6603644
commit 17f40b80f6
2 changed files with 10 additions and 5 deletions

View File

@@ -576,7 +576,7 @@ bool Tree::allocateBitmapIfNeeded(SkBitmap* outCache, int width, int height) {
} }
bool Tree::canReuseBitmap(const SkBitmap& bitmap, int width, int height) { bool Tree::canReuseBitmap(const SkBitmap& bitmap, int width, int height) {
return width == bitmap.width() && height == bitmap.height(); return width <= bitmap.width() && height <= bitmap.height();
} }
void Tree::onPropertyChanged(TreeProperties* prop) { void Tree::onPropertyChanged(TreeProperties* prop) {

View File

@@ -622,10 +622,15 @@ public:
} }
void setScaledSize(int width, int height) { void setScaledSize(int width, int height) {
if (mNonAnimatableProperties.scaledWidth != width // If the requested size is bigger than what the bitmap was, then
|| mNonAnimatableProperties.scaledHeight != height) { // we increase the bitmap size to match. The width and height
mNonAnimatableProperties.scaledWidth = width; // are bound by MAX_CACHED_BITMAP_SIZE.
mNonAnimatableProperties.scaledHeight = height; if (mNonAnimatableProperties.scaledWidth < width
|| mNonAnimatableProperties.scaledHeight < height) {
mNonAnimatableProperties.scaledWidth = std::max(width,
mNonAnimatableProperties.scaledWidth);
mNonAnimatableProperties.scaledHeight = std::max(height,
mNonAnimatableProperties.scaledHeight);
mNonAnimatablePropertiesDirty = true; mNonAnimatablePropertiesDirty = true;
mTree->onPropertyChanged(this); mTree->onPropertyChanged(this);
} }