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

Commit a756fd9a authored by Alan Viverette's avatar Alan Viverette
Browse files

Prevent temp rect reuse across methods in LayerDrawable

Drawable invalidation may call back into methods that are relying on
the same temp rect objects, which mangles the values.

Bug: 19321598
Change-Id: If8aa434cf85c81d22b5d580e258926087248cd93
parent 92b2fe5d
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -92,6 +92,8 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
    private int[] mPaddingB;

    private final Rect mTmpRect = new Rect();
    private final Rect mTmpOutRect = new Rect();
    private final Rect mTmpContainer = new Rect();
    private Rect mHotspotBounds;
    private boolean mMutated;

@@ -945,7 +947,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
        int padR = 0;
        int padB = 0;

        final Rect outRect = mTmpRect;
        final Rect outRect = mTmpOutRect;
        final int layoutDirection = getLayoutDirection();
        final boolean nest = mLayerState.mPaddingMode == PADDING_MODE_NEST;
        final ChildDrawable[] array = mLayerState.mChildren;
@@ -953,7 +955,8 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
        for (int i = 0; i < N; i++) {
            final ChildDrawable r = array[i];
            final Drawable d = r.mDrawable;
            final Rect container = d.getBounds();
            final Rect container = mTmpContainer;
            container.set(d.getBounds());

            // Take the resolved layout direction into account. If start / end
            // padding are defined, they will be resolved (hence overriding) to