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

Commit b35ab7b7 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

Sub display list in TextView

TextView uses a sub-display list to 'cache' the rendering of its
text. This saves time when drawing an editable text, where the blinking
cursor forces a re-draw twice per second, which creates pauses during
scrolling.

Added a sub-display list invalidation when an appearance span is
modified/added/removed.

Also added an invalidation of the display list when selection range
is changed.

Change-Id: I41e8068a12902b8a745c5bb77de8c77def76a270
parent cf5cecd8
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -32,20 +32,20 @@ public abstract class DisplayList {
     * 
     * @return A canvas to record drawing operations.
     */
    abstract HardwareCanvas start();
    public abstract HardwareCanvas start();

    /**
     * Ends the recording for this display list. A display list cannot be
     * replayed if recording is not finished. 
     */
    abstract void end();
    public abstract void end();

    /**
     * Invalidates the display list, indicating that it should be repopulated
     * with new drawing commands prior to being used again. Calling this method
     * causes calls to {@link #isValid()} to return <code>false</code>.
     */
    abstract void invalidate();
    public abstract void invalidate();

    /**
     * Returns whether the display list is currently usable. If this returns false,
@@ -53,12 +53,12 @@ public abstract class DisplayList {
     *
     * @return boolean true if the display list is able to be replayed, false otherwise.
     */
    abstract boolean isValid();
    public abstract boolean isValid();

    /**
     * Return the amount of memory used by this display list.
     * 
     * @return The size of this display list in bytes
     */
    abstract int getSize();
    public abstract int getSize();
}
+2 −2
Original line number Diff line number Diff line
@@ -247,7 +247,7 @@ class GLES20Canvas extends HardwareCanvas {
    private static native void nDisableVsync();

    @Override
    void onPreDraw(Rect dirty) {
    public void onPreDraw(Rect dirty) {
        if (dirty != null) {
            nPrepareDirty(mRenderer, dirty.left, dirty.top, dirty.right, dirty.bottom, mOpaque);
        } else {
@@ -260,7 +260,7 @@ class GLES20Canvas extends HardwareCanvas {
            boolean opaque);

    @Override
    void onPostDraw() {
    public void onPostDraw() {
        nFinish(mRenderer);
    }

+5 −5
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ class GLES20DisplayList extends DisplayList {
    }

    @Override
    HardwareCanvas start() {
    public HardwareCanvas start() {
        if (mCanvas != null) {
            throw new IllegalStateException("Recording has already started");
        }
@@ -55,7 +55,7 @@ class GLES20DisplayList extends DisplayList {
    }

    @Override
    void invalidate() {
    public void invalidate() {
        if (mCanvas != null) {
            mCanvas.recycle();
            mCanvas = null;
@@ -64,12 +64,12 @@ class GLES20DisplayList extends DisplayList {
    }

    @Override
    boolean isValid() {
    public boolean isValid() {
        return mValid;
    }

    @Override
    void end() {
    public void end() {
        if (mCanvas != null) {
            if (mFinalizer != null) {
                mCanvas.end(mFinalizer.mNativeDisplayList);
@@ -83,7 +83,7 @@ class GLES20DisplayList extends DisplayList {
    }

    @Override
    int getSize() {
    public int getSize() {
        if (mFinalizer == null) return 0;
        return GLES20Canvas.getDisplayListSize(mFinalizer.mNativeDisplayList);
    }
+3 −3
Original line number Diff line number Diff line
@@ -42,12 +42,12 @@ public abstract class HardwareCanvas extends Canvas {
     * 
     * @param dirty The dirty rectangle to update, can be null.
     */
    abstract void onPreDraw(Rect dirty);
    public abstract void onPreDraw(Rect dirty);

    /**
     * Invoked after all drawing operation have been performed.
     */
    abstract void onPostDraw();
    public abstract void onPostDraw();
    
    /**
     * Draws the specified display list onto this canvas.
@@ -61,7 +61,7 @@ public abstract class HardwareCanvas extends Canvas {
     * @return True if the content of the display list requires another
     *         drawing pass (invalidate()), false otherwise
     */
    abstract boolean drawDisplayList(DisplayList displayList, int width, int height, Rect dirty);
    public abstract boolean drawDisplayList(DisplayList displayList, int width, int height, Rect dirty);

    /**
     * Outputs the specified display list to the log. This method exists for use by
+2 −2
Original line number Diff line number Diff line
@@ -276,7 +276,7 @@ public abstract class HardwareRenderer {
     * 
     * @return A new display list.
     */
    abstract DisplayList createDisplayList();
    public abstract DisplayList createDisplayList();

    /**
     * Creates a new hardware layer. A hardware layer built by calling this
@@ -1083,7 +1083,7 @@ public abstract class HardwareRenderer {
        }

        @Override
        DisplayList createDisplayList() {
        public DisplayList createDisplayList() {
            return new GLES20DisplayList();
        }

Loading