diff --git a/shell/common/animator.cc b/shell/common/animator.cc index 004069bd8cfe2..7e581c07ca6e5 100644 --- a/shell/common/animator.cc +++ b/shell/common/animator.cc @@ -190,7 +190,7 @@ void Animator::Render(std::unique_ptr layer_tree) { FML_DLOG(INFO) << "No pending continuation to commit"; } - delegate_.OnAnimatorDraw(layer_tree_pipeline_); + delegate_.OnAnimatorDraw(layer_tree_pipeline_, last_frame_target_time_); } bool Animator::CanReuseLastLayerTree() { diff --git a/shell/common/animator.h b/shell/common/animator.h index f96acb7e9a3a0..0bab57730015a 100644 --- a/shell/common/animator.h +++ b/shell/common/animator.h @@ -35,7 +35,8 @@ class Animator final { virtual void OnAnimatorNotifyIdle(int64_t deadline) = 0; virtual void OnAnimatorDraw( - fml::RefPtr> pipeline) = 0; + fml::RefPtr> pipeline, + fml::TimePoint frame_target_time) = 0; virtual void OnAnimatorDrawLastLayerTree() = 0; }; diff --git a/shell/common/shell.cc b/shell/common/shell.cc index 8d278535c15e9..d83fadbb4b833 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -952,9 +952,20 @@ void Shell::OnAnimatorNotifyIdle(int64_t deadline) { } // |Animator::Delegate| -void Shell::OnAnimatorDraw(fml::RefPtr> pipeline) { +void Shell::OnAnimatorDraw(fml::RefPtr> pipeline, + fml::TimePoint frame_target_time) { FML_DCHECK(is_setup_); + // record the target time for use by rasterizer. + { + std::scoped_lock time_recorder_lock(time_recorder_mutex_); + if (!latest_frame_target_time_) { + latest_frame_target_time_ = frame_target_time; + } else if (latest_frame_target_time_ < frame_target_time) { + latest_frame_target_time_ = frame_target_time; + } + } + task_runners_.GetRasterTaskRunner()->PostTask( [&waiting_for_first_frame = waiting_for_first_frame_, &waiting_for_first_frame_condition = waiting_for_first_frame_condition_, diff --git a/shell/common/shell.h b/shell/common/shell.h index 3c904d85c45e3..a39884a823aca 100644 --- a/shell/common/shell.h +++ b/shell/common/shell.h @@ -489,8 +489,8 @@ class Shell final : public PlatformView::Delegate, void OnAnimatorNotifyIdle(int64_t deadline) override; // |Animator::Delegate| - void OnAnimatorDraw( - fml::RefPtr> pipeline) override; + void OnAnimatorDraw(fml::RefPtr> pipeline, + fml::TimePoint frame_target_time) override; // |Animator::Delegate| void OnAnimatorDrawLastLayerTree() override;