diff --git a/flow/embedded_views.cc b/flow/embedded_views.cc index 1907762ca0584..ddb85acd2b0c7 100644 --- a/flow/embedded_views.cc +++ b/flow/embedded_views.cc @@ -43,6 +43,7 @@ bool DisplayListEmbedderViewSlice::recording_ended() { } void ExternalViewEmbedder::SubmitFlutterView( + int64_t flutter_view_id, GrDirectContext* context, const std::shared_ptr& aiks_context, std::unique_ptr frame) { diff --git a/flow/embedded_views.h b/flow/embedded_views.h index 745c91d9dd2f5..89a2aa7e5eddf 100644 --- a/flow/embedded_views.h +++ b/flow/embedded_views.h @@ -435,16 +435,19 @@ class ExternalViewEmbedder { virtual DlCanvas* CompositeEmbeddedView(int64_t platform_view_id) = 0; // Prepare for a view to be drawn. - virtual void PrepareFlutterView(int64_t flutter_view_id, - SkISize frame_size, + virtual void PrepareFlutterView(SkISize frame_size, double device_pixel_ratio) = 0; + // Submits the content stored since |PrepareFlutterView| to the specified + // Flutter view. + // // Implementers must submit the frame by calling frame.Submit(). // // This method can mutate the root Skia canvas before submitting the frame. // // It can also allocate frames for overlay surfaces to compose hybrid views. virtual void SubmitFlutterView( + int64_t flutter_view_id, GrDirectContext* context, const std::shared_ptr& aiks_context, std::unique_ptr frame); diff --git a/flow/testing/mock_embedder.cc b/flow/testing/mock_embedder.cc index 3cec9fecdbf34..2e74d2691602d 100644 --- a/flow/testing/mock_embedder.cc +++ b/flow/testing/mock_embedder.cc @@ -29,8 +29,7 @@ void MockViewEmbedder::BeginFrame( const fml::RefPtr& raster_thread_merger) {} // |ExternalViewEmbedder| -void MockViewEmbedder::PrepareFlutterView(int64_t flutter_view_id, - SkISize frame_size, +void MockViewEmbedder::PrepareFlutterView(SkISize frame_size, double device_pixel_ratio) {} // |ExternalViewEmbedder| diff --git a/flow/testing/mock_embedder.h b/flow/testing/mock_embedder.h index b9038d8af6ffa..1812083fd8960 100644 --- a/flow/testing/mock_embedder.h +++ b/flow/testing/mock_embedder.h @@ -30,8 +30,7 @@ class MockViewEmbedder : public ExternalViewEmbedder { raster_thread_merger) override; // |ExternalViewEmbedder| - void PrepareFlutterView(int64_t flutter_view_id, - SkISize frame_size, + void PrepareFlutterView(SkISize frame_size, double device_pixel_ratio) override; // |ExternalViewEmbedder| diff --git a/shell/common/rasterizer.cc b/shell/common/rasterizer.cc index ed7bee5a9376c..060d928f10bca 100644 --- a/shell/common/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -663,8 +663,8 @@ DrawSurfaceStatus Rasterizer::DrawToSurfaceUnsafe( DlCanvas* embedder_root_canvas = nullptr; if (external_view_embedder_) { - external_view_embedder_->PrepareFlutterView( - view_id, layer_tree.frame_size(), device_pixel_ratio); + external_view_embedder_->PrepareFlutterView(layer_tree.frame_size(), + device_pixel_ratio); // TODO(dkwingsmt): Add view ID here. embedder_root_canvas = external_view_embedder_->GetRootCanvas(); } @@ -752,7 +752,8 @@ DrawSurfaceStatus Rasterizer::DrawToSurfaceUnsafe( (!raster_thread_merger_ || raster_thread_merger_->IsMerged())) { FML_DCHECK(!frame->IsSubmitted()); external_view_embedder_->SubmitFlutterView( - surface_->GetContext(), surface_->GetAiksContext(), std::move(frame)); + view_id, surface_->GetContext(), surface_->GetAiksContext(), + std::move(frame)); } else { frame->Submit(); } diff --git a/shell/common/rasterizer_unittests.cc b/shell/common/rasterizer_unittests.cc index 7265bb887578f..a43d92551971a 100644 --- a/shell/common/rasterizer_unittests.cc +++ b/shell/common/rasterizer_unittests.cc @@ -97,9 +97,7 @@ class MockExternalViewEmbedder : public ExternalViewEmbedder { (override)); MOCK_METHOD(void, PrepareFlutterView, - (int64_t flutter_view_id, - SkISize frame_size, - double device_pixel_ratio), + (SkISize frame_size, double device_pixel_ratio), (override)); MOCK_METHOD(void, PrerollCompositeEmbeddedView, @@ -113,7 +111,8 @@ class MockExternalViewEmbedder : public ExternalViewEmbedder { MOCK_METHOD(DlCanvas*, CompositeEmbeddedView, (int64_t view_id), (override)); MOCK_METHOD(void, SubmitFlutterView, - (GrDirectContext * context, + (int64_t flutter_view_id, + GrDirectContext* context, const std::shared_ptr& aiks_context, std::unique_ptr frame), (override)); @@ -223,12 +222,13 @@ TEST(RasterizerTest, /*raster_thread_merger=*/ fml::RefPtr(nullptr))) .Times(1); + EXPECT_CALL(*external_view_embedder, PrepareFlutterView( + /*frame_size=*/SkISize(), + /*device_pixel_ratio=*/2.0)) + .Times(1); EXPECT_CALL(*external_view_embedder, - PrepareFlutterView(/*flutter_view_id=*/kImplicitViewId, - /*frame_size=*/SkISize(), - /*device_pixel_ratio=*/2.0)) + SubmitFlutterView(/*flutter_view_id=*/kImplicitViewId, _, _, _)) .Times(1); - EXPECT_CALL(*external_view_embedder, SubmitFlutterView).Times(1); EXPECT_CALL( *external_view_embedder, EndFrame(/*should_resubmit_frame=*/false, @@ -299,12 +299,13 @@ TEST( EXPECT_CALL(*external_view_embedder, BeginFrame(/*context=*/nullptr, /*raster_thread_merger=*/_)) .Times(1); - EXPECT_CALL(*external_view_embedder, - PrepareFlutterView(/*flutter_view_id=*/kImplicitViewId, - /*frame_size=*/SkISize(), - /*device_pixel_ratio=*/2.0)) + EXPECT_CALL(*external_view_embedder, PrepareFlutterView( + /*frame_size=*/SkISize(), + /*device_pixel_ratio=*/2.0)) .Times(1); - EXPECT_CALL(*external_view_embedder, SubmitFlutterView).Times(0); + EXPECT_CALL(*external_view_embedder, + SubmitFlutterView(/*flutter_view_id=*/kImplicitViewId, _, _, _)) + .Times(0); EXPECT_CALL(*external_view_embedder, EndFrame(/*should_resubmit_frame=*/false, /*raster_thread_merger=*/_)) .Times(1); @@ -378,12 +379,13 @@ TEST( EXPECT_CALL(*external_view_embedder, BeginFrame(/*context=*/nullptr, /*raster_thread_merger=*/_)) .Times(1); + EXPECT_CALL(*external_view_embedder, PrepareFlutterView( + /*frame_size=*/SkISize(), + /*device_pixel_ratio=*/2.0)) + .Times(1); EXPECT_CALL(*external_view_embedder, - PrepareFlutterView(/*flutter_view_id=*/kImplicitViewId, - /*frame_size=*/SkISize(), - /*device_pixel_ratio=*/2.0)) + SubmitFlutterView(/*flutter_view_id=*/kImplicitViewId, _, _, _)) .Times(1); - EXPECT_CALL(*external_view_embedder, SubmitFlutterView).Times(1); EXPECT_CALL(*external_view_embedder, EndFrame(/*should_resubmit_frame=*/false, /*raster_thread_merger=*/_)) .Times(1); @@ -460,12 +462,13 @@ TEST(RasterizerTest, EXPECT_CALL(*external_view_embedder, BeginFrame(/*context=*/nullptr, /*raster_thread_merger=*/_)) .Times(2); + EXPECT_CALL(*external_view_embedder, PrepareFlutterView( + /*frame_size=*/SkISize(), + /*device_pixel_ratio=*/2.0)) + .Times(2); EXPECT_CALL(*external_view_embedder, - PrepareFlutterView(/*flutter_view_id=*/kImplicitViewId, - /*frame_size=*/SkISize(), - /*device_pixel_ratio=*/2.0)) + SubmitFlutterView(/*flutter_view_id=*/kImplicitViewId, _, _, _)) .Times(2); - EXPECT_CALL(*external_view_embedder, SubmitFlutterView).Times(2); EXPECT_CALL(*external_view_embedder, EndFrame(/*should_resubmit_frame=*/false, /*raster_thread_merger=*/_)) .Times(2); @@ -575,10 +578,9 @@ TEST(RasterizerTest, externalViewEmbedderDoesntEndFrameWhenNotUsedThisFrame) { EXPECT_CALL(*external_view_embedder, BeginFrame(/*context=*/nullptr, /*raster_thread_merger=*/_)) .Times(0); - EXPECT_CALL(*external_view_embedder, - PrepareFlutterView(/*flutter_view_id=*/kImplicitViewId, - /*frame_size=*/SkISize(), - /*device_pixel_ratio=*/2.0)) + EXPECT_CALL(*external_view_embedder, PrepareFlutterView( + /*frame_size=*/SkISize(), + /*device_pixel_ratio=*/2.0)) .Times(0); EXPECT_CALL( *external_view_embedder, @@ -696,17 +698,20 @@ TEST(RasterizerTest, drawMultipleViewsWithExternalViewEmbedder) { EXPECT_CALL(*external_view_embedder, BeginFrame(/*context=*/nullptr, /*raster_thread_merger=*/_)) .Times(1); - EXPECT_CALL( - *external_view_embedder, - PrepareFlutterView(/*flutter_view_id=*/0, /*frame_size=*/SkISize(), - /*device_pixel_ratio=*/1.5)) + EXPECT_CALL(*external_view_embedder, + PrepareFlutterView(/*frame_size=*/SkISize(), + /*device_pixel_ratio=*/1.5)) .Times(1); - EXPECT_CALL( - *external_view_embedder, - PrepareFlutterView(/*flutter_view_id=*/1, /*frame_size=*/SkISize(), - /*device_pixel_ratio=*/2.0)) + EXPECT_CALL(*external_view_embedder, + SubmitFlutterView(/*flutter_view_id=*/0, _, _, _)) + .Times(1); + EXPECT_CALL(*external_view_embedder, + PrepareFlutterView(/*frame_size=*/SkISize(), + /*device_pixel_ratio=*/2.0)) + .Times(1); + EXPECT_CALL(*external_view_embedder, + SubmitFlutterView(/*flutter_view_id=*/1, _, _, _)) .Times(1); - EXPECT_CALL(*external_view_embedder, SubmitFlutterView).Times(2); EXPECT_CALL(*external_view_embedder, EndFrame(/*should_resubmit_frame=*/false, /*raster_thread_merger=*/_)) .Times(1); diff --git a/shell/common/shell_test_external_view_embedder.cc b/shell/common/shell_test_external_view_embedder.cc index d03a2a57cde89..dd351b5dfc605 100644 --- a/shell/common/shell_test_external_view_embedder.cc +++ b/shell/common/shell_test_external_view_embedder.cc @@ -46,7 +46,6 @@ void ShellTestExternalViewEmbedder::BeginFrame( // |ExternalViewEmbedder| void ShellTestExternalViewEmbedder::PrepareFlutterView( - int64_t flutter_view_id, SkISize frame_size, double device_pixel_ratio) { visited_platform_views_.clear(); @@ -94,6 +93,7 @@ DlCanvas* ShellTestExternalViewEmbedder::CompositeEmbeddedView( // |ExternalViewEmbedder| void ShellTestExternalViewEmbedder::SubmitFlutterView( + int64_t flutter_view_id, GrDirectContext* context, const std::shared_ptr& aiks_context, std::unique_ptr frame) { diff --git a/shell/common/shell_test_external_view_embedder.h b/shell/common/shell_test_external_view_embedder.h index d9af75d575b40..b000c239435fb 100644 --- a/shell/common/shell_test_external_view_embedder.h +++ b/shell/common/shell_test_external_view_embedder.h @@ -51,8 +51,7 @@ class ShellTestExternalViewEmbedder final : public ExternalViewEmbedder { raster_thread_merger) override; // |ExternalViewEmbedder| - void PrepareFlutterView(int64_t flutter_view_id, - SkISize frame_size, + void PrepareFlutterView(SkISize frame_size, double device_pixel_ratio) override; // |ExternalViewEmbedder| @@ -78,6 +77,7 @@ class ShellTestExternalViewEmbedder final : public ExternalViewEmbedder { // |ExternalViewEmbedder| void SubmitFlutterView( + int64_t flutter_view_id, GrDirectContext* context, const std::shared_ptr& aiks_context, std::unique_ptr frame) override; diff --git a/shell/platform/android/external_view_embedder/external_view_embedder.cc b/shell/platform/android/external_view_embedder/external_view_embedder.cc index 2ec5a9ac198a7..f6ce9eb161273 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder.cc +++ b/shell/platform/android/external_view_embedder/external_view_embedder.cc @@ -64,10 +64,14 @@ SkRect AndroidExternalViewEmbedder::GetViewRect(int64_t view_id) const { // |ExternalViewEmbedder| void AndroidExternalViewEmbedder::SubmitFlutterView( + int64_t flutter_view_id, GrDirectContext* context, const std::shared_ptr& aiks_context, std::unique_ptr frame) { TRACE_EVENT0("flutter", "AndroidExternalViewEmbedder::SubmitFlutterView"); + // TODO(dkwingsmt): This class only supports rendering into the implicit view. + // Properly support multi-view in the future. + FML_DCHECK(flutter_view_id == kFlutterImplicitViewId); if (!FrameHasPlatformLayers()) { frame->Submit(); @@ -268,12 +272,8 @@ void AndroidExternalViewEmbedder::BeginFrame( // |ExternalViewEmbedder| void AndroidExternalViewEmbedder::PrepareFlutterView( - int64_t flutter_view_id, SkISize frame_size, double device_pixel_ratio) { - // TODO(dkwingsmt): This class only supports rendering into the implicit view. - // Properly support multi-view in the future. - FML_DCHECK(flutter_view_id == kFlutterImplicitViewId); Reset(); // The surface size changed. Therefore, destroy existing surfaces as diff --git a/shell/platform/android/external_view_embedder/external_view_embedder.h b/shell/platform/android/external_view_embedder/external_view_embedder.h index d601a52fcaccd..ab00870276ffc 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder.h +++ b/shell/platform/android/external_view_embedder/external_view_embedder.h @@ -44,6 +44,7 @@ class AndroidExternalViewEmbedder final : public ExternalViewEmbedder { // |ExternalViewEmbedder| void SubmitFlutterView( + int64_t flutter_view_id, GrDirectContext* context, const std::shared_ptr& aiks_context, std::unique_ptr frame) override; @@ -62,8 +63,7 @@ class AndroidExternalViewEmbedder final : public ExternalViewEmbedder { raster_thread_merger) override; // |ExternalViewEmbedder| - void PrepareFlutterView(int64_t flutter_view_id, - SkISize frame_size, + void PrepareFlutterView(SkISize frame_size, double device_pixel_ratio) override; // |ExternalViewEmbedder| diff --git a/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc b/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc index 0cb9f7ac11824..57eec1e60d2eb 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc +++ b/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc @@ -147,7 +147,7 @@ TEST(AndroidExternalViewEmbedder, RasterizerRunsOnPlatformThread) { EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()); embedder->BeginFrame(nullptr, raster_thread_merger); - embedder->PrepareFlutterView(kImplicitViewId, SkISize::Make(10, 20), 1.0); + embedder->PrepareFlutterView(SkISize::Make(10, 20), 1.0); // Push a platform view. embedder->PrerollCompositeEmbeddedView( @@ -201,7 +201,7 @@ TEST(AndroidExternalViewEmbedder, PlatformViewRect) { EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()); embedder->BeginFrame(nullptr, raster_thread_merger); - embedder->PrepareFlutterView(kImplicitViewId, SkISize::Make(100, 100), 1.5); + embedder->PrepareFlutterView(SkISize::Make(100, 100), 1.5); MutatorsStack stack; SkMatrix matrix; @@ -229,7 +229,7 @@ TEST(AndroidExternalViewEmbedder, PlatformViewRectChangedParams) { EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()); embedder->BeginFrame(nullptr, raster_thread_merger); - embedder->PrepareFlutterView(kImplicitViewId, SkISize::Make(100, 100), 1.5); + embedder->PrepareFlutterView(SkISize::Make(100, 100), 1.5); auto view_id = 0; @@ -316,7 +316,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFlutterView) { }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFlutterView(gr_context.get(), nullptr, + embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr, std::move(surface_frame)); // Submits frame if no Android view in the current frame. EXPECT_TRUE(did_submit_frame); @@ -332,7 +332,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFlutterView) { { EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()); embedder->BeginFrame(nullptr, raster_thread_merger); - embedder->PrepareFlutterView(kImplicitViewId, frame_size, 1.5); + embedder->PrepareFlutterView(frame_size, 1.5); // Add an Android view. MutatorsStack stack1; @@ -386,7 +386,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFlutterView) { }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFlutterView(gr_context.get(), nullptr, + embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr, std::move(surface_frame)); // Doesn't submit frame if there aren't Android views in the previous frame. EXPECT_FALSE(did_submit_frame); @@ -402,7 +402,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFlutterView) { { EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()); embedder->BeginFrame(nullptr, raster_thread_merger); - embedder->PrepareFlutterView(kImplicitViewId, frame_size, 1.5); + embedder->PrepareFlutterView(frame_size, 1.5); // Add an Android view. MutatorsStack stack1; @@ -453,7 +453,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFlutterView) { return true; }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFlutterView(gr_context.get(), nullptr, + embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr, std::move(surface_frame)); // Submits frame if there are Android views in the previous frame. EXPECT_TRUE(did_submit_frame); @@ -508,7 +508,7 @@ TEST(AndroidExternalViewEmbedder, OverlayCoverTwoPlatformViews) { EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()); embedder->BeginFrame(nullptr, raster_thread_merger); - embedder->PrepareFlutterView(kImplicitViewId, frame_size, 1.5); + embedder->PrepareFlutterView(frame_size, 1.5); { // Add first Android view. @@ -562,7 +562,7 @@ TEST(AndroidExternalViewEmbedder, OverlayCoverTwoPlatformViews) { }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFlutterView(gr_context.get(), nullptr, + embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr, std::move(surface_frame)); EXPECT_CALL(*jni_mock, FlutterViewEndFrame()); @@ -608,7 +608,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFrameOverlayComposition) { EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()); embedder->BeginFrame(nullptr, raster_thread_merger); - embedder->PrepareFlutterView(kImplicitViewId, frame_size, 1.5); + embedder->PrepareFlutterView(frame_size, 1.5); { // Add first Android view. @@ -667,7 +667,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFrameOverlayComposition) { }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFlutterView(gr_context.get(), nullptr, + embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr, std::move(surface_frame)); EXPECT_CALL(*jni_mock, FlutterViewEndFrame()); @@ -713,7 +713,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFramePlatformViewWithoutAnyOverlay) { EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()); embedder->BeginFrame(nullptr, raster_thread_merger); - embedder->PrepareFlutterView(kImplicitViewId, frame_size, 1.5); + embedder->PrepareFlutterView(frame_size, 1.5); { // Add Android view. @@ -737,7 +737,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFramePlatformViewWithoutAnyOverlay) { }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFlutterView(gr_context.get(), nullptr, + embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr, std::move(surface_frame)); EXPECT_CALL(*jni_mock, FlutterViewEndFrame()); @@ -758,7 +758,7 @@ TEST(AndroidExternalViewEmbedder, DoesNotCallJNIPlatformThreadOnlyMethods) { EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()).Times(0); embedder->BeginFrame(nullptr, raster_thread_merger); - embedder->PrepareFlutterView(kImplicitViewId, SkISize::Make(10, 20), 1.0); + embedder->PrepareFlutterView(SkISize::Make(10, 20), 1.0); EXPECT_CALL(*jni_mock, FlutterViewEndFrame()).Times(0); embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger); @@ -807,7 +807,7 @@ TEST(AndroidExternalViewEmbedder, DestroyOverlayLayersOnSizeChange) { { EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()); embedder->BeginFrame(nullptr, raster_thread_merger); - embedder->PrepareFlutterView(kImplicitViewId, frame_size, 1.5); + embedder->PrepareFlutterView(frame_size, 1.5); // Add an Android view. MutatorsStack stack1; @@ -840,7 +840,7 @@ TEST(AndroidExternalViewEmbedder, DestroyOverlayLayersOnSizeChange) { return true; }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFlutterView(gr_context.get(), nullptr, + embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr, std::move(surface_frame)); EXPECT_CALL(*jni_mock, FlutterViewEndFrame()); @@ -851,7 +851,7 @@ TEST(AndroidExternalViewEmbedder, DestroyOverlayLayersOnSizeChange) { EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()); // Change the frame size. embedder->BeginFrame(nullptr, raster_thread_merger); - embedder->PrepareFlutterView(kImplicitViewId, SkISize::Make(30, 40), 1.0); + embedder->PrepareFlutterView(SkISize::Make(30, 40), 1.0); } TEST(AndroidExternalViewEmbedder, DoesNotDestroyOverlayLayersOnSizeChange) { @@ -897,7 +897,7 @@ TEST(AndroidExternalViewEmbedder, DoesNotDestroyOverlayLayersOnSizeChange) { GetThreadMergerFromPlatformThread(&rasterizer_thread); EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()); embedder->BeginFrame(nullptr, raster_thread_merger); - embedder->PrepareFlutterView(kImplicitViewId, frame_size, 1.5); + embedder->PrepareFlutterView(frame_size, 1.5); // Add an Android view. MutatorsStack stack1; @@ -929,7 +929,7 @@ TEST(AndroidExternalViewEmbedder, DoesNotDestroyOverlayLayersOnSizeChange) { return true; }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFlutterView(gr_context.get(), nullptr, + embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr, std::move(surface_frame)); EXPECT_CALL(*jni_mock, FlutterViewEndFrame()); @@ -942,7 +942,7 @@ TEST(AndroidExternalViewEmbedder, DoesNotDestroyOverlayLayersOnSizeChange) { fml::Thread platform_thread("platform"); embedder->BeginFrame(nullptr, GetThreadMergerFromRasterThread(&platform_thread)); - embedder->PrepareFlutterView(kImplicitViewId, SkISize::Make(30, 40), 1.0); + embedder->PrepareFlutterView(SkISize::Make(30, 40), 1.0); } TEST(AndroidExternalViewEmbedder, SupportsDynamicThreadMerging) { @@ -969,7 +969,7 @@ TEST(AndroidExternalViewEmbedder, DisableThreadMerger) { EXPECT_CALL(*jni_mock, FlutterViewBeginFrame()).Times(0); embedder->BeginFrame(nullptr, raster_thread_merger); - embedder->PrepareFlutterView(kImplicitViewId, SkISize::Make(10, 20), 1.0); + embedder->PrepareFlutterView(SkISize::Make(10, 20), 1.0); // Push a platform view. embedder->PrerollCompositeEmbeddedView( 0, std::make_unique()); @@ -1019,7 +1019,7 @@ TEST(AndroidExternalViewEmbedder, Teardown) { GetThreadMergerFromPlatformThread(&rasterizer_thread); embedder->BeginFrame(nullptr, raster_thread_merger); - embedder->PrepareFlutterView(kImplicitViewId, frame_size, 1.5); + embedder->PrepareFlutterView(frame_size, 1.5); // Add an Android view. MutatorsStack stack; @@ -1043,7 +1043,7 @@ TEST(AndroidExternalViewEmbedder, Teardown) { SkSurfaces::Null(1000, 1000), framebuffer_info, [](const SurfaceFrame& surface_frame, DlCanvas* canvas) { return true; }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFlutterView(gr_context.get(), nullptr, + embedder->SubmitFlutterView(kImplicitViewId, gr_context.get(), nullptr, std::move(surface_frame)); embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger); diff --git a/shell/platform/darwin/ios/ios_external_view_embedder.h b/shell/platform/darwin/ios/ios_external_view_embedder.h index 8a47eaea31639..953966378b15a 100644 --- a/shell/platform/darwin/ios/ios_external_view_embedder.h +++ b/shell/platform/darwin/ios/ios_external_view_embedder.h @@ -36,8 +36,7 @@ class IOSExternalViewEmbedder : public ExternalViewEmbedder { raster_thread_merger) override; // |ExternalViewEmbedder| - void PrepareFlutterView(int64_t flutter_view_id, - SkISize frame_size, + void PrepareFlutterView(SkISize frame_size, double device_pixel_ratio) override; // |ExternalViewEmbedder| @@ -55,6 +54,7 @@ class IOSExternalViewEmbedder : public ExternalViewEmbedder { // |ExternalViewEmbedder| void SubmitFlutterView( + int64_t flutter_view_id, GrDirectContext* context, const std::shared_ptr& aiks_context, std::unique_ptr frame) override; diff --git a/shell/platform/darwin/ios/ios_external_view_embedder.mm b/shell/platform/darwin/ios/ios_external_view_embedder.mm index 2e13055c2de01..9af5904a4e092 100644 --- a/shell/platform/darwin/ios/ios_external_view_embedder.mm +++ b/shell/platform/darwin/ios/ios_external_view_embedder.mm @@ -37,12 +37,7 @@ const fml::RefPtr& raster_thread_merger) {} // |ExternalViewEmbedder| -void IOSExternalViewEmbedder::PrepareFlutterView(int64_t flutter_view_id, - SkISize frame_size, - double device_pixel_ratio) { - // TODO(dkwingsmt): This class only supports rendering into the implicit view. - // Properly support multi-view in the future. - FML_DCHECK(flutter_view_id == kFlutterImplicitViewId); +void IOSExternalViewEmbedder::PrepareFlutterView(SkISize frame_size, double device_pixel_ratio) { FML_CHECK(platform_views_controller_); platform_views_controller_->BeginFrame(frame_size); } @@ -74,10 +69,14 @@ // |ExternalViewEmbedder| void IOSExternalViewEmbedder::SubmitFlutterView( + int64_t flutter_view_id, GrDirectContext* context, const std::shared_ptr& aiks_context, std::unique_ptr frame) { TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::SubmitFlutterView"); + // TODO(dkwingsmt): This class only supports rendering into the implicit view. + // Properly support multi-view in the future. + FML_DCHECK(flutter_view_id == kFlutterImplicitViewId); FML_CHECK(platform_views_controller_); platform_views_controller_->SubmitFrame(context, ios_context_, std::move(frame)); TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::DidSubmitFrame"); diff --git a/shell/platform/embedder/embedder_external_view_embedder.cc b/shell/platform/embedder/embedder_external_view_embedder.cc index fe699575e77ea..1e9ddf90c4390 100644 --- a/shell/platform/embedder/embedder_external_view_embedder.cc +++ b/shell/platform/embedder/embedder_external_view_embedder.cc @@ -59,13 +59,8 @@ void EmbedderExternalViewEmbedder::BeginFrame( // |ExternalViewEmbedder| void EmbedderExternalViewEmbedder::PrepareFlutterView( - int64_t flutter_view_id, SkISize frame_size, double device_pixel_ratio) { - // TODO(dkwingsmt): This class only supports rendering into the implicit - // view. Properly support multi-view in the future. - // https://github.com/flutter/flutter/issues/135530 item 4 - FML_DCHECK(flutter_view_id == kFlutterImplicitViewId); Reset(); pending_frame_size_ = frame_size; @@ -417,6 +412,7 @@ class LayerBuilder { }; // namespace void EmbedderExternalViewEmbedder::SubmitFlutterView( + int64_t flutter_view_id, GrDirectContext* context, const std::shared_ptr& aiks_context, std::unique_ptr frame) { @@ -494,10 +490,7 @@ void EmbedderExternalViewEmbedder::SubmitFlutterView( builder.PushLayers(presented_layers); - // TODO(loic-sharma): Currently only supports a single view. - // See https://github.com/flutter/flutter/issues/135530. - presented_layers.InvokePresentCallback(kFlutterImplicitViewId, - present_callback_); + presented_layers.InvokePresentCallback(flutter_view_id, present_callback_); } // See why this is necessary in the comment where this collection in diff --git a/shell/platform/embedder/embedder_external_view_embedder.h b/shell/platform/embedder/embedder_external_view_embedder.h index d850fa85e8443..ef51cc1b245ab 100644 --- a/shell/platform/embedder/embedder_external_view_embedder.h +++ b/shell/platform/embedder/embedder_external_view_embedder.h @@ -87,8 +87,7 @@ class EmbedderExternalViewEmbedder final : public ExternalViewEmbedder { raster_thread_merger) override; // |ExternalViewEmbedder| - void PrepareFlutterView(int64_t flutter_view_id, - SkISize frame_size, + void PrepareFlutterView(SkISize frame_size, double device_pixel_ratio) override; // |ExternalViewEmbedder| @@ -101,6 +100,7 @@ class EmbedderExternalViewEmbedder final : public ExternalViewEmbedder { // |ExternalViewEmbedder| void SubmitFlutterView( + int64_t flutter_view_id, GrDirectContext* context, const std::shared_ptr& aiks_context, std::unique_ptr frame) override; diff --git a/shell/platform/fuchsia/flutter/external_view_embedder.cc b/shell/platform/fuchsia/flutter/external_view_embedder.cc index af50b423f9d58..4f630c75e2c79 100644 --- a/shell/platform/fuchsia/flutter/external_view_embedder.cc +++ b/shell/platform/fuchsia/flutter/external_view_embedder.cc @@ -114,12 +114,8 @@ void ExternalViewEmbedder::BeginFrame( const fml::RefPtr& raster_thread_merger) {} // |ExternalViewEmbedder| -void ExternalViewEmbedder::PrepareFlutterView(int64_t flutter_view_id, - SkISize frame_size, +void ExternalViewEmbedder::PrepareFlutterView(SkISize frame_size, double device_pixel_ratio) { - // Fuchsia only supports operating the implicit view for now. - FML_DCHECK(flutter_view_id == flutter::kFlutterImplicitViewId); - // Reset for new view. Reset(); frame_size_ = frame_size; @@ -139,9 +135,13 @@ void ExternalViewEmbedder::EndFrame( } void ExternalViewEmbedder::SubmitFlutterView( + int64_t flutter_view_id, GrDirectContext* context, const std::shared_ptr& aiks_context, std::unique_ptr frame) { + // Fuchsia only supports operating the implicit view for now. + FML_DCHECK(flutter_view_id == flutter::kFlutterImplicitViewId); + TRACE_EVENT0("flutter", "ExternalViewEmbedder::SubmitFlutterView"); std::vector> frame_surfaces; std::unordered_map frame_surface_indices; diff --git a/shell/platform/fuchsia/flutter/external_view_embedder.h b/shell/platform/fuchsia/flutter/external_view_embedder.h index 382cadce9c0a2..5c00272499063 100644 --- a/shell/platform/fuchsia/flutter/external_view_embedder.h +++ b/shell/platform/fuchsia/flutter/external_view_embedder.h @@ -77,8 +77,7 @@ class ExternalViewEmbedder final : public flutter::ExternalViewEmbedder { raster_thread_merger) override; // |ExternalViewEmbedder| - void PrepareFlutterView(int64_t flutter_view_id, - SkISize frame_size, + void PrepareFlutterView(SkISize frame_size, double device_pixel_ratio) override; // |ExternalViewEmbedder| @@ -88,6 +87,7 @@ class ExternalViewEmbedder final : public flutter::ExternalViewEmbedder { // |ExternalViewEmbedder| void SubmitFlutterView( + int64_t flutter_view_id, GrDirectContext* context, const std::shared_ptr& aiks_context, std::unique_ptr frame) override; diff --git a/shell/platform/fuchsia/flutter/tests/external_view_embedder_unittests.cc b/shell/platform/fuchsia/flutter/tests/external_view_embedder_unittests.cc index 93b20a5edc6c8..bd34c85508124 100644 --- a/shell/platform/fuchsia/flutter/tests/external_view_embedder_unittests.cc +++ b/shell/platform/fuchsia/flutter/tests/external_view_embedder_unittests.cc @@ -328,8 +328,7 @@ void DrawSimpleFrame(ExternalViewEmbedder& external_view_embedder, float frame_dpr, std::function draw_callback) { external_view_embedder.BeginFrame(nullptr, nullptr); - external_view_embedder.PrepareFlutterView(kImplicitViewId, frame_size, - frame_dpr); + external_view_embedder.PrepareFlutterView(frame_size, frame_dpr); { flutter::DlCanvas* root_canvas = external_view_embedder.GetRootCanvas(); external_view_embedder.PostPrerollAction(nullptr); @@ -339,7 +338,7 @@ void DrawSimpleFrame(ExternalViewEmbedder& external_view_embedder, flutter::SurfaceFrame::FramebufferInfo framebuffer_info; framebuffer_info.supports_readback = true; external_view_embedder.SubmitFlutterView( - nullptr, nullptr, + kImplicitViewId, nullptr, nullptr, std::make_unique( nullptr, std::move(framebuffer_info), [](const flutter::SurfaceFrame& surface_frame, @@ -356,8 +355,7 @@ void DrawFrameWithView( std::function background_draw_callback, std::function overlay_draw_callback) { external_view_embedder.BeginFrame(nullptr, nullptr); - external_view_embedder.PrepareFlutterView(kImplicitViewId, frame_size, - frame_dpr); + external_view_embedder.PrepareFlutterView(frame_size, frame_dpr); { flutter::DlCanvas* root_canvas = external_view_embedder.GetRootCanvas(); external_view_embedder.PrerollCompositeEmbeddedView( @@ -372,7 +370,7 @@ void DrawFrameWithView( flutter::SurfaceFrame::FramebufferInfo framebuffer_info; framebuffer_info.supports_readback = true; external_view_embedder.SubmitFlutterView( - nullptr, nullptr, + kImplicitViewId, nullptr, nullptr, std::make_unique( nullptr, std::move(framebuffer_info), [](const flutter::SurfaceFrame& surface_frame, diff --git a/shell/platform/fuchsia/flutter/tests/platform_view_unittest.cc b/shell/platform/fuchsia/flutter/tests/platform_view_unittest.cc index a387eb06d44bc..b61d87b22cfa2 100644 --- a/shell/platform/fuchsia/flutter/tests/platform_view_unittest.cc +++ b/shell/platform/fuchsia/flutter/tests/platform_view_unittest.cc @@ -49,11 +49,11 @@ class MockExternalViewEmbedder : public flutter::ExternalViewEmbedder { const fml::RefPtr& raster_thread_merger) override {} - void PrepareFlutterView(int64_t flutter_view_id, - SkISize frame_size, + void PrepareFlutterView(SkISize frame_size, double device_pixel_ratio) override {} void SubmitFlutterView( + int64_t flutter_view_id, GrDirectContext* context, const std::shared_ptr& aiks_context, std::unique_ptr frame) override {} diff --git a/shell/testing/tester_main.cc b/shell/testing/tester_main.cc index d1a206f72e6b1..dac86e7c8d33e 100644 --- a/shell/testing/tester_main.cc +++ b/shell/testing/tester_main.cc @@ -159,8 +159,7 @@ class TesterExternalViewEmbedder : public ExternalViewEmbedder { raster_thread_merger) override {} // |ExternalViewEmbedder| - void PrepareFlutterView(int64_t flutter_view_id, - SkISize frame_size, + void PrepareFlutterView(SkISize frame_size, double device_pixel_ratio) override {} // |ExternalViewEmbedder|