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

Commit 71e5ab59 authored by Ady Abraham's avatar Ady Abraham Committed by Automerger Merge Worker
Browse files

Merge "WM: Replace eEarlyWakeup flags with explicit eEarlyWakeup start and end...

Merge "WM: Replace eEarlyWakeup flags with explicit eEarlyWakeup start and end flags" into rvc-dev am: 278f0031 am: 5173ddf9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11852824

Change-Id: Idcabf2d07d54f141d608f73acd934706be0bb099
parents b7985e80 5173ddf9
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -102,6 +102,8 @@ public final class SurfaceControl implements Parcelable {
            long otherTransactionObj);
    private static native void nativeSetAnimationTransaction(long transactionObj);
    private static native void nativeSetEarlyWakeup(long transactionObj);
    private static native void nativeSetEarlyWakeupStart(long transactionObj);
    private static native void nativeSetEarlyWakeupEnd(long transactionObj);

    private static native void nativeSetLayer(long transactionObj, long nativeObject, int zorder);
    private static native void nativeSetRelativeLayer(long transactionObj, long nativeObject,
@@ -2775,6 +2777,8 @@ public final class SurfaceControl implements Parcelable {
        }

        /**
         * @deprecated use {@link Transaction#setEarlyWakeupStart()}
         *
         * Indicate that SurfaceFlinger should wake up earlier than usual as a result of this
         * transaction. This should be used when the caller thinks that the scene is complex enough
         * that it's likely to hit GL composition, and thus, SurfaceFlinger needs to more time in
@@ -2783,11 +2787,35 @@ public final class SurfaceControl implements Parcelable {
         * Corresponds to setting ISurfaceComposer::eEarlyWakeup
         * @hide
         */
        @Deprecated
        public Transaction setEarlyWakeup() {
            nativeSetEarlyWakeup(mNativeObject);
            return this;
        }

         /**
          * Provides a hint to SurfaceFlinger to change its offset so that SurfaceFlinger wakes up
          * earlier to compose surfaces. The caller should use this as a hint to SurfaceFlinger
          * when the scene is complex enough to use GPU composition. The hint will remain active
          * until until the client calls {@link Transaction#setEarlyWakeupEnd}.
          *
          * @hide
          */
        public Transaction setEarlyWakeupStart() {
            nativeSetEarlyWakeupStart(mNativeObject);
            return this;
        }

        /**
         * Removes the early wake up hint set by {@link Transaction#setEarlyWakeupStart}.
         *
         * @hide
         */
        public Transaction setEarlyWakeupEnd() {
            nativeSetEarlyWakeupEnd(mNativeObject);
            return this;
        }

        /**
         * Sets an arbitrary piece of metadata on the surface. This is a helper for int data.
         * @hide
+1 −1
Original line number Diff line number Diff line
@@ -640,7 +640,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
                mTmpRect.set(0, 0, mSurfaceWidth, mSurfaceHeight);
            }
            SyncRtSurfaceTransactionApplier applier = new SyncRtSurfaceTransactionApplier(this);
            applier.scheduleApply(false /* earlyWakeup */,
            applier.scheduleApply(
                    new SyncRtSurfaceTransactionApplier.SurfaceParams.Builder(mSurfaceControl)
                            .withWindowCrop(mTmpRect)
                            .build());
+3 −9
Original line number Diff line number Diff line
@@ -53,11 +53,10 @@ public class SyncRtSurfaceTransactionApplier {
    /**
     * Schedules applying surface parameters on the next frame.
     *
     * @param earlyWakeup Whether to set {@link Transaction#setEarlyWakeup()} on transaction.
     * @param params The surface parameters to apply. DO NOT MODIFY the list after passing into
     *               this method to avoid synchronization issues.
     */
    public void scheduleApply(boolean earlyWakeup, final SurfaceParams... params) {
    public void scheduleApply(final SurfaceParams... params) {
        if (mTargetViewRootImpl == null) {
            return;
        }
@@ -67,7 +66,7 @@ public class SyncRtSurfaceTransactionApplier {
                return;
            }
            Transaction t = new Transaction();
            applyParams(t, frame, earlyWakeup, params);
            applyParams(t, frame, params);
        });

        // Make sure a frame gets scheduled.
@@ -78,12 +77,10 @@ public class SyncRtSurfaceTransactionApplier {
     * Applies surface parameters on the next frame.
     * @param t transaction to apply all parameters in.
     * @param frame frame to synchronize to. Set -1 when sync is not required.
     * @param earlyWakeup Whether to set {@link Transaction#setEarlyWakeup()} on transaction.
     * @param params The surface parameters to apply. DO NOT MODIFY the list after passing into
     *               this method to avoid synchronization issues.
     */
     void applyParams(Transaction t, long frame, boolean earlyWakeup,
            final SurfaceParams... params) {
     void applyParams(Transaction t, long frame, final SurfaceParams... params) {
        for (int i = params.length - 1; i >= 0; i--) {
            SurfaceParams surfaceParams = params[i];
            SurfaceControl surface = surfaceParams.surface;
@@ -92,9 +89,6 @@ public class SyncRtSurfaceTransactionApplier {
            }
            applyParams(t, surfaceParams, mTmpFloat9);
        }
        if (earlyWakeup) {
            t.setEarlyWakeup();
        }
        t.apply();
    }

+2 −3
Original line number Diff line number Diff line
@@ -120,13 +120,12 @@ public class ViewRootInsetsControllerHost implements InsetsController.Host {
            mApplier = new SyncRtSurfaceTransactionApplier(mViewRoot.mView);
        }
        if (mViewRoot.mView.isHardwareAccelerated()) {
            mApplier.scheduleApply(false /* earlyWakeup */, params);
            mApplier.scheduleApply(params);
        } else {
            // Window doesn't support hardware acceleration, no synchronization for now.
            // TODO(b/149342281): use mViewRoot.mSurface.getNextFrameNumber() to sync on every
            //  frame instead.
            mApplier.applyParams(new SurfaceControl.Transaction(), -1 /* frame */,
                    false /* earlyWakeup */, params);
            mApplier.applyParams(new SurfaceControl.Transaction(), -1 /* frame */, params);
        }
    }

+14 −0
Original line number Diff line number Diff line
@@ -395,6 +395,16 @@ static void nativeSetEarlyWakeup(JNIEnv* env, jclass clazz, jlong transactionObj
    transaction->setEarlyWakeup();
}

static void nativeSetEarlyWakeupStart(JNIEnv* env, jclass clazz, jlong transactionObj) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    transaction->setExplicitEarlyWakeupStart();
}

static void nativeSetEarlyWakeupEnd(JNIEnv* env, jclass clazz, jlong transactionObj) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    transaction->setExplicitEarlyWakeupEnd();
}

static void nativeSetLayer(JNIEnv* env, jclass clazz, jlong transactionObj,
        jlong nativeObject, jint zorder) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
@@ -1501,6 +1511,10 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSetAnimationTransaction },
    {"nativeSetEarlyWakeup", "(J)V",
            (void*)nativeSetEarlyWakeup },
    {"nativeSetEarlyWakeupStart", "(J)V",
            (void*)nativeSetEarlyWakeupStart },
    {"nativeSetEarlyWakeupEnd", "(J)V",
            (void*)nativeSetEarlyWakeupEnd },
    {"nativeSetLayer", "(JJI)V",
            (void*)nativeSetLayer },
    {"nativeSetRelativeLayer", "(JJJI)V",
Loading