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

Commit 38c2ece5 authored by Romain Guy's avatar Romain Guy
Browse files

Clear bitmap references from display lists as early as possible

Bug #6555840

Apps like Google+ with large bitmaps displayed in listivews could
run into memory issues because of these references.

Change-Id: I39486bda13ce00c5a3b6481139ad54547506a8b4
parent 393a52c9
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -82,6 +82,12 @@ public abstract class DisplayList {
     */
     */
    public abstract void invalidate();
    public abstract void invalidate();


    /**
     * Clears additional resources held onto by this display list. You should
     * only invoke this method after {@link #invalidate()}.
     */
    public abstract void clear();

    /**
    /**
     * Returns whether the display list is currently usable. If this returns false,
     * Returns whether the display list is currently usable. If this returns false,
     * the display list should be re-recorded prior to replaying it.
     * the display list should be re-recorded prior to replaying it.
+7 −1
Original line number Original line Diff line number Diff line
@@ -71,6 +71,13 @@ class GLES20DisplayList extends DisplayList {
        mValid = false;
        mValid = false;
    }
    }


    @Override
    public void clear() {
        if (!mValid) {
            mBitmaps.clear();
        }
    }

    @Override
    @Override
    public boolean isValid() {
    public boolean isValid() {
        return mValid;
        return mValid;
@@ -343,7 +350,6 @@ class GLES20DisplayList extends DisplayList {
    private static native void nSetPivotX(int displayList, float pivotX);
    private static native void nSetPivotX(int displayList, float pivotX);
    private static native void nSetCaching(int displayList, boolean caching);
    private static native void nSetCaching(int displayList, boolean caching);
    private static native void nSetClipChildren(int displayList, boolean clipChildren);
    private static native void nSetClipChildren(int displayList, boolean clipChildren);
    private static native void nSetApplicationScale(int displayList, float scale);
    private static native void nSetAlpha(int displayList, float alpha);
    private static native void nSetAlpha(int displayList, float alpha);
    private static native void nSetHasOverlappingRendering(int displayList,
    private static native void nSetHasOverlappingRendering(int displayList,
            boolean hasOverlappingRendering);
            boolean hasOverlappingRendering);
+11 −4
Original line number Original line Diff line number Diff line
@@ -6800,6 +6800,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     */
     */
    public void dispatchStartTemporaryDetach() {
    public void dispatchStartTemporaryDetach() {
        clearAccessibilityFocus();
        clearAccessibilityFocus();
        clearDisplayList();
        onStartTemporaryDetach();
        onStartTemporaryDetach();
    }
    }
@@ -11455,10 +11457,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
            }
            }
            mAttachInfo.mViewRootImpl.cancelInvalidate(this);
            mAttachInfo.mViewRootImpl.cancelInvalidate(this);
        } else {
        } else {
            if (mDisplayList != null) {
            // Should never happen
            // Should never happen
                mDisplayList.invalidate();
            clearDisplayList();
            }
        }
        }
        mCurrentAnimation = null;
        mCurrentAnimation = null;
@@ -12236,6 +12236,13 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        return mDisplayList;
        return mDisplayList;
    }
    }
    private void clearDisplayList() {
        if (mDisplayList != null) {
            mDisplayList.invalidate();
            mDisplayList.clear();
        }
    }
    /**
    /**
     * <p>Calling this method is equivalent to calling <code>getDrawingCache(false)</code>.</p>
     * <p>Calling this method is equivalent to calling <code>getDrawingCache(false)</code>.</p>
     *
     *
+3 −1
Original line number Original line Diff line number Diff line
@@ -2335,7 +2335,9 @@ public final class ViewRootImpl implements ViewParent,
        final int count = displayLists.size();
        final int count = displayLists.size();


        for (int i = 0; i < count; i++) {
        for (int i = 0; i < count; i++) {
            displayLists.get(i).invalidate();
            final DisplayList displayList = displayLists.get(i);
            displayList.invalidate();
            displayList.clear();
        }
        }


        displayLists.clear();
        displayLists.clear();