OSDN Git Service

Recreate the bitmap cache when it is smaller than needed
authorTeng-Hui Zhu <ztenghui@google.com>
Wed, 16 Nov 2016 18:29:39 +0000 (10:29 -0800)
committerTeng-Hui Zhu <ztenghui@google.com>
Wed, 16 Nov 2016 21:01:02 +0000 (13:01 -0800)
fix:32780212

Test: Existing CTS and attached repro apk.

Change-Id: Ib908319af6539b2438b850f7a50d5a539cef8368

libs/hwui/VectorDrawable.cpp
libs/hwui/VectorDrawable.h

index b50647a..8a8f267 100644 (file)
@@ -574,7 +574,7 @@ bool Tree::allocateBitmapIfNeeded(Cache& cache, int width, int height) {
 }
 
 bool Tree::canReuseBitmap(Bitmap* bitmap, int width, int height) {
-    return bitmap && width == bitmap->width() && height == bitmap->height();
+    return bitmap && width <= bitmap->width() && height <= bitmap->height();
 }
 
 void Tree::onPropertyChanged(TreeProperties* prop) {
index e9a9c71..8244a39 100644 (file)
@@ -630,10 +630,15 @@ public:
         }
 
         void setScaledSize(int width, int height) {
-            if (mNonAnimatableProperties.scaledWidth != width
-                    || mNonAnimatableProperties.scaledHeight != height) {
-                mNonAnimatableProperties.scaledWidth = width;
-                mNonAnimatableProperties.scaledHeight = height;
+            // If the requested size is bigger than what the bitmap was, then
+            // we increase the bitmap size to match. The width and height
+            // are bound by MAX_CACHED_BITMAP_SIZE.
+            if (mNonAnimatableProperties.scaledWidth < width
+                    || mNonAnimatableProperties.scaledHeight < height) {
+                mNonAnimatableProperties.scaledWidth = std::max(width,
+                        mNonAnimatableProperties.scaledWidth);
+                mNonAnimatableProperties.scaledHeight = std::max(height,
+                        mNonAnimatableProperties.scaledHeight);
                 mNonAnimatablePropertiesDirty = true;
                 mTree->onPropertyChanged(this);
             }