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

Commit ac5f7554 authored by Matt Buckley's avatar Matt Buckley
Browse files

Send load up hint on view inflation

In order for HWUI to keep up with sudden changes in workload, it
needs to send hints in advance of view inflation in order to compensate
for these increases. This patch allows HWUI to inform PowerHAL about
upcoming spikes in workload.

Bug: b/261130508
Test: manual
Change-Id: Ie0bb80d021dee13067d1960276065f6f2e0af34d
parent effd5af6
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -640,6 +640,10 @@ public abstract class LayoutInflater {
            mConstructorArgs[0] = inflaterContext;
            View result = root;

            if (root != null && root.getViewRootImpl() != null) {
                root.getViewRootImpl().notifyRendererOfExpensiveFrame();
            }

            try {
                advanceToRootNode(parser);
                final String name = parser.getName();
@@ -662,6 +666,10 @@ public abstract class LayoutInflater {
                    // Temp is the root view that was found in the xml
                    final View temp = createViewFromTag(root, name, inflaterContext, attrs);

                    if (root == null && temp != null && temp.getViewRootImpl() != null) {
                        temp.getViewRootImpl().notifyRendererOfExpensiveFrame();
                    }

                    ViewGroup.LayoutParams params = null;

                    if (root != null) {
+7 −0
Original line number Diff line number Diff line
@@ -594,6 +594,13 @@ public final class ThreadedRenderer extends HardwareRenderer {
        }
    }

    @Override
    public void notifyExpensiveFrame() {
        if (isEnabled()) {
            super.notifyExpensiveFrame();
        }
    }

    /**
     * Updates the light position based on the position of the window.
     *
+12 −0
Original line number Diff line number Diff line
@@ -2334,6 +2334,18 @@ public final class ViewRootImpl implements ViewParent,
        }
    }

    /**
     * Notifies the HardwareRenderer of an expensive upcoming frame, to
     * allow better handling of power and scheduling requirements.
     *
     * @hide
     */
    void notifyRendererOfExpensiveFrame() {
        if (mAttachInfo.mThreadedRenderer != null) {
            mAttachInfo.mThreadedRenderer.notifyExpensiveFrame();
        }
    }

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    void scheduleTraversals() {
        if (!mTraversalScheduled) {
+11 −0
Original line number Diff line number Diff line
@@ -991,6 +991,15 @@ public class HardwareRenderer {
        nNotifyCallbackPending(mNativeProxy);
    }

    /**
     * Notifies the hardware renderer about upcoming expensive frames.
     *
     * @hide
     */
    public void notifyExpensiveFrame() {
        nNotifyExpensiveFrame(mNativeProxy);
    }

    /**
     * b/68769804, b/66945974: For low FPS experiments.
     *
@@ -1551,4 +1560,6 @@ public class HardwareRenderer {
    private static native void nSetRtAnimationsEnabled(boolean rtAnimationsEnabled);

    private static native void nNotifyCallbackPending(long nativeProxy);

    private static native void nNotifyExpensiveFrame(long nativeProxy);
}
+7 −0
Original line number Diff line number Diff line
@@ -865,6 +865,11 @@ static void android_view_ThreadedRenderer_notifyCallbackPending(JNIEnv*, jclass,
    proxy->notifyCallbackPending();
}

static void android_view_ThreadedRenderer_notifyExpensiveFrame(JNIEnv*, jclass, jlong proxyPtr) {
    RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
    proxy->notifyExpensiveFrame();
}

// Plumbs the display density down to DeviceInfo.
static void android_view_ThreadedRenderer_setDisplayDensityDpi(JNIEnv*, jclass, jint densityDpi) {
    // Convert from dpi to density-independent pixels.
@@ -1044,6 +1049,8 @@ static const JNINativeMethod gMethods[] = {
         (void*)android_view_ThreadedRenderer_setRtAnimationsEnabled},
        {"nNotifyCallbackPending", "(J)V",
         (void*)android_view_ThreadedRenderer_notifyCallbackPending},
        {"nNotifyExpensiveFrame", "(J)V",
         (void*)android_view_ThreadedRenderer_notifyExpensiveFrame},
};

static JavaVM* mJvm = nullptr;
Loading