Loading core/java/android/view/SurfaceControlViewHost.java +7 −1 Original line number Diff line number Diff line Loading @@ -273,8 +273,14 @@ public class SurfaceControlViewHost { /** @hide */ public SurfaceControlViewHost(@NonNull Context c, @NonNull Display d, @NonNull WindowlessWindowManager wwm) { this(c, d, wwm, false /* useSfChoreographer */); } /** @hide */ public SurfaceControlViewHost(@NonNull Context c, @NonNull Display d, @NonNull WindowlessWindowManager wwm, boolean useSfChoreographer) { mWm = wwm; mViewRoot = new ViewRootImpl(c, d, mWm); mViewRoot = new ViewRootImpl(c, d, mWm, useSfChoreographer); addConfigCallback(c, d); WindowManagerGlobal.getInstance().addWindowlessRoot(mViewRoot); Loading core/java/android/view/ViewRootImpl.java +9 −2 Original line number Diff line number Diff line Loading @@ -854,10 +854,16 @@ public final class ViewRootImpl implements ViewParent, private String mTag = TAG; public ViewRootImpl(Context context, Display display) { this(context, display, WindowManagerGlobal.getWindowSession()); this(context, display, WindowManagerGlobal.getWindowSession(), false /* useSfChoreographer */); } public ViewRootImpl(@UiContext Context context, Display display, IWindowSession session) { this(context, display, session, false /* useSfChoreographer */); } public ViewRootImpl(@UiContext Context context, Display display, IWindowSession session, boolean useSfChoreographer) { mContext = context; mWindowSession = session; mDisplay = display; Loading Loading @@ -889,7 +895,8 @@ public final class ViewRootImpl implements ViewParent, mNoncompatDensity = context.getResources().getDisplayMetrics().noncompatDensityDpi; mFallbackEventHandler = new PhoneFallbackEventHandler(context); // TODO(b/222696368): remove getSfInstance usage and use vsyncId for transactions mChoreographer = Choreographer.getInstance(); mChoreographer = useSfChoreographer ? Choreographer.getSfInstance() : Choreographer.getInstance(); mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE); mInsetsController = new InsetsController(new ViewRootInsetsControllerHost(this)); mHandwritingInitiator = new HandwritingInitiator(mViewConfiguration, Loading libs/WindowManager/Shell/src/com/android/wm/shell/common/SystemWindows.java +2 −1 Original line number Diff line number Diff line Loading @@ -221,7 +221,8 @@ public class SystemWindows { } final Display display = mDisplayController.getDisplay(mDisplayId); SurfaceControlViewHost viewRoot = new SurfaceControlViewHost(view.getContext(), display, wwm); new SurfaceControlViewHost( view.getContext(), display, wwm, true /* useSfChoreographer */); attrs.flags |= FLAG_HARDWARE_ACCELERATED; viewRoot.setView(view, attrs); mViewRoots.put(view, viewRoot); Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellConcurrencyModule.java +27 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.wm.shell.dagger; import static android.os.Process.THREAD_PRIORITY_DISPLAY; import static android.os.Process.THREAD_PRIORITY_TOP_APP_BOOST; import android.animation.AnimationHandler; import android.content.Context; import android.os.Build; import android.os.Handler; Loading @@ -28,9 +29,11 @@ import android.os.Trace; import androidx.annotation.Nullable; import com.android.internal.graphics.SfVsyncFrameCallbackProvider; import com.android.wm.shell.R; import com.android.wm.shell.common.HandlerExecutor; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.annotations.ChoreographerSfVsync; import com.android.wm.shell.common.annotations.ExternalMainThread; import com.android.wm.shell.common.annotations.ShellAnimationThread; import com.android.wm.shell.common.annotations.ShellMainThread; Loading Loading @@ -168,4 +171,28 @@ public abstract class WMShellConcurrencyModule { shellSplashscreenThread.start(); return new HandlerExecutor(shellSplashscreenThread.getThreadHandler()); } /** * Provide a Shell main-thread AnimationHandler. The AnimationHandler can be set on * {@link android.animation.ValueAnimator}s and will ensure that the animation will run on * the Shell main-thread with the SF vsync. */ @WMSingleton @Provides @ChoreographerSfVsync public static AnimationHandler provideShellMainExecutorSfVsyncAnimationHandler( @ShellMainThread ShellExecutor mainExecutor) { try { AnimationHandler handler = new AnimationHandler(); mainExecutor.executeBlocking(() -> { // This is called on the animation thread since it calls // Choreographer.getSfInstance() which returns a thread-local Choreographer instance // that uses the SF vsync handler.setProvider(new SfVsyncFrameCallbackProvider()); }); return handler; } catch (InterruptedException e) { throw new RuntimeException("Failed to initialize SfVsync animation handler in 1s", e); } } } libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +5 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.dagger; import android.animation.AnimationHandler; import android.content.Context; import android.content.pm.LauncherApps; import android.os.Handler; Loading @@ -41,6 +42,7 @@ import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.common.SystemWindows; import com.android.wm.shell.common.TaskStackListenerImpl; import com.android.wm.shell.common.TransactionPool; import com.android.wm.shell.common.annotations.ChoreographerSfVsync; import com.android.wm.shell.common.annotations.ShellMainThread; import com.android.wm.shell.draganddrop.DragAndDropController; import com.android.wm.shell.freeform.FreeformTaskListener; Loading Loading @@ -182,10 +184,11 @@ public class WMShellModule { DisplayImeController displayImeController, TransactionPool transactionPool, ShellTaskOrganizer shellTaskOrganizer, SyncTransactionQueue syncQueue, TaskStackListenerImpl taskStackListener, Transitions transitions, @ShellMainThread ShellExecutor mainExecutor) { @ShellMainThread ShellExecutor mainExecutor, @ChoreographerSfVsync AnimationHandler sfVsyncAnimationHandler) { return new LegacySplitScreenController(context, displayController, systemWindows, displayImeController, transactionPool, shellTaskOrganizer, syncQueue, taskStackListener, transitions, mainExecutor); taskStackListener, transitions, mainExecutor, sfVsyncAnimationHandler); } @WMSingleton Loading Loading
core/java/android/view/SurfaceControlViewHost.java +7 −1 Original line number Diff line number Diff line Loading @@ -273,8 +273,14 @@ public class SurfaceControlViewHost { /** @hide */ public SurfaceControlViewHost(@NonNull Context c, @NonNull Display d, @NonNull WindowlessWindowManager wwm) { this(c, d, wwm, false /* useSfChoreographer */); } /** @hide */ public SurfaceControlViewHost(@NonNull Context c, @NonNull Display d, @NonNull WindowlessWindowManager wwm, boolean useSfChoreographer) { mWm = wwm; mViewRoot = new ViewRootImpl(c, d, mWm); mViewRoot = new ViewRootImpl(c, d, mWm, useSfChoreographer); addConfigCallback(c, d); WindowManagerGlobal.getInstance().addWindowlessRoot(mViewRoot); Loading
core/java/android/view/ViewRootImpl.java +9 −2 Original line number Diff line number Diff line Loading @@ -854,10 +854,16 @@ public final class ViewRootImpl implements ViewParent, private String mTag = TAG; public ViewRootImpl(Context context, Display display) { this(context, display, WindowManagerGlobal.getWindowSession()); this(context, display, WindowManagerGlobal.getWindowSession(), false /* useSfChoreographer */); } public ViewRootImpl(@UiContext Context context, Display display, IWindowSession session) { this(context, display, session, false /* useSfChoreographer */); } public ViewRootImpl(@UiContext Context context, Display display, IWindowSession session, boolean useSfChoreographer) { mContext = context; mWindowSession = session; mDisplay = display; Loading Loading @@ -889,7 +895,8 @@ public final class ViewRootImpl implements ViewParent, mNoncompatDensity = context.getResources().getDisplayMetrics().noncompatDensityDpi; mFallbackEventHandler = new PhoneFallbackEventHandler(context); // TODO(b/222696368): remove getSfInstance usage and use vsyncId for transactions mChoreographer = Choreographer.getInstance(); mChoreographer = useSfChoreographer ? Choreographer.getSfInstance() : Choreographer.getInstance(); mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE); mInsetsController = new InsetsController(new ViewRootInsetsControllerHost(this)); mHandwritingInitiator = new HandwritingInitiator(mViewConfiguration, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/common/SystemWindows.java +2 −1 Original line number Diff line number Diff line Loading @@ -221,7 +221,8 @@ public class SystemWindows { } final Display display = mDisplayController.getDisplay(mDisplayId); SurfaceControlViewHost viewRoot = new SurfaceControlViewHost(view.getContext(), display, wwm); new SurfaceControlViewHost( view.getContext(), display, wwm, true /* useSfChoreographer */); attrs.flags |= FLAG_HARDWARE_ACCELERATED; viewRoot.setView(view, attrs); mViewRoots.put(view, viewRoot); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellConcurrencyModule.java +27 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.wm.shell.dagger; import static android.os.Process.THREAD_PRIORITY_DISPLAY; import static android.os.Process.THREAD_PRIORITY_TOP_APP_BOOST; import android.animation.AnimationHandler; import android.content.Context; import android.os.Build; import android.os.Handler; Loading @@ -28,9 +29,11 @@ import android.os.Trace; import androidx.annotation.Nullable; import com.android.internal.graphics.SfVsyncFrameCallbackProvider; import com.android.wm.shell.R; import com.android.wm.shell.common.HandlerExecutor; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.annotations.ChoreographerSfVsync; import com.android.wm.shell.common.annotations.ExternalMainThread; import com.android.wm.shell.common.annotations.ShellAnimationThread; import com.android.wm.shell.common.annotations.ShellMainThread; Loading Loading @@ -168,4 +171,28 @@ public abstract class WMShellConcurrencyModule { shellSplashscreenThread.start(); return new HandlerExecutor(shellSplashscreenThread.getThreadHandler()); } /** * Provide a Shell main-thread AnimationHandler. The AnimationHandler can be set on * {@link android.animation.ValueAnimator}s and will ensure that the animation will run on * the Shell main-thread with the SF vsync. */ @WMSingleton @Provides @ChoreographerSfVsync public static AnimationHandler provideShellMainExecutorSfVsyncAnimationHandler( @ShellMainThread ShellExecutor mainExecutor) { try { AnimationHandler handler = new AnimationHandler(); mainExecutor.executeBlocking(() -> { // This is called on the animation thread since it calls // Choreographer.getSfInstance() which returns a thread-local Choreographer instance // that uses the SF vsync handler.setProvider(new SfVsyncFrameCallbackProvider()); }); return handler; } catch (InterruptedException e) { throw new RuntimeException("Failed to initialize SfVsync animation handler in 1s", e); } } }
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +5 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.dagger; import android.animation.AnimationHandler; import android.content.Context; import android.content.pm.LauncherApps; import android.os.Handler; Loading @@ -41,6 +42,7 @@ import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.common.SystemWindows; import com.android.wm.shell.common.TaskStackListenerImpl; import com.android.wm.shell.common.TransactionPool; import com.android.wm.shell.common.annotations.ChoreographerSfVsync; import com.android.wm.shell.common.annotations.ShellMainThread; import com.android.wm.shell.draganddrop.DragAndDropController; import com.android.wm.shell.freeform.FreeformTaskListener; Loading Loading @@ -182,10 +184,11 @@ public class WMShellModule { DisplayImeController displayImeController, TransactionPool transactionPool, ShellTaskOrganizer shellTaskOrganizer, SyncTransactionQueue syncQueue, TaskStackListenerImpl taskStackListener, Transitions transitions, @ShellMainThread ShellExecutor mainExecutor) { @ShellMainThread ShellExecutor mainExecutor, @ChoreographerSfVsync AnimationHandler sfVsyncAnimationHandler) { return new LegacySplitScreenController(context, displayController, systemWindows, displayImeController, transactionPool, shellTaskOrganizer, syncQueue, taskStackListener, transitions, mainExecutor); taskStackListener, transitions, mainExecutor, sfVsyncAnimationHandler); } @WMSingleton Loading