diff --git a/engine/src/flutter/flow/surface_frame.h b/engine/src/flutter/flow/surface_frame.h index 0e15cde490..2ecee0b176 100644 --- a/engine/src/flutter/flow/surface_frame.h +++ b/engine/src/flutter/flow/surface_frame.h @@ -28,6 +28,10 @@ class SurfaceFrame { // circumstances such as a BackdropFilter. bool supports_readback = false; + // Indicates that target device supports partial repaint. At very minimum + // this means that the surface will provide valid existing damage. + bool supports_partial_repaint = false; + // This is the area of framebuffer that lags behind the front buffer. // // Correctly providing exiting_damage is necessary for supporting double and diff --git a/engine/src/flutter/shell/common/rasterizer.cc b/engine/src/flutter/shell/common/rasterizer.cc index ad5644c45f..2fec73ab23 100644 --- a/engine/src/flutter/shell/common/rasterizer.cc +++ b/engine/src/flutter/shell/common/rasterizer.cc @@ -552,30 +552,35 @@ RasterStatus Rasterizer::DrawToSurfaceUnsafe( compositor_context_->raster_cache().PrepareNewFrame(); frame_timings_recorder.RecordRasterStart(fml::TimePoint::Now()); - // Disable partial repaint if external_view_embedder_ SubmitFrame is - // involved - ExternalViewEmbedder unconditionally clears the entire - // surface and also partial repaint with platform view present is something - // that still need to be figured out. - bool disable_partial_repaint = - external_view_embedder_ && - (!raster_thread_merger_ || raster_thread_merger_->IsMerged()); + std::unique_ptr damage; + if (frame->framebuffer_info().supports_partial_repaint) { + // Disable partial repaint if external_view_embedder_ SubmitFrame is + // involved - ExternalViewEmbedder unconditionally clears the entire + // surface and also partial repaint with platform view present is + // something that still need to be figured out. + bool force_full_repaint = + external_view_embedder_ && + (!raster_thread_merger_ || raster_thread_merger_->IsMerged()); - FrameDamage damage; - if (!disable_partial_repaint && frame->framebuffer_info().existing_damage) { - damage.SetPreviousLayerTree(last_layer_tree_.get()); - damage.AddAdditonalDamage(*frame->framebuffer_info().existing_damage); + damage = std::make_unique(); + if (frame->framebuffer_info().existing_damage && !force_full_repaint) { + damage->SetPreviousLayerTree(last_layer_tree_.get()); + damage->AddAdditonalDamage(*frame->framebuffer_info().existing_damage); + } } RasterStatus raster_status = - compositor_frame->Raster(layer_tree, false, &damage); + compositor_frame->Raster(layer_tree, false, damage.get()); if (raster_status == RasterStatus::kFailed || raster_status == RasterStatus::kSkipAndRetry) { return raster_status; } SurfaceFrame::SubmitInfo submit_info; - submit_info.frame_damage = damage.GetFrameDamage(); - submit_info.buffer_damage = damage.GetBufferDamage(); + if (damage) { + submit_info.frame_damage = damage->GetFrameDamage(); + submit_info.buffer_damage = damage->GetBufferDamage(); + } frame->set_submit_info(submit_info); diff --git a/engine/src/flutter/shell/gpu/gpu_surface_metal.mm b/engine/src/flutter/shell/gpu/gpu_surface_metal.mm index b9e92bb9b1..aaa0b76fdb 100644 --- a/engine/src/flutter/shell/gpu/gpu_surface_metal.mm +++ b/engine/src/flutter/shell/gpu/gpu_surface_metal.mm @@ -160,7 +160,7 @@ std::unique_ptr GPUSurfaceMetal::AcquireFrameFromCAMetalLayer( if (i != damage_.end()) { framebuffer_info.existing_damage = i->second; } - + framebuffer_info.supports_partial_repaint = true; return std::make_unique(std::move(surface), framebuffer_info, submit_callback); }