forked from firka/flutter
Always update the latest frame target time when the 'Animator::Render' method is called (flutter/engine#31973)
This commit is contained in:
@@ -174,6 +174,9 @@ void Animator::Render(std::unique_ptr<flutter::LayerTree> layer_tree) {
|
||||
"Animator::Render");
|
||||
frame_timings_recorder_->RecordBuildEnd(fml::TimePoint::Now());
|
||||
|
||||
delegate_.OnAnimatorUpdateLatestFrameTargetTime(
|
||||
frame_timings_recorder_->GetVsyncTargetTime());
|
||||
|
||||
// Commit the pending continuation.
|
||||
PipelineProduceResult result =
|
||||
producer_continuation_.Complete(std::move(layer_tree));
|
||||
|
||||
@@ -36,6 +36,9 @@ class Animator final {
|
||||
|
||||
virtual void OnAnimatorNotifyIdle(fml::TimePoint deadline) = 0;
|
||||
|
||||
virtual void OnAnimatorUpdateLatestFrameTargetTime(
|
||||
fml::TimePoint frame_target_time) = 0;
|
||||
|
||||
virtual void OnAnimatorDraw(
|
||||
std::shared_ptr<Pipeline<flutter::LayerTree>> pipeline,
|
||||
std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder) = 0;
|
||||
|
||||
@@ -32,6 +32,9 @@ class FakeAnimatorDelegate : public Animator::Delegate {
|
||||
notify_idle_called_ = true;
|
||||
}
|
||||
|
||||
MOCK_METHOD1(OnAnimatorUpdateLatestFrameTargetTime,
|
||||
void(fml::TimePoint frame_target_time));
|
||||
|
||||
MOCK_METHOD2(
|
||||
OnAnimatorDraw,
|
||||
void(std::shared_ptr<Pipeline<flutter::LayerTree>> pipeline,
|
||||
@@ -222,9 +225,12 @@ TEST_F(ShellTest, AnimatorDoesNotNotifyDelegateIfPipelineIsNotEmpty) {
|
||||
[&](fml::TimePoint frame_target_time, uint64_t frame_number) {
|
||||
begin_frame_latch.Signal();
|
||||
});
|
||||
|
||||
// It will only be called once even though we call the method Animator::Render
|
||||
// twice. because it will only be called when the pipeline is empty.
|
||||
// It must always be called when the method 'Animator::Render' is called,
|
||||
// regardless of whether the pipeline is empty or not.
|
||||
EXPECT_CALL(delegate, OnAnimatorUpdateLatestFrameTargetTime).Times(2);
|
||||
// It will only be called once even though we call the method
|
||||
// 'Animator::Render' twice. because it will only be called when the pipeline
|
||||
// is empty.
|
||||
EXPECT_CALL(delegate, OnAnimatorDraw).Times(1);
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
@@ -1111,23 +1111,26 @@ void Shell::OnAnimatorNotifyIdle(fml::TimePoint deadline) {
|
||||
}
|
||||
}
|
||||
|
||||
// |Animator::Delegate|
|
||||
void Shell::OnAnimatorDraw(
|
||||
std::shared_ptr<Pipeline<flutter::LayerTree>> pipeline,
|
||||
std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder) {
|
||||
void Shell::OnAnimatorUpdateLatestFrameTargetTime(
|
||||
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_);
|
||||
const fml::TimePoint frame_target_time =
|
||||
frame_timings_recorder->GetVsyncTargetTime();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// |Animator::Delegate|
|
||||
void Shell::OnAnimatorDraw(
|
||||
std::shared_ptr<Pipeline<flutter::LayerTree>> pipeline,
|
||||
std::unique_ptr<FrameTimingsRecorder> frame_timings_recorder) {
|
||||
FML_DCHECK(is_setup_);
|
||||
|
||||
auto discard_callback = [this](flutter::LayerTree& tree) {
|
||||
std::scoped_lock<std::mutex> lock(resize_mutex_);
|
||||
|
||||
@@ -582,6 +582,10 @@ class Shell final : public PlatformView::Delegate,
|
||||
// |Animator::Delegate|
|
||||
void OnAnimatorNotifyIdle(fml::TimePoint deadline) override;
|
||||
|
||||
// |Animator::Delegate|
|
||||
void OnAnimatorUpdateLatestFrameTargetTime(
|
||||
fml::TimePoint frame_target_time) override;
|
||||
|
||||
// |Animator::Delegate|
|
||||
void OnAnimatorDraw(
|
||||
std::shared_ptr<Pipeline<flutter::LayerTree>> pipeline,
|
||||
|
||||
Reference in New Issue
Block a user