Loading core/java/android/view/SurfaceControl.java +28 −0 Original line number Diff line number Diff line Loading @@ -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, Loading Loading @@ -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 Loading @@ -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 Loading core/java/android/view/SurfaceView.java +1 −1 Original line number Diff line number Diff line Loading @@ -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()); Loading core/java/android/view/SyncRtSurfaceTransactionApplier.java +3 −9 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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. Loading @@ -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; Loading @@ -92,9 +89,6 @@ public class SyncRtSurfaceTransactionApplier { } applyParams(t, surfaceParams, mTmpFloat9); } if (earlyWakeup) { t.setEarlyWakeup(); } t.apply(); } Loading core/java/android/view/ViewRootInsetsControllerHost.java +2 −3 Original line number Diff line number Diff line Loading @@ -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); } } Loading core/jni/android_view_SurfaceControl.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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 Loading
core/java/android/view/SurfaceControl.java +28 −0 Original line number Diff line number Diff line Loading @@ -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, Loading Loading @@ -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 Loading @@ -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 Loading
core/java/android/view/SurfaceView.java +1 −1 Original line number Diff line number Diff line Loading @@ -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()); Loading
core/java/android/view/SyncRtSurfaceTransactionApplier.java +3 −9 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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. Loading @@ -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; Loading @@ -92,9 +89,6 @@ public class SyncRtSurfaceTransactionApplier { } applyParams(t, surfaceParams, mTmpFloat9); } if (earlyWakeup) { t.setEarlyWakeup(); } t.apply(); } Loading
core/java/android/view/ViewRootInsetsControllerHost.java +2 −3 Original line number Diff line number Diff line Loading @@ -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); } } Loading
core/jni/android_view_SurfaceControl.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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