diff --git a/shell/platform/fuchsia/flutter/component.cc b/shell/platform/fuchsia/flutter/component.cc index 99b6ee37d506f..12bdf2a6b3682 100644 --- a/shell/platform/fuchsia/flutter/component.cc +++ b/shell/platform/fuchsia/flutter/component.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -578,17 +579,6 @@ void Application::CreateView( return; } - // TODO(MI4-2490): remove once ViewRefControl and ViewRef come as a parameters - // to CreateView - fuchsia::ui::views::ViewRefControl view_ref_control; - fuchsia::ui::views::ViewRef view_ref; - zx_status_t status = zx::eventpair::create( - /*flags*/ 0u, &view_ref_control.reference, &view_ref.reference); - FML_DCHECK(status == ZX_OK); - - status = view_ref.reference.replace(ZX_RIGHTS_BASIC, &view_ref.reference); - FML_DCHECK(status == ZX_OK); - shell_holders_.emplace(std::make_unique( *this, // delegate debug_label_, // thread label @@ -597,8 +587,7 @@ void Application::CreateView( settings_, // settings std::move(isolate_snapshot_), // isolate snapshot scenic::ToViewToken(std::move(view_token)), // view token - std::move(view_ref_control), // view ref control - std::move(view_ref), // view ref + scenic::ViewRefPair::New(), // view ref pair std::move(fdio_ns_), // FDIO namespace std::move(directory_request_) // outgoing request )); diff --git a/shell/platform/fuchsia/flutter/compositor_context.cc b/shell/platform/fuchsia/flutter/compositor_context.cc index e47720998138e..ef389dbceaef5 100644 --- a/shell/platform/fuchsia/flutter/compositor_context.cc +++ b/shell/platform/fuchsia/flutter/compositor_context.cc @@ -63,12 +63,14 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame { CompositorContext::CompositorContext( std::string debug_label, fuchsia::ui::views::ViewToken view_token, + scenic::ViewRefPair view_ref_pair, fidl::InterfaceHandle session, fml::closure session_error_callback, zx_handle_t vsync_event_handle) : debug_label_(std::move(debug_label)), session_connection_(debug_label_, std::move(view_token), + std::move(view_ref_pair), std::move(session), session_error_callback, vsync_event_handle) {} diff --git a/shell/platform/fuchsia/flutter/compositor_context.h b/shell/platform/fuchsia/flutter/compositor_context.h index ce7d16d47c411..46088f8e6fe36 100644 --- a/shell/platform/fuchsia/flutter/compositor_context.h +++ b/shell/platform/fuchsia/flutter/compositor_context.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "flutter/flow/compositor_context.h" #include "flutter/flow/embedded_views.h" @@ -22,6 +23,7 @@ class CompositorContext final : public flutter::CompositorContext { public: CompositorContext(std::string debug_label, fuchsia::ui::views::ViewToken view_token, + scenic::ViewRefPair view_ref_pair, fidl::InterfaceHandle session, fml::closure session_error_callback, zx_handle_t vsync_event_handle); @@ -36,6 +38,7 @@ class CompositorContext final : public flutter::CompositorContext { private: const std::string debug_label_; + scenic::ViewRefPair view_ref_pair_; SessionConnection session_connection_; // |flutter::CompositorContext| diff --git a/shell/platform/fuchsia/flutter/engine.cc b/shell/platform/fuchsia/flutter/engine.cc index 665cd1b74f639..d476070a95b3d 100644 --- a/shell/platform/fuchsia/flutter/engine.cc +++ b/shell/platform/fuchsia/flutter/engine.cc @@ -55,8 +55,7 @@ Engine::Engine(Delegate& delegate, flutter::Settings settings, fml::RefPtr isolate_snapshot, fuchsia::ui::views::ViewToken view_token, - fuchsia::ui::views::ViewRefControl view_ref_control, - fuchsia::ui::views::ViewRef view_ref, + scenic::ViewRefPair view_ref_pair, UniqueFDIONS fdio_ns, fidl::InterfaceRequest directory_request) : delegate_(delegate), @@ -114,12 +113,14 @@ Engine::Engine(Delegate& delegate, }); }; + fuchsia::ui::views::ViewRef view_ref; + view_ref_pair.view_ref.Clone(&view_ref); + // Setup the callback that will instantiate the platform view. flutter::Shell::CreateCallback on_create_platform_view = fml::MakeCopyable( - [debug_label = thread_label_, - view_ref_control = std::move(view_ref_control), - view_ref = std::move(view_ref), runner_services, + [debug_label = thread_label_, view_ref = std::move(view_ref), + runner_services, parent_environment_service_provider = std::move(parent_environment_service_provider), session_listener_request = std::move(session_listener_request), @@ -133,11 +134,10 @@ Engine::Engine(Delegate& delegate, std::move(on_enable_wireframe_callback), vsync_handle = vsync_event_.get()](flutter::Shell& shell) mutable { return std::make_unique( - shell, // delegate - debug_label, // debug label - std::move(view_ref_control), // view control ref - std::move(view_ref), // view ref - shell.GetTaskRunners(), // task runners + shell, // delegate + debug_label, // debug label + std::move(view_ref), // view ref + shell.GetTaskRunners(), // task runners std::move(runner_services), std::move(parent_environment_service_provider), // services std::move(session_listener_request), // session listener @@ -177,11 +177,12 @@ Engine::Engine(Delegate& delegate, // Setup the callback that will instantiate the rasterizer. flutter::Shell::CreateCallback on_create_rasterizer = - fml::MakeCopyable([thread_label = thread_label_, // - view_token = std::move(view_token), // - session = std::move(session), // - on_session_error_callback, // - vsync_event = vsync_event_.get() // + fml::MakeCopyable([thread_label = thread_label_, // + view_token = std::move(view_token), // + view_ref_pair = std::move(view_ref_pair), // + session = std::move(session), // + on_session_error_callback, // + vsync_event = vsync_event_.get() // ](flutter::Shell& shell) mutable { std::unique_ptr compositor_context; { @@ -190,7 +191,8 @@ Engine::Engine(Delegate& delegate, std::make_unique( thread_label, // debug label std::move(view_token), // scenic view we attach our tree to - std::move(session), // scenic session + std::move(view_ref_pair), // scenic view ref/view ref control + std::move(session), // scenic session on_session_error_callback, // session did encounter error vsync_event // vsync event handle ); diff --git a/shell/platform/fuchsia/flutter/engine.h b/shell/platform/fuchsia/flutter/engine.h index 7b233dcfcf4b4..6f045e330aa03 100644 --- a/shell/platform/fuchsia/flutter/engine.h +++ b/shell/platform/fuchsia/flutter/engine.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "flutter/fml/macros.h" @@ -36,8 +37,7 @@ class Engine final { flutter::Settings settings, fml::RefPtr isolate_snapshot, fuchsia::ui::views::ViewToken view_token, - fuchsia::ui::views::ViewRefControl view_ref_control, - fuchsia::ui::views::ViewRef view_ref, + scenic::ViewRefPair view_ref_pair, UniqueFDIONS fdio_ns, fidl::InterfaceRequest directory_request); ~Engine(); diff --git a/shell/platform/fuchsia/flutter/platform_view.cc b/shell/platform/fuchsia/flutter/platform_view.cc index 7c6886e5b6ec3..3449cb416aba9 100644 --- a/shell/platform/fuchsia/flutter/platform_view.cc +++ b/shell/platform/fuchsia/flutter/platform_view.cc @@ -80,7 +80,6 @@ void SetInterfaceErrorHandler(fidl::Binding& binding, std::string name) { PlatformView::PlatformView( flutter::PlatformView::Delegate& delegate, std::string debug_label, - fuchsia::ui::views::ViewRefControl view_ref_control, fuchsia::ui::views::ViewRef view_ref, flutter::TaskRunners task_runners, std::shared_ptr runner_services, @@ -95,7 +94,6 @@ PlatformView::PlatformView( zx_handle_t vsync_event_handle) : flutter::PlatformView(delegate, std::move(task_runners)), debug_label_(std::move(debug_label)), - view_ref_control_(std::move(view_ref_control)), view_ref_(std::move(view_ref)), session_listener_binding_(this, std::move(session_listener_request)), session_listener_error_callback_( diff --git a/shell/platform/fuchsia/flutter/platform_view.h b/shell/platform/fuchsia/flutter/platform_view.h index e02bf8d0c53d3..4e0f434e97cba 100644 --- a/shell/platform/fuchsia/flutter/platform_view.h +++ b/shell/platform/fuchsia/flutter/platform_view.h @@ -42,7 +42,6 @@ class PlatformView final : public flutter::PlatformView, public: PlatformView(flutter::PlatformView::Delegate& delegate, std::string debug_label, - fuchsia::ui::views::ViewRefControl view_ref_control, fuchsia::ui::views::ViewRef view_ref, flutter::TaskRunners task_runners, std::shared_ptr runner_services, @@ -77,7 +76,6 @@ class PlatformView final : public flutter::PlatformView, const std::string debug_label_; // TODO(MI4-2490): remove once ViewRefControl is passed to Scenic and kept // alive there - const fuchsia::ui::views::ViewRefControl view_ref_control_; const fuchsia::ui::views::ViewRef view_ref_; std::unique_ptr accessibility_bridge_; diff --git a/shell/platform/fuchsia/flutter/platform_view_unittest.cc b/shell/platform/fuchsia/flutter/platform_view_unittest.cc index 8524df10f08e2..a66e261f11130 100644 --- a/shell/platform/fuchsia/flutter/platform_view_unittest.cc +++ b/shell/platform/fuchsia/flutter/platform_view_unittest.cc @@ -92,9 +92,6 @@ TEST_F(PlatformViewTests, ChangesAccessibilitySettings) { auto view_ref = fuchsia::ui::views::ViewRef({ .reference = std::move(a), }); - auto view_ref_control = fuchsia::ui::views::ViewRefControl({ - .reference = std::move(b), - }); flutter::TaskRunners task_runners = flutter::TaskRunners("test_runners", nullptr, nullptr, nullptr, nullptr); @@ -104,7 +101,6 @@ TEST_F(PlatformViewTests, ChangesAccessibilitySettings) { auto platform_view = flutter_runner::PlatformView( delegate, // delegate "test_platform_view", // label - std::move(view_ref_control), // view_ref_control std::move(view_ref), // view_ref std::move(task_runners), // task_runners services_provider.service_directory(), // runner_services @@ -143,9 +139,6 @@ TEST_F(PlatformViewTests, EnableWireframeTest) { auto view_ref = fuchsia::ui::views::ViewRef({ .reference = std::move(a), }); - auto view_ref_control = fuchsia::ui::views::ViewRefControl({ - .reference = std::move(b), - }); flutter::TaskRunners task_runners = flutter::TaskRunners("test_runners", nullptr, nullptr, nullptr, nullptr); @@ -160,7 +153,6 @@ TEST_F(PlatformViewTests, EnableWireframeTest) { auto platform_view = flutter_runner::PlatformView( delegate, // delegate "test_platform_view", // label - std::move(view_ref_control), // view_ref_control std::move(view_ref), // view_refs std::move(task_runners), // task_runners services_provider.service_directory(), // runner_services diff --git a/shell/platform/fuchsia/flutter/session_connection.cc b/shell/platform/fuchsia/flutter/session_connection.cc index f79c5579cf73f..c60224bec31f6 100644 --- a/shell/platform/fuchsia/flutter/session_connection.cc +++ b/shell/platform/fuchsia/flutter/session_connection.cc @@ -15,12 +15,17 @@ namespace flutter_runner { SessionConnection::SessionConnection( std::string debug_label, fuchsia::ui::views::ViewToken view_token, + scenic::ViewRefPair view_ref_pair, fidl::InterfaceHandle session, fml::closure session_error_callback, zx_handle_t vsync_event_handle) : debug_label_(std::move(debug_label)), session_wrapper_(session.Bind(), nullptr), - root_view_(&session_wrapper_, std::move(view_token.value), debug_label), + root_view_(&session_wrapper_, + std::move(view_token), + std::move(view_ref_pair.control_ref), + std::move(view_ref_pair.view_ref), + debug_label), root_node_(&session_wrapper_), surface_producer_( std::make_unique(&session_wrapper_)), diff --git a/shell/platform/fuchsia/flutter/session_connection.h b/shell/platform/fuchsia/flutter/session_connection.h index 77a42c2f4f2ba..838e51b2b5ce6 100644 --- a/shell/platform/fuchsia/flutter/session_connection.h +++ b/shell/platform/fuchsia/flutter/session_connection.h @@ -13,6 +13,7 @@ #include #include #include +#include #include "flutter/flow/compositor_context.h" #include "flutter/flow/scene_update_context.h" @@ -29,6 +30,7 @@ class SessionConnection final { public: SessionConnection(std::string debug_label, fuchsia::ui::views::ViewToken view_token, + scenic::ViewRefPair view_ref_pair, fidl::InterfaceHandle session, fml::closure session_error_callback, zx_handle_t vsync_event_handle);