fuchsia: Implement CreateViewWithViewProvider (flutter/engine#18280)
Tested: Manual test via workstation product BUG: 50875
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include <lib/async/default.h>
|
#include <lib/async/default.h>
|
||||||
#include <lib/fdio/directory.h>
|
#include <lib/fdio/directory.h>
|
||||||
#include <lib/fdio/namespace.h>
|
#include <lib/fdio/namespace.h>
|
||||||
|
#include <lib/ui/scenic/cpp/view_ref_pair.h>
|
||||||
#include <lib/ui/scenic/cpp/view_token_pair.h>
|
#include <lib/ui/scenic/cpp/view_token_pair.h>
|
||||||
#include <lib/vfs/cpp/composed_service_dir.h>
|
#include <lib/vfs/cpp/composed_service_dir.h>
|
||||||
#include <lib/vfs/cpp/remote_dir.h>
|
#include <lib/vfs/cpp/remote_dir.h>
|
||||||
@@ -553,7 +554,6 @@ void Application::AttemptVMLaunchWithCurrentSettings(
|
|||||||
FML_CHECK(vm) << "Mut be able to initialize the VM.";
|
FML_CHECK(vm) << "Mut be able to initialize the VM.";
|
||||||
}
|
}
|
||||||
|
|
||||||
// |fuchsia::sys::ComponentController|
|
|
||||||
void Application::Kill() {
|
void Application::Kill() {
|
||||||
application_controller_.events().OnTerminated(
|
application_controller_.events().OnTerminated(
|
||||||
last_return_code_.second, fuchsia::sys::TerminationReason::EXITED);
|
last_return_code_.second, fuchsia::sys::TerminationReason::EXITED);
|
||||||
@@ -563,12 +563,10 @@ void Application::Kill() {
|
|||||||
// collected.
|
// collected.
|
||||||
}
|
}
|
||||||
|
|
||||||
// |fuchsia::sys::ComponentController|
|
|
||||||
void Application::Detach() {
|
void Application::Detach() {
|
||||||
application_controller_.set_error_handler(nullptr);
|
application_controller_.set_error_handler(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// |flutter::Engine::Delegate|
|
|
||||||
void Application::OnEngineTerminate(const Engine* shell_holder) {
|
void Application::OnEngineTerminate(const Engine* shell_holder) {
|
||||||
auto found = std::find_if(shell_holders_.begin(), shell_holders_.end(),
|
auto found = std::find_if(shell_holders_.begin(), shell_holders_.end(),
|
||||||
[shell_holder](const auto& holder) {
|
[shell_holder](const auto& holder) {
|
||||||
@@ -596,11 +594,20 @@ void Application::OnEngineTerminate(const Engine* shell_holder) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// |fuchsia::ui::app::ViewProvider|
|
|
||||||
void Application::CreateView(
|
void Application::CreateView(
|
||||||
|
zx::eventpair token,
|
||||||
|
fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> /*incoming_services*/,
|
||||||
|
fidl::InterfaceHandle<
|
||||||
|
fuchsia::sys::ServiceProvider> /*outgoing_services*/) {
|
||||||
|
auto view_ref_pair = scenic::ViewRefPair::New();
|
||||||
|
CreateViewWithViewRef(std::move(token), std::move(view_ref_pair.control_ref),
|
||||||
|
std::move(view_ref_pair.view_ref));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::CreateViewWithViewRef(
|
||||||
zx::eventpair view_token,
|
zx::eventpair view_token,
|
||||||
fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> incoming_services,
|
fuchsia::ui::views::ViewRefControl control_ref,
|
||||||
fidl::InterfaceHandle<fuchsia::sys::ServiceProvider> outgoing_services) {
|
fuchsia::ui::views::ViewRef view_ref) {
|
||||||
if (!svc_) {
|
if (!svc_) {
|
||||||
FML_DLOG(ERROR)
|
FML_DLOG(ERROR)
|
||||||
<< "Component incoming services was invalid when attempting to "
|
<< "Component incoming services was invalid when attempting to "
|
||||||
@@ -616,6 +623,8 @@ void Application::CreateView(
|
|||||||
settings_, // settings
|
settings_, // settings
|
||||||
std::move(isolate_snapshot_), // isolate snapshot
|
std::move(isolate_snapshot_), // isolate snapshot
|
||||||
scenic::ToViewToken(std::move(view_token)), // view token
|
scenic::ToViewToken(std::move(view_token)), // view token
|
||||||
|
std::move(control_ref), // view ref control
|
||||||
|
std::move(view_ref), // view ref
|
||||||
std::move(fdio_ns_), // FDIO namespace
|
std::move(fdio_ns_), // FDIO namespace
|
||||||
std::move(directory_request_), // outgoing request
|
std::move(directory_request_), // outgoing request
|
||||||
product_config_ // product configuration
|
product_config_ // product configuration
|
||||||
|
|||||||
@@ -114,11 +114,16 @@ class Application final : public Engine::Delegate,
|
|||||||
|
|
||||||
// |fuchsia::ui::app::ViewProvider|
|
// |fuchsia::ui::app::ViewProvider|
|
||||||
void CreateView(
|
void CreateView(
|
||||||
zx::eventpair view_token,
|
zx::eventpair token,
|
||||||
fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> incoming_services,
|
fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> incoming_services,
|
||||||
fidl::InterfaceHandle<fuchsia::sys::ServiceProvider> outgoing_services)
|
fidl::InterfaceHandle<fuchsia::sys::ServiceProvider> outgoing_services)
|
||||||
override;
|
override;
|
||||||
|
|
||||||
|
// |fuchsia::ui::app::ViewProvider|
|
||||||
|
void CreateViewWithViewRef(zx::eventpair view_token,
|
||||||
|
fuchsia::ui::views::ViewRefControl control_ref,
|
||||||
|
fuchsia::ui::views::ViewRef view_ref) override;
|
||||||
|
|
||||||
// |flutter::Engine::Delegate|
|
// |flutter::Engine::Delegate|
|
||||||
void OnEngineTerminate(const Engine* holder) override;
|
void OnEngineTerminate(const Engine* holder) override;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
#include <lib/async/cpp/task.h>
|
#include <lib/async/cpp/task.h>
|
||||||
#include <lib/ui/scenic/cpp/view_ref_pair.h>
|
|
||||||
#include <zircon/status.h>
|
#include <zircon/status.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@@ -50,16 +49,19 @@ static fml::RefPtr<flutter::PlatformMessage> MakeLocalizationPlatformMessage(
|
|||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine::Engine(Delegate& delegate,
|
Engine::Engine(
|
||||||
std::string thread_label,
|
Delegate& delegate,
|
||||||
std::shared_ptr<sys::ServiceDirectory> svc,
|
std::string thread_label,
|
||||||
std::shared_ptr<sys::ServiceDirectory> runner_services,
|
std::shared_ptr<sys::ServiceDirectory> svc,
|
||||||
flutter::Settings settings,
|
std::shared_ptr<sys::ServiceDirectory> runner_services,
|
||||||
fml::RefPtr<const flutter::DartSnapshot> isolate_snapshot,
|
flutter::Settings settings,
|
||||||
fuchsia::ui::views::ViewToken view_token,
|
fml::RefPtr<const flutter::DartSnapshot> isolate_snapshot,
|
||||||
UniqueFDIONS fdio_ns,
|
fuchsia::ui::views::ViewToken view_token,
|
||||||
fidl::InterfaceRequest<fuchsia::io::Directory> directory_request,
|
scenic
|
||||||
FlutterRunnerProductConfiguration product_config)
|
: ViewRefPair view_ref_pair,
|
||||||
|
UniqueFDIONS fdio_ns,
|
||||||
|
fidl::InterfaceRequest<fuchsia::io::Directory> directory_request,
|
||||||
|
FlutterRunnerProductConfiguration product_config)
|
||||||
: delegate_(delegate),
|
: delegate_(delegate),
|
||||||
thread_label_(std::move(thread_label)),
|
thread_label_(std::move(thread_label)),
|
||||||
settings_(std::move(settings)),
|
settings_(std::move(settings)),
|
||||||
@@ -115,18 +117,14 @@ Engine::Engine(Delegate& delegate,
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
auto view_ref_pair = scenic::ViewRefPair::New();
|
fuchsia::ui::views::ViewRef platform_view_ref, isolate_view_ref;
|
||||||
fuchsia::ui::views::ViewRef view_ref;
|
view_ref_pair.view_ref.Clone(&platform_view_ref);
|
||||||
view_ref_pair.view_ref.Clone(&view_ref);
|
view_ref_pair.view_ref.Clone(&isolate_view_ref);
|
||||||
|
|
||||||
fuchsia::ui::views::ViewRef dart_view_ref;
|
|
||||||
view_ref_pair.view_ref.Clone(&dart_view_ref);
|
|
||||||
zx::eventpair dart_view_ref_event_pair(std::move(dart_view_ref.reference));
|
|
||||||
|
|
||||||
// Setup the callback that will instantiate the platform view.
|
// Setup the callback that will instantiate the platform view.
|
||||||
flutter::Shell::CreateCallback<flutter::PlatformView>
|
flutter::Shell::CreateCallback<flutter::PlatformView>
|
||||||
on_create_platform_view = fml::MakeCopyable(
|
on_create_platform_view = fml::MakeCopyable(
|
||||||
[debug_label = thread_label_, view_ref = std::move(view_ref),
|
[debug_label = thread_label_, view_ref = std::move(platform_view_ref),
|
||||||
runner_services,
|
runner_services,
|
||||||
parent_environment_service_provider =
|
parent_environment_service_provider =
|
||||||
std::move(parent_environment_service_provider),
|
std::move(parent_environment_service_provider),
|
||||||
@@ -263,10 +261,10 @@ Engine::Engine(Delegate& delegate,
|
|||||||
svc->Connect(environment.NewRequest());
|
svc->Connect(environment.NewRequest());
|
||||||
|
|
||||||
isolate_configurator_ = std::make_unique<IsolateConfigurator>(
|
isolate_configurator_ = std::make_unique<IsolateConfigurator>(
|
||||||
std::move(fdio_ns), //
|
std::move(fdio_ns), //
|
||||||
std::move(environment), //
|
std::move(environment), //
|
||||||
directory_request.TakeChannel(), //
|
directory_request.TakeChannel(), //
|
||||||
std::move(dart_view_ref_event_pair) //
|
std::move(isolate_view_ref.reference) //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <fuchsia/ui/views/cpp/fidl.h>
|
#include <fuchsia/ui/views/cpp/fidl.h>
|
||||||
#include <lib/async-loop/cpp/loop.h>
|
#include <lib/async-loop/cpp/loop.h>
|
||||||
#include <lib/sys/cpp/service_directory.h>
|
#include <lib/sys/cpp/service_directory.h>
|
||||||
|
#include <lib/ui/scenic/cpp/view_ref_pair.h>
|
||||||
#include <lib/zx/event.h>
|
#include <lib/zx/event.h>
|
||||||
|
|
||||||
#include "flutter/fml/macros.h"
|
#include "flutter/fml/macros.h"
|
||||||
@@ -37,6 +38,7 @@ class Engine final {
|
|||||||
flutter::Settings settings,
|
flutter::Settings settings,
|
||||||
fml::RefPtr<const flutter::DartSnapshot> isolate_snapshot,
|
fml::RefPtr<const flutter::DartSnapshot> isolate_snapshot,
|
||||||
fuchsia::ui::views::ViewToken view_token,
|
fuchsia::ui::views::ViewToken view_token,
|
||||||
|
scenic::ViewRefPair view_ref_pair,
|
||||||
UniqueFDIONS fdio_ns,
|
UniqueFDIONS fdio_ns,
|
||||||
fidl::InterfaceRequest<fuchsia::io::Directory> directory_request,
|
fidl::InterfaceRequest<fuchsia::io::Directory> directory_request,
|
||||||
FlutterRunnerProductConfiguration product_config);
|
FlutterRunnerProductConfiguration product_config);
|
||||||
|
|||||||
Reference in New Issue
Block a user