Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 670689af authored by ztenghui's avatar ztenghui Committed by Tenghui Zhu
Browse files

Fix caching in VectorDrawable to pass the CTS test

bug:16380401

Change-Id: I573f4cc782707c6ef3484597ddc621a7a6353898
parent ba051aa6
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -336,6 +336,7 @@ public class VectorDrawable extends Drawable {
        a.recycle();

        final VectorDrawableState state = mVectorState;
        mVectorState.mCacheDirty = true;
        inflateInternal(res, parser, attrs, theme);

        mTintFilter = updateTintFilter(mTintFilter, state.mTint, state.mTintMode);
@@ -510,6 +511,8 @@ public class VectorDrawable extends Drawable {
        ColorStateList mCachedTint;
        Mode mCachedTintMode;
        int mCachedRootAlpha;
        boolean mCachedAutoMirrored;
        boolean mCacheDirty;

        // Deep copy for mutate() or implicitly mutate.
        public VectorDrawableState(VectorDrawableState copy) {
@@ -524,10 +527,11 @@ public class VectorDrawable extends Drawable {
        }

        public boolean canReuseCache(int width, int height) {
            if (mCachedThemeAttrs == mThemeAttrs
            if (!mCacheDirty
                    && mCachedThemeAttrs == mThemeAttrs
                    && mCachedTint == mTint
                    && mCachedTintMode == mTintMode
                    && mAutoMirrored == mAutoMirrored
                    && mCachedAutoMirrored == mAutoMirrored
                    && width == mCachedBitmap.getWidth()
                    && height == mCachedBitmap.getHeight()
                    && mCachedRootAlpha == mVPathRenderer.getRootAlpha())  {
@@ -543,6 +547,8 @@ public class VectorDrawable extends Drawable {
            mCachedTint = mTint;
            mCachedTintMode = mTintMode;
            mCachedRootAlpha = mVPathRenderer.getRootAlpha();
            mCachedAutoMirrored = mAutoMirrored;
            mCacheDirty = false;
        }

        public VectorDrawableState() {