diff --git a/shell/common/animator.cc b/shell/common/animator.cc index 30deb0638b671..02a32495ca94c 100644 --- a/shell/common/animator.cc +++ b/shell/common/animator.cc @@ -25,6 +25,7 @@ Animator::Animator(fml::WeakPtr rasterizer, paused_(false), regenerate_layer_tree_(false), frame_scheduled_(false), + dimension_change_pending_(false), weak_factory_(this) {} Animator::~Animator() = default; @@ -42,6 +43,12 @@ void Animator::Start() { RequestFrame(); } +// Indicate that screen dimensions will be changing in order to force rendering +// of an updated frame even if the animator is currently paused. +void Animator::SetDimensionChangePending() { + dimension_change_pending_ = true; +} + // This Parity is used by the timeline component to correctly align // GPU Workloads events with their respective Framework Workload. const char* Animator::FrameParity() { @@ -98,6 +105,12 @@ void Animator::BeginFrame(fxl::TimePoint frame_start_time, } void Animator::Render(std::unique_ptr layer_tree) { + if (dimension_change_pending_ && + layer_tree->frame_size() != last_layer_tree_size_) { + dimension_change_pending_ = false; + } + last_layer_tree_size_ = layer_tree->frame_size(); + if (layer_tree) { // Note the frame time for instrumentation. layer_tree->set_construction_time(fxl::TimePoint::Now() - @@ -134,7 +147,7 @@ void Animator::RequestFrame(bool regenerate_layer_tree) { if (regenerate_layer_tree) { regenerate_layer_tree_ = true; } - if (paused_) { + if (paused_ && !dimension_change_pending_) { return; } diff --git a/shell/common/animator.h b/shell/common/animator.h index 300d422d59b7f..0f2b4ee31566c 100644 --- a/shell/common/animator.h +++ b/shell/common/animator.h @@ -36,6 +36,8 @@ class Animator { void Stop(); + void SetDimensionChangePending(); + private: using LayerTreePipeline = flutter::Pipeline; @@ -63,6 +65,8 @@ class Animator { bool paused_; bool regenerate_layer_tree_; bool frame_scheduled_; + bool dimension_change_pending_; + SkISize last_layer_tree_size_; fml::WeakPtrFactory weak_factory_; diff --git a/shell/common/engine.cc b/shell/common/engine.cc index b092ab2addcfc..9e7fff7d99147 100644 --- a/shell/common/engine.cc +++ b/shell/common/engine.cc @@ -326,6 +326,11 @@ void Engine::SetViewportMetrics(const blink::ViewportMetrics& metrics) { viewport_metrics_ = metrics; if (runtime_) runtime_->SetViewportMetrics(viewport_metrics_); + if (animator_) { + animator_->SetDimensionChangePending(); + if (have_surface_) + ScheduleFrame(); + } } void Engine::DispatchPlatformMessage(