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

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

Merge "Bag of scheduling tweaks" into lmp-preview-dev

parents db67ffd6 a5dda645
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -578,6 +578,12 @@ public abstract class HardwareRenderer {
     */
    abstract void fence();

    /**
     * Called by {@link ViewRootImpl} when a new performTraverals is scheduled.
     */
    public void notifyFramePending() {
    }

    /**
     * Describes a series of frames that should be drawn on screen as a graph.
     * Each frame is composed of 1 or more elements.
+6 −0
Original line number Diff line number Diff line
@@ -290,6 +290,11 @@ public class ThreadedRenderer extends HardwareRenderer {
        nFence(mNativeProxy);
    }

    @Override
    public void notifyFramePending() {
        nNotifyFramePending(mNativeProxy);
    }

    @Override
    protected void finalize() throws Throwable {
        try {
@@ -364,4 +369,5 @@ public class ThreadedRenderer extends HardwareRenderer {
    private static native void nDestroyLayer(long nativeProxy, long layer);

    private static native void nFence(long nativeProxy);
    private static native void nNotifyFramePending(long nativeProxy);
}
+12 −0
Original line number Diff line number Diff line
@@ -999,6 +999,17 @@ public final class ViewRootImpl implements ViewParent,
        }
    }

    /**
     * Notifies the HardwareRenderer that a new frame will be coming soon.
     * Currently only {@link ThreadedRenderer} cares about this, and uses
     * this knowledge to adjust the scheduling of off-thread animations
     */
    void notifyRendererOfFramePending() {
        if (mAttachInfo.mHardwareRenderer != null) {
            mAttachInfo.mHardwareRenderer.notifyFramePending();
        }
    }

    void scheduleTraversals() {
        if (!mTraversalScheduled) {
            mTraversalScheduled = true;
@@ -1006,6 +1017,7 @@ public final class ViewRootImpl implements ViewParent,
            mChoreographer.postCallback(
                    Choreographer.CALLBACK_TRAVERSAL, mTraversalRunnable, null);
            scheduleConsumeBatchedInput();
            notifyRendererOfFramePending();
        }
    }

+7 −0
Original line number Diff line number Diff line
@@ -299,6 +299,12 @@ static void android_view_ThreadedRenderer_fence(JNIEnv* env, jobject clazz,
    proxy->fence();
}

static void android_view_ThreadedRenderer_notifyFramePending(JNIEnv* env, jobject clazz,
        jlong proxyPtr) {
    RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
    proxy->notifyFramePending();
}

#endif

// ----------------------------------------------------------------------------
@@ -329,6 +335,7 @@ static JNINativeMethod gMethods[] = {
    { "nCopyLayerInto", "(JJJ)Z", (void*) android_view_ThreadedRenderer_copyLayerInto },
    { "nDestroyLayer", "(JJ)V", (void*) android_view_ThreadedRenderer_destroyLayer },
    { "nFence", "(J)V", (void*) android_view_ThreadedRenderer_fence },
    { "nNotifyFramePending", "(J)V", (void*) android_view_ThreadedRenderer_notifyFramePending },
#endif
};

+8 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ struct TreeInfo {
            : hasFunctors(false)
            , hasAnimations(false)
            , requiresUiRedraw(false)
            , canDrawThisFrame(true)
        {}
        bool hasFunctors;
        // This is only updated if evaluateAnimations is true
@@ -60,6 +61,13 @@ struct TreeInfo {
        // animate itself, such as if hasFunctors is true
        // This is only set if hasAnimations is true
        bool requiresUiRedraw;
        // This is set to true if draw() can be called this frame
        // false means that we must delay until the next vsync pulse as frame
        // production is outrunning consumption
        // NOTE that if this is false CanvasContext will set either requiresUiRedraw
        // *OR* will post itself for the next vsync automatically, use this
        // only to avoid calling draw()
        bool canDrawThisFrame;
    } out;

    // TODO: Damage calculations
Loading