diff --git a/flow/embedded_views.h b/flow/embedded_views.h index 337ebb4a567a9..37781ca0902e1 100644 --- a/flow/embedded_views.h +++ b/flow/embedded_views.h @@ -190,8 +190,9 @@ class ExternalViewEmbedder { virtual std::vector GetCurrentCanvases() = 0; // Must be called on the UI thread. - virtual SkCanvas* CompositeEmbeddedView(int view_id, - const EmbeddedViewParams& params) = 0; + virtual SkCanvas* CompositeEmbeddedView( + int view_id, + std::unique_ptr params) = 0; virtual bool SubmitFrame(GrContext* context); diff --git a/flow/layers/platform_view_layer.cc b/flow/layers/platform_view_layer.cc index c7845a867de61..6205324ab0318 100644 --- a/flow/layers/platform_view_layer.cc +++ b/flow/layers/platform_view_layer.cc @@ -32,15 +32,16 @@ void PlatformViewLayer::Paint(PaintContext& context) const { "does not support embedding"; return; } - EmbeddedViewParams params; + std::unique_ptr params = + std::make_unique(); SkMatrix transform = context.leaf_nodes_canvas->getTotalMatrix(); - params.offsetPixels = + params->offsetPixels = SkPoint::Make(transform.getTranslateX(), transform.getTranslateY()); - params.sizePoints = size_; - params.mutatorsStack = context.mutators_stack; + params->sizePoints = size_; + params->mutatorsStack = context.mutators_stack; SkCanvas* canvas = - context.view_embedder->CompositeEmbeddedView(view_id_, params); + context.view_embedder->CompositeEmbeddedView(view_id_, std::move(params)); context.leaf_nodes_canvas = canvas; } } // namespace flutter diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index 08ace583d48ab..39fb0e0fbb179 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -231,7 +231,6 @@ void FlutterPlatformViewsController::ApplyMutators(const MutatorsStack& mutators_stack, UIView* embedded_view) { FML_DCHECK(CATransform3DEqualToTransform(embedded_view.layer.transform, CATransform3DIdentity)); - UIView* head = embedded_view; head.clipsToBounds = YES; ResetAnchor(head.layer); @@ -275,13 +274,13 @@ void FlutterPlatformViewsController::CompositeWithParams( int view_id, - const flutter::EmbeddedViewParams& params) { - CGRect frame = CGRectMake(0, 0, params.sizePoints.width(), params.sizePoints.height()); + std::unique_ptr params) { + CGRect frame = CGRectMake(0, 0, params->sizePoints.width(), params->sizePoints.height()); UIView* touchInterceptor = touch_interceptors_[view_id].get(); touchInterceptor.layer.transform = CATransform3DIdentity; touchInterceptor.frame = frame; - int currentClippingCount = CountClips(params.mutatorsStack); + int currentClippingCount = CountClips(params->mutatorsStack); int previousClippingCount = clip_count_[view_id]; if (currentClippingCount != previousClippingCount) { clip_count_[view_id] = currentClippingCount; @@ -292,22 +291,22 @@ ReconstructClipViewsChain(currentClippingCount, touchInterceptor, oldPlatformViewRoot); root_views_[view_id] = fml::scoped_nsobject([newPlatformViewRoot retain]); } - ApplyMutators(params.mutatorsStack, touchInterceptor); + ApplyMutators(params->mutatorsStack, touchInterceptor); } SkCanvas* FlutterPlatformViewsController::CompositeEmbeddedView( int view_id, - const flutter::EmbeddedViewParams& params) { + std::unique_ptr params) { // TODO(amirh): assert that this is running on the platform thread once we support the iOS // embedded views thread configuration. // Do nothing if the params didn't change. if (current_composition_params_.count(view_id) == 1 && - current_composition_params_[view_id] == params) { + current_composition_params_[view_id] == *params.get()) { return picture_recorders_[view_id]->getRecordingCanvas(); } - current_composition_params_[view_id] = EmbeddedViewParams(params); - CompositeWithParams(view_id, params); + current_composition_params_[view_id] = EmbeddedViewParams(*params.get()); + CompositeWithParams(view_id, std::move(params)); return picture_recorders_[view_id]->getRecordingCanvas(); } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index 61ecc4637ca34..e4610e0559d60 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -90,7 +90,7 @@ class FlutterPlatformViewsController { std::vector GetCurrentCanvases(); - SkCanvas* CompositeEmbeddedView(int view_id, const flutter::EmbeddedViewParams& params); + SkCanvas* CompositeEmbeddedView(int view_id, std::unique_ptr params); // Discards all platform views instances and auxiliary resources. void Reset(); @@ -184,7 +184,7 @@ class FlutterPlatformViewsController { // // After each clip operation, we update the head to the super view of the current head. void ApplyMutators(const MutatorsStack& mutators_stack, UIView* embedded_view); - void CompositeWithParams(int view_id, const flutter::EmbeddedViewParams& params); + void CompositeWithParams(int view_id, std::unique_ptr params); FML_DISALLOW_COPY_AND_ASSIGN(FlutterPlatformViewsController); }; diff --git a/shell/platform/darwin/ios/ios_surface_gl.h b/shell/platform/darwin/ios/ios_surface_gl.h index 0090634a99033..25c8613e6db6d 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.h +++ b/shell/platform/darwin/ios/ios_surface_gl.h @@ -61,7 +61,8 @@ class IOSSurfaceGL final : public IOSSurface, std::vector GetCurrentCanvases() override; // |flutter::ExternalViewEmbedder| - SkCanvas* CompositeEmbeddedView(int view_id, const flutter::EmbeddedViewParams& params) override; + SkCanvas* CompositeEmbeddedView(int view_id, + std::unique_ptr params) override; // |flutter::ExternalViewEmbedder| bool SubmitFrame(GrContext* context) override; diff --git a/shell/platform/darwin/ios/ios_surface_gl.mm b/shell/platform/darwin/ios/ios_surface_gl.mm index f9279cc5116fe..ee7e27b7fade2 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.mm +++ b/shell/platform/darwin/ios/ios_surface_gl.mm @@ -102,10 +102,10 @@ } SkCanvas* IOSSurfaceGL::CompositeEmbeddedView(int view_id, - const flutter::EmbeddedViewParams& params) { + std::unique_ptr params) { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); - return platform_views_controller->CompositeEmbeddedView(view_id, params); + return platform_views_controller->CompositeEmbeddedView(view_id, std::move(params)); } bool IOSSurfaceGL::SubmitFrame(GrContext* context) { diff --git a/shell/platform/darwin/ios/ios_surface_software.h b/shell/platform/darwin/ios/ios_surface_software.h index bcb5b6210bf6b..af9bb9c6c9c9b 100644 --- a/shell/platform/darwin/ios/ios_surface_software.h +++ b/shell/platform/darwin/ios/ios_surface_software.h @@ -55,7 +55,8 @@ class IOSSurfaceSoftware final : public IOSSurface, std::vector GetCurrentCanvases() override; // |flutter::ExternalViewEmbedder| - SkCanvas* CompositeEmbeddedView(int view_id, const flutter::EmbeddedViewParams& params) override; + SkCanvas* CompositeEmbeddedView(int view_id, + std::unique_ptr params) override; // |flutter::ExternalViewEmbedder| bool SubmitFrame(GrContext* context) override; diff --git a/shell/platform/darwin/ios/ios_surface_software.mm b/shell/platform/darwin/ios/ios_surface_software.mm index 32cb5a2bbeef1..fb2fe0b104bdf 100644 --- a/shell/platform/darwin/ios/ios_surface_software.mm +++ b/shell/platform/darwin/ios/ios_surface_software.mm @@ -153,11 +153,12 @@ return platform_views_controller->GetCurrentCanvases(); } -SkCanvas* IOSSurfaceSoftware::CompositeEmbeddedView(int view_id, - const flutter::EmbeddedViewParams& params) { +SkCanvas* IOSSurfaceSoftware::CompositeEmbeddedView( + int view_id, + std::unique_ptr params) { FlutterPlatformViewsController* platform_views_controller = GetPlatformViewsController(); FML_CHECK(platform_views_controller != nullptr); - return platform_views_controller->CompositeEmbeddedView(view_id, params); + return platform_views_controller->CompositeEmbeddedView(view_id, std::move(params)); } bool IOSSurfaceSoftware::SubmitFrame(GrContext* context) {