Skip to content

Commit

Permalink
ExternalViewEmbedder can CancelFrame after pre-roll (flutter#9660)
Browse files Browse the repository at this point in the history
* ExternalViewEmbedder can CancelFrame after pre-roll

- Resets the state so next pre-roll can be successful.
- Commit any pending `CATransaction` so we don't create
  nested transactions.

* Update flow/embedded_views.h
  • Loading branch information
iskakaushik committed Jul 3, 2019
1 parent d637f29 commit 791143f
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions flow/embedded_views.h
Expand Up @@ -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(
Expand Down
Expand Up @@ -160,6 +160,10 @@
frame_size_ = frame_size;
}

void FlutterPlatformViewsController::CancelFrame() {
composition_order_.clear();
}

bool FlutterPlatformViewsController::HasPendingViewOperations() {
if (!views_to_recomposite_.empty()) {
return true;
Expand Down
Expand Up @@ -81,6 +81,8 @@ class FlutterPlatformViewsController {

bool HasPendingViewOperations();

void CancelFrame();

void PrerollCompositeEmbeddedView(int view_id,
std::unique_ptr<flutter::EmbeddedViewParams> params);

Expand Down
3 changes: 3 additions & 0 deletions shell/platform/darwin/ios/ios_surface_gl.h
Expand Up @@ -51,6 +51,9 @@ class IOSSurfaceGL final : public IOSSurface,
// |GPUSurfaceGLDelegate|
flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override;

// |flutter::ExternalViewEmbedder|
void CancelFrame() override;

// |flutter::ExternalViewEmbedder|
bool HasPendingViewOperations() override;

Expand Down
9 changes: 9 additions & 0 deletions shell/platform/darwin/ios/ios_surface_gl.mm
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/darwin/ios/ios_surface_software.h
Expand Up @@ -45,6 +45,9 @@ class IOSSurfaceSoftware final : public IOSSurface,
// |GPUSurfaceSoftwareDelegate|
flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override;

// |flutter::ExternalViewEmbedder|
void CancelFrame() override;

// |flutter::ExternalViewEmbedder|
bool HasPendingViewOperations() override;

Expand Down
6 changes: 6 additions & 0 deletions shell/platform/darwin/ios/ios_surface_software.mm
Expand Up @@ -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);
Expand Down

0 comments on commit 791143f

Please sign in to comment.