diff --git a/flow/embedded_views.h b/flow/embedded_views.h index 50d09ed928859..1b641665e3690 100644 --- a/flow/embedded_views.h +++ b/flow/embedded_views.h @@ -187,6 +187,10 @@ class ExternalViewEmbedder { // have mutated for last layer tree. virtual bool HasPendingViewOperations() = 0; + // Call this in-lieu of |SubmitFrame| to clear pre-roll state and + // sets the stage for the next pre-roll. + virtual void CancelFrame() = 0; + virtual void BeginFrame(SkISize frame_size) = 0; virtual void PrerollCompositeEmbeddedView( diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index aa2e2ab0bf4b3..33c5332baa96d 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -160,6 +160,10 @@ frame_size_ = frame_size; } +void FlutterPlatformViewsController::CancelFrame() { + composition_order_.clear(); +} + bool FlutterPlatformViewsController::HasPendingViewOperations() { if (!views_to_recomposite_.empty()) { return true; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index 40ea6333dff23..9644682c9156e 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -81,6 +81,8 @@ class FlutterPlatformViewsController { bool HasPendingViewOperations(); + void CancelFrame(); + void PrerollCompositeEmbeddedView(int view_id, std::unique_ptr params); diff --git a/shell/platform/darwin/ios/ios_surface_gl.h b/shell/platform/darwin/ios/ios_surface_gl.h index 8999669c6a0a9..eb1bf4a61c87f 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.h +++ b/shell/platform/darwin/ios/ios_surface_gl.h @@ -51,6 +51,9 @@ class IOSSurfaceGL final : public IOSSurface, // |GPUSurfaceGLDelegate| flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; + // |flutter::ExternalViewEmbedder| + void CancelFrame() override; + // |flutter::ExternalViewEmbedder| bool HasPendingViewOperations() override; diff --git a/shell/platform/darwin/ios/ios_surface_gl.mm b/shell/platform/darwin/ios/ios_surface_gl.mm index 5f4185a07bf69..aaad61190530f 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.mm +++ b/shell/platform/darwin/ios/ios_surface_gl.mm @@ -82,6 +82,15 @@ } } +void IOSSurfaceGL::CancelFrame() { + FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); + FML_CHECK(platform_views_controller != nullptr); + platform_views_controller->CancelFrame(); + // Committing the current transaction as |BeginFrame| will create a nested + // CATransaction otherwise. + [CATransaction commit]; +} + bool IOSSurfaceGL::HasPendingViewOperations() { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); diff --git a/shell/platform/darwin/ios/ios_surface_software.h b/shell/platform/darwin/ios/ios_surface_software.h index 7b0c2a0b0db9c..29d3ad7eaef58 100644 --- a/shell/platform/darwin/ios/ios_surface_software.h +++ b/shell/platform/darwin/ios/ios_surface_software.h @@ -45,6 +45,9 @@ class IOSSurfaceSoftware final : public IOSSurface, // |GPUSurfaceSoftwareDelegate| flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; + // |flutter::ExternalViewEmbedder| + void CancelFrame() override; + // |flutter::ExternalViewEmbedder| bool HasPendingViewOperations() override; diff --git a/shell/platform/darwin/ios/ios_surface_software.mm b/shell/platform/darwin/ios/ios_surface_software.mm index 2977ed792c34c..30818eb7ff9d2 100644 --- a/shell/platform/darwin/ios/ios_surface_software.mm +++ b/shell/platform/darwin/ios/ios_surface_software.mm @@ -135,6 +135,12 @@ } } +void IOSSurfaceSoftware::CancelFrame() { + FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); + FML_CHECK(platform_views_controller != nullptr); + platform_views_controller->CancelFrame(); +} + bool IOSSurfaceSoftware::HasPendingViewOperations() { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr);