Commit 61967bd4 authored by Yi Gu's avatar Yi Gu Committed by Commit Bot

[Animation Worklet] Early exit from StartOnCompositor for main thread animations

If an animation has been started on main thread, there is no need to try
running it on the compositor at the moment. We plan to support the
transition from main to compositor (tracked via crbug.com/972691).

Bug: 962174
Change-Id: I766a4a87a6a0ae8c4360b54fbd15348cf3c11259
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1656019Reviewed-by: default avatarMajid Valipour <majidvp@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668560}
parent f54b2781
...@@ -503,7 +503,7 @@ void WorkletAnimation::UpdateCompositingState() { ...@@ -503,7 +503,7 @@ void WorkletAnimation::UpdateCompositingState() {
} else if (play_state_ == Animation::kRunning) { } else if (play_state_ == Animation::kRunning) {
// TODO(majidvp): If keyframes have changed then it may be possible to now // TODO(majidvp): If keyframes have changed then it may be possible to now
// run the animation on compositor. The current logic does not allow this // run the animation on compositor. The current logic does not allow this
// switch from main to compositor to happen. // switch from main to compositor to happen. https://crbug.com/972691.
if (!running_on_main_thread_) { if (!running_on_main_thread_) {
if (!UpdateOnCompositor()) { if (!UpdateOnCompositor()) {
// When an animation that is running on compositor loses the target, it // When an animation that is running on compositor loses the target, it
...@@ -535,6 +535,14 @@ void WorkletAnimation::StartOnMain() { ...@@ -535,6 +535,14 @@ void WorkletAnimation::StartOnMain() {
bool WorkletAnimation::StartOnCompositor() { bool WorkletAnimation::StartOnCompositor() {
DCHECK(IsMainThread()); DCHECK(IsMainThread());
// There is no need to proceed if an animation has already started on main
// thread.
// TODO(majidvp): If keyframes have changed then it may be possible to now
// run the animation on compositor. The current logic does not allow this
// switch from main to compositor to happen. https://crbug.com/972691.
if (running_on_main_thread_)
return false;
if (effects_.size() > 1) { if (effects_.size() > 1) {
// Compositor doesn't support multiple effects but they can be run via main. // Compositor doesn't support multiple effects but they can be run via main.
return false; return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment