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

Commit aa29a97f authored by Romain Guy's avatar Romain Guy
Browse files

Clear display lists when a View becomes GONE/INVISIBLE

We force an invalidate whenever a View becomes VISIBLE so there is
no need to keep the display list object while the view is either
GONE or INVISIBLE. In particular this clears the lists of references
kept by GLES20DisplayList, which helps the GC free large objects
such as Bitmaps.

Change-Id: Ifde0cb40baa1f35e5e6439d3bf8eab3c4c1270f0
parent 56cf63f8
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -8581,7 +8581,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            }
        }
        if ((flags & VISIBILITY_MASK) == VISIBLE) {
        final int newVisibility = flags & VISIBILITY_MASK;
        if (newVisibility == VISIBLE) {
            if ((changed & VISIBILITY_MASK) != 0) {
                /*
                 * If this view is becoming visible, invalidate it in case it changed while
@@ -8647,14 +8648,19 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        }
        if ((changed & VISIBILITY_MASK) != 0) {
            // If the view is invisible, cleanup its display list to free up resources
            if (newVisibility != VISIBLE) {
                cleanupDraw();
            }
            if (mParent instanceof ViewGroup) {
                ((ViewGroup) mParent).onChildVisibilityChanged(this,
                        (changed & VISIBILITY_MASK), (flags & VISIBILITY_MASK));
                        (changed & VISIBILITY_MASK), newVisibility);
                ((View) mParent).invalidate(true);
            } else if (mParent != null) {
                mParent.invalidateChild(this, null);
            }
            dispatchVisibilityChanged(this, (flags & VISIBILITY_MASK));
            dispatchVisibilityChanged(this, newVisibility);
        }
        if ((changed & WILL_NOT_CACHE_DRAWING) != 0) {
@@ -12034,6 +12040,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        destroyLayer(false);
        cleanupDraw();
        mCurrentAnimation = null;
        mCurrentScene = null;
        resetAccessibilityStateChanged();
    }
    private void cleanupDraw() {
        if (mAttachInfo != null) {
            if (mDisplayList != null) {
                mDisplayList.markDirty();
@@ -12044,12 +12059,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            // Should never happen
            clearDisplayList();
        }
        mCurrentAnimation = null;
        mCurrentScene = null;
        resetAccessibilityStateChanged();
    }
    void invalidateInheritedLayoutMode(int layoutModeOfRoot) {