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

Commit f5b87ce9 authored by Doris Liu's avatar Doris Liu Committed by android-build-merger
Browse files

Merge \"Ensure native allocation/free is correctly registered\" into nyc-mr1-dev

am: a7272b4c

Change-Id: Ib1d07a6420d6800b290d0c47e9fcfe3690c541eb
parents 3d3e2e2b a7272b4c
Loading
Loading
Loading
Loading
+9 −9
Original line number Original line Diff line number Diff line
@@ -235,7 +235,7 @@ public class VectorDrawable extends Drawable {
    private final Rect mTmpBounds = new Rect();
    private final Rect mTmpBounds = new Rect();


    public VectorDrawable() {
    public VectorDrawable() {
        this(new VectorDrawableState(), null);
        this(new VectorDrawableState(null), null);
    }
    }


    /**
    /**
@@ -830,7 +830,8 @@ public class VectorDrawable extends Drawable {


        private static final int NATIVE_ALLOCATION_SIZE = 316;
        private static final int NATIVE_ALLOCATION_SIZE = 316;


        // Deep copy for mutate() or implicitly mutate.
        // If copy is not null, deep copy the given VectorDrawableState. Otherwise, create a
        // native vector drawable tree with an empty root group.
        public VectorDrawableState(VectorDrawableState copy) {
        public VectorDrawableState(VectorDrawableState copy) {
            if (copy != null) {
            if (copy != null) {
                mThemeAttrs = copy.mThemeAttrs;
                mThemeAttrs = copy.mThemeAttrs;
@@ -851,8 +852,11 @@ public class VectorDrawable extends Drawable {
                if (copy.mRootName != null) {
                if (copy.mRootName != null) {
                    mVGTargetsMap.put(copy.mRootName, this);
                    mVGTargetsMap.put(copy.mRootName, this);
                }
                }
                onTreeConstructionFinished();
            } else {
                mRootGroup = new VGroup();
                createNativeTree(mRootGroup);
            }
            }
            onTreeConstructionFinished();
        }
        }


        private void createNativeTree(VGroup rootGroup) {
        private void createNativeTree(VGroup rootGroup) {
@@ -870,7 +874,8 @@ public class VectorDrawable extends Drawable {
            VMRuntime.getRuntime().registerNativeAllocation(NATIVE_ALLOCATION_SIZE);
            VMRuntime.getRuntime().registerNativeAllocation(NATIVE_ALLOCATION_SIZE);
        }
        }



        // This should be called every time after a new RootGroup and all its subtrees are created
        // (i.e. in constructors of VectorDrawableState and in inflate).
        void onTreeConstructionFinished() {
        void onTreeConstructionFinished() {
            mRootGroup.setTree(mNativeTree);
            mRootGroup.setTree(mNativeTree);
            mAllocationOfAllNodes = mRootGroup.getNativeSize();
            mAllocationOfAllNodes = mRootGroup.getNativeSize();
@@ -918,11 +923,6 @@ public class VectorDrawable extends Drawable {
                    || super.canApplyTheme();
                    || super.canApplyTheme();
        }
        }


        public VectorDrawableState() {
            mRootGroup = new VGroup();
            createNativeTree(mRootGroup);
        }

        @Override
        @Override
        public Drawable newDrawable() {
        public Drawable newDrawable() {
            return new VectorDrawable(this, null);
            return new VectorDrawable(this, null);