Allow rendering of frames in a paused animator during a change to screen dimensions (flutter/engine#4333)
Fixes https://github.com/flutter/flutter/issues/12886
This commit is contained in:
@@ -25,6 +25,7 @@ Animator::Animator(fml::WeakPtr<Rasterizer> 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<flow::LayerTree> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ class Animator {
|
||||
|
||||
void Stop();
|
||||
|
||||
void SetDimensionChangePending();
|
||||
|
||||
private:
|
||||
using LayerTreePipeline = flutter::Pipeline<flow::LayerTree>;
|
||||
|
||||
@@ -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<Animator> weak_factory_;
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user