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

Commit 2665f6e9 authored by John Reck's avatar John Reck Committed by Android (Google) Code Review
Browse files

Merge "Remove invalid usage of DisplayList.isValid()"

parents 1f97d0ae 7558aa70
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -238,16 +238,6 @@ public class DisplayList {
        mValid = true;
    }

    /**
    * After calling this method {@link #isValid()} will return false.
    * TODO: Have Editor stop using this
    *
    * @see #isValid()
    */
    public void markInvalid() {
        mValid = false;
    }

    /**
     * Reset native resources. This is called when cleaning up the state of display lists
     * during destruction of hardware resources, to ensure that we do not hold onto
+33 −11
Original line number Diff line number Diff line
@@ -137,7 +137,16 @@ public class Editor {
    InputContentType mInputContentType;
    InputMethodState mInputMethodState;

    DisplayList[] mTextDisplayLists;
    private static class TextDisplayList {
        DisplayList displayList;
        boolean isDirty;
        public TextDisplayList(String name) {
            isDirty = true;
            displayList = DisplayList.create(name);
        }
        boolean needsRecord() { return isDirty || !displayList.isValid(); }
    }
    TextDisplayList[] mTextDisplayLists;

    boolean mFrozenWithFocus;
    boolean mSelectionMoved;
@@ -262,7 +271,7 @@ public class Editor {
            mTextView.removeCallbacks(mShowSuggestionRunnable);
        }

        invalidateTextDisplayList();
        destroyDisplayListsData();

        if (mSpellChecker != null) {
            mSpellChecker.closeSession();
@@ -277,6 +286,19 @@ public class Editor {
        mTemporaryDetach = false;
    }

    private void destroyDisplayListsData() {
        HardwareRenderer renderer = mTextView.getHardwareRenderer();
        if (mTextDisplayLists != null) {
            for (int i = 0; i < mTextDisplayLists.length; i++) {
                DisplayList displayList = mTextDisplayLists[i] != null
                        ? mTextDisplayLists[i].displayList : null;
                if (displayList != null && displayList.isValid()) {
                    displayList.destroyDisplayListData(renderer);
                }
            }
        }
    }

    private void showError() {
        if (mTextView.getWindowToken() == null) {
            mShowErrorAfterAttach = true;
@@ -1320,7 +1342,7 @@ public class Editor {

        if (layout instanceof DynamicLayout) {
            if (mTextDisplayLists == null) {
                mTextDisplayLists = new DisplayList[ArrayUtils.idealObjectArraySize(0)];
                mTextDisplayLists = new TextDisplayList[ArrayUtils.idealObjectArraySize(0)];
            }

            DynamicLayout dynamicLayout = (DynamicLayout) layout;
@@ -1344,13 +1366,13 @@ public class Editor {
                    searchStartIndex = blockIndex + 1;
                }

                DisplayList blockDisplayList = mTextDisplayLists[blockIndex];
                if (blockDisplayList == null) {
                    blockDisplayList = mTextDisplayLists[blockIndex] =
                            DisplayList.create("Text " + blockIndex);
                if (mTextDisplayLists[blockIndex] == null) {
                    mTextDisplayLists[blockIndex] =
                            new TextDisplayList("Text " + blockIndex);
                }

                final boolean blockDisplayListIsInvalid = !blockDisplayList.isValid();
                final boolean blockDisplayListIsInvalid = mTextDisplayLists[blockIndex].needsRecord();
                DisplayList blockDisplayList = mTextDisplayLists[blockIndex].displayList;
                if (i >= indexFirstChangedBlock || blockDisplayListIsInvalid) {
                    final int blockBeginLine = endOfPreviousBlock + 1;
                    final int top = layout.getLineTop(blockBeginLine);
@@ -1421,7 +1443,7 @@ public class Editor {

        // No available index found, the pool has to grow
        int newSize = ArrayUtils.idealIntArraySize(length + 1);
        DisplayList[] displayLists = new DisplayList[newSize];
        TextDisplayList[] displayLists = new TextDisplayList[newSize];
        System.arraycopy(mTextDisplayLists, 0, displayLists, 0, length);
        mTextDisplayLists = displayLists;
        return length;
@@ -1460,7 +1482,7 @@ public class Editor {
            while (i < numberOfBlocks) {
                final int blockIndex = blockIndices[i];
                if (blockIndex != DynamicLayout.INVALID_BLOCK_INDEX) {
                    mTextDisplayLists[blockIndex].markInvalid();
                    mTextDisplayLists[blockIndex].isDirty = true;
                }
                if (blockEndLines[i] >= lastLine) break;
                i++;
@@ -1471,7 +1493,7 @@ public class Editor {
    void invalidateTextDisplayList() {
        if (mTextDisplayLists != null) {
            for (int i = 0; i < mTextDisplayLists.length; i++) {
                if (mTextDisplayLists[i] != null) mTextDisplayLists[i].markInvalid();
                if (mTextDisplayLists[i] != null) mTextDisplayLists[i].isDirty = true;
            }
        }
    }