diff --git a/content_handler/accessibility_bridge.cc b/content_handler/accessibility_bridge.cc index f3d52f6cdbbb693d7b877769f14051e88ce79cca..ecff416427da572f2aaa1915feeaf7a899775832 100644 --- a/content_handler/accessibility_bridge.cc +++ b/content_handler/accessibility_bridge.cc @@ -7,14 +7,13 @@ #include #include "lib/app/cpp/application_context.h" -#include "lib/context/fidl/context_writer.fidl.h" #include "third_party/rapidjson/rapidjson/document.h" #include "third_party/rapidjson/rapidjson/stringbuffer.h" #include "third_party/rapidjson/rapidjson/writer.h" namespace flutter { -AccessibilityBridge::AccessibilityBridge(maxwell::ContextWriterPtr writer) +AccessibilityBridge::AccessibilityBridge(modular::ContextWriterPtr writer) : writer_(std::move(writer)) {} AccessibilityBridge::~AccessibilityBridge() = default; diff --git a/content_handler/accessibility_bridge.h b/content_handler/accessibility_bridge.h index dde8bfaa54c3654cd3f5fbb5aa0db5e5db50940e..70a304fb545b9ab0ecbd8ac6ae85c00a76330858 100644 --- a/content_handler/accessibility_bridge.h +++ b/content_handler/accessibility_bridge.h @@ -6,8 +6,9 @@ #include +#include + #include "flutter/lib/ui/semantics/semantics_node.h" -#include "lib/context/fidl/context_writer.fidl.h" #include "lib/fxl/macros.h" namespace flutter { @@ -16,7 +17,7 @@ namespace flutter { // with the Context Service. class AccessibilityBridge final { public: - AccessibilityBridge(maxwell::ContextWriterPtr writer); + AccessibilityBridge(modular::ContextWriterPtr writer); ~AccessibilityBridge(); @@ -25,7 +26,7 @@ class AccessibilityBridge final { void UpdateSemantics(const blink::SemanticsNodeUpdates& update); private: - maxwell::ContextWriterPtr writer_; + modular::ContextWriterPtr writer_; std::map semantics_nodes_; // Walk the semantics node tree starting at |id|, and store the id of each diff --git a/content_handler/application.cc b/content_handler/application.cc index 7dd2270d42317cc3a074ea05f46e362d03963138..3f56ab911cb646f5561f321a8a25cde4b1c0e164 100644 --- a/content_handler/application.cc +++ b/content_handler/application.cc @@ -21,9 +21,9 @@ namespace flutter { std::pair, std::unique_ptr> Application::Create( Application::Delegate& delegate, - component::ApplicationPackagePtr package, - component::ApplicationStartupInfoPtr startup_info, - f1dl::InterfaceRequest controller) { + component::ApplicationPackage package, + component::ApplicationStartupInfo startup_info, + fidl::InterfaceRequest controller) { auto thread = std::make_unique(); std::unique_ptr application; @@ -52,52 +52,48 @@ static std::string DebugLabelForURL(const std::string url) { Application::Application( Application::Delegate& delegate, - component::ApplicationPackagePtr package, - component::ApplicationStartupInfoPtr startup_info, - f1dl::InterfaceRequest + component::ApplicationPackage, + component::ApplicationStartupInfo startup_info, + fidl::InterfaceRequest application_controller_request) : delegate_(delegate), - debug_label_(DebugLabelForURL(startup_info->launch_info->url)), + debug_label_(DebugLabelForURL(startup_info.launch_info.url)), application_controller_(this) { application_controller_.set_error_handler([this]() { Kill(); }); FXL_DCHECK(fdio_ns_.is_valid()); // ApplicationLaunchInfo::url non-optional. - auto& launch_info = startup_info->launch_info; + auto& launch_info = startup_info.launch_info; // ApplicationLaunchInfo::arguments optional. - if (auto& arguments = launch_info->arguments) { + if (auto& arguments = launch_info.arguments) { settings_ = shell::SettingsFromCommandLine( fxl::CommandLineFromIterators(arguments->begin(), arguments->end())); } - // TODO: ApplicationLaunchInfo::out optional. + // TODO: ApplicationLaunchInfo::out. - // TODO: ApplicationLaunchInfo::err optional. + // TODO: ApplicationLaunchInfo::err. // ApplicationLaunchInfo::service_request optional. - if (launch_info->directory_request) { + if (launch_info.directory_request) { service_provider_bridge_.ServeDirectory( - std::move(launch_info->directory_request)); + std::move(launch_info.directory_request)); } // ApplicationLaunchInfo::flat_namespace optional. - if (auto& flat_namespace = startup_info->flat_namespace) { - for (size_t i = 0; i < flat_namespace->paths->size(); ++i) { - const auto& path = flat_namespace->paths->at(i); - if (path == "/svc") { - continue; - } - - zx::channel dir = std::move(flat_namespace->directories->at(i)); - zx_handle_t dir_handle = dir.release(); - if (fdio_ns_bind(fdio_ns_.get(), path->data(), dir_handle) != ZX_OK) { - FXL_DLOG(ERROR) << "Could not bind path to namespace: " << path; - zx_handle_close(dir_handle); - } + for (size_t i = 0; i < startup_info.flat_namespace.paths->size(); ++i) { + const auto& path = startup_info.flat_namespace.paths->at(i); + if (path == "/svc") { + continue; + } + + zx::channel dir = std::move(startup_info.flat_namespace.directories->at(i)); + zx_handle_t dir_handle = dir.release(); + if (fdio_ns_bind(fdio_ns_.get(), path->data(), dir_handle) != ZX_OK) { + FXL_DLOG(ERROR) << "Could not bind path to namespace: " << path; + zx_handle_close(dir_handle); } - } else { - FXL_DLOG(ERROR) << "There was no flat namespace."; } application_directory_.reset(fdio_ns_opendir(fdio_ns_.get())); @@ -108,15 +104,11 @@ Application::Application( // TODO: ApplicationLaunchInfo::additional_services optional. - // ApplicationPackage::data: This is legacy FLX data. Ensure that we dont have - // any. - FXL_DCHECK(!package->data) << "Legacy FLX data must not be supplied."; - // All launch arguments have been read. Perform service binding and // final settings configuration. The next call will be to create a view // for this application. - service_provider_bridge_.AddService( + service_provider_bridge_.AddService( std::bind(&Application::CreateShellForView, this, std::placeholders::_1)); component::ServiceProviderPtr outgoing_services; @@ -193,10 +185,10 @@ void Application::AttemptVMLaunchWithCurrentSettings( return; } - auto lib = fxl::MakeRefCounted( - library_handle, // library handle - true // close the handle when done - ); + auto lib = + fml::NativeLibrary::CreateWithHandle(library_handle, // library handle + true // close the handle when done + ); auto symbol = [](const char* str) { return std::string{"_"} + std::string{str}; @@ -248,7 +240,7 @@ void Application::Detach() { } // |component::ApplicationController| -void Application::Wait(const WaitCallback& callback) { +void Application::Wait(WaitCallback callback) { wait_callbacks_.emplace_back(std::move(callback)); } @@ -281,14 +273,14 @@ void Application::OnEngineTerminate(const Engine* shell_holder) { } void Application::CreateShellForView( - f1dl::InterfaceRequest view_provider_request) { + fidl::InterfaceRequest view_provider_request) { shells_bindings_.AddBinding(this, std::move(view_provider_request)); } -// |mozart::ViewProvider| +// |views_v1::ViewProvider| void Application::CreateView( - f1dl::InterfaceRequest view_owner, - f1dl::InterfaceRequest) { + fidl::InterfaceRequest view_owner, + fidl::InterfaceRequest) { if (!application_context_) { FXL_DLOG(ERROR) << "Application context was invalid when attempting to " "create a shell for a view provider request."; diff --git a/content_handler/application.h b/content_handler/application.h index e4f5da105cac802f7bb41c04690a7c51375e69e3..eb06a4aad07fd93a3ce9ee408a3c98ed85cd84a9 100644 --- a/content_handler/application.h +++ b/content_handler/application.h @@ -8,16 +8,19 @@ #include #include +#include +#include +#include + #include "engine.h" #include "flutter/common/settings.h" #include "lib/app/cpp/application_context.h" -#include "lib/app/fidl/application_controller.fidl.h" -#include "lib/fidl/cpp/bindings/binding_set.h" +#include "lib/fidl/cpp/binding_set.h" +#include "lib/fidl/cpp/interface_request.h" #include "lib/fsl/threading/thread.h" #include "lib/fxl/files/unique_fd.h" #include "lib/fxl/macros.h" #include "lib/svc/cpp/service_provider_bridge.h" -#include "lib/ui/views/fidl/view_provider.fidl.h" #include "unique_fdio_ns.h" namespace flutter { @@ -26,7 +29,7 @@ namespace flutter { // Flutter engine instances. class Application final : public Engine::Delegate, public component::ApplicationController, - public mozart::ViewProvider { + public views_v1::ViewProvider { public: class Delegate { public: @@ -38,9 +41,9 @@ class Application final : public Engine::Delegate, // This is a synchronous operation. static std::pair, std::unique_ptr> Create(Application::Delegate& delegate, - component::ApplicationPackagePtr package, - component::ApplicationStartupInfoPtr startup_info, - f1dl::InterfaceRequest controller); + component::ApplicationPackage package, + component::ApplicationStartupInfo startup_info, + fidl::InterfaceRequest controller); // Must be called on the same thread returned from the create call. The thread // may be collected after. @@ -53,20 +56,20 @@ class Application final : public Engine::Delegate, UniqueFDIONS fdio_ns_ = UniqueFDIONSCreate(); fxl::UniqueFD application_directory_; fxl::UniqueFD application_assets_directory_; - f1dl::Binding application_controller_; - f1dl::InterfaceRequest outgoing_services_request_; + fidl::Binding application_controller_; + fidl::InterfaceRequest outgoing_services_request_; component::ServiceProviderBridge service_provider_bridge_; std::unique_ptr application_context_; - f1dl::BindingSet shells_bindings_; + fidl::BindingSet shells_bindings_; std::set> shell_holders_; std::vector wait_callbacks_; std::pair last_return_code_; Application( Application::Delegate& delegate, - component::ApplicationPackagePtr package, - component::ApplicationStartupInfoPtr startup_info, - f1dl::InterfaceRequest controller); + component::ApplicationPackage package, + component::ApplicationStartupInfo startup_info, + fidl::InterfaceRequest controller); // |component::ApplicationController| void Kill() override; @@ -75,18 +78,18 @@ class Application final : public Engine::Delegate, void Detach() override; // |component::ApplicationController| - void Wait(const WaitCallback& callback) override; + void Wait(WaitCallback callback) override; - // |mozart::ViewProvider| + // |views_v1::ViewProvider| void CreateView( - f1dl::InterfaceRequest view_owner, - f1dl::InterfaceRequest services) override; + fidl::InterfaceRequest view_owner, + fidl::InterfaceRequest services) override; // |flutter::Engine::Delegate| void OnEngineTerminate(const Engine* holder) override; void CreateShellForView( - f1dl::InterfaceRequest view_provider_request); + fidl::InterfaceRequest view_provider_request); void AttemptVMLaunchWithCurrentSettings( const blink::Settings& settings) const; diff --git a/content_handler/application_runner.cc b/content_handler/application_runner.cc index 2d77f43cbdd45dbed3eef1b73f2ded7cc68d8914..9a36fd1881c0e1fcc4bafc835e58fffca4afb2c3 100644 --- a/content_handler/application_runner.cc +++ b/content_handler/application_runner.cc @@ -8,7 +8,6 @@ #include "flutter/lib/ui/text/font_collection.h" #include "fuchsia_font_manager.h" -#include "lib/fonts/fidl/font_provider.fidl.h" #include "lib/icu_data/cpp/icu_data.h" namespace flutter { @@ -38,14 +37,14 @@ ApplicationRunner::~ApplicationRunner() { } void ApplicationRunner::RegisterApplication( - f1dl::InterfaceRequest request) { + fidl::InterfaceRequest request) { active_applications_bindings_.AddBinding(this, std::move(request)); } void ApplicationRunner::StartApplication( - component::ApplicationPackagePtr package, - component::ApplicationStartupInfoPtr startup_info, - f1dl::InterfaceRequest controller) { + component::ApplicationPackage package, + component::ApplicationStartupInfo startup_info, + fidl::InterfaceRequest controller) { auto thread_application_pair = Application::Create(*this, // delegate std::move(package), // application pacakge diff --git a/content_handler/application_runner.h b/content_handler/application_runner.h index fdf5b4420dc0f3570f41f688e7bc0f740de76936..bae56b79dad39e65fab68782265975136f1fa4b7 100644 --- a/content_handler/application_runner.h +++ b/content_handler/application_runner.h @@ -7,10 +7,11 @@ #include #include +#include + #include "application.h" #include "lib/app/cpp/application_context.h" -#include "lib/app/fidl/application_runner.fidl.h" -#include "lib/fidl/cpp/bindings/binding_set.h" +#include "lib/fidl/cpp/binding_set.h" #include "lib/fsl/tasks/message_loop.h" #include "lib/fxl/functional/make_copyable.h" #include "lib/fxl/macros.h" @@ -49,18 +50,18 @@ class ApplicationRunner final : public Application::Delegate, fxl::Closure on_termination_callback_; std::unique_ptr host_context_; - f1dl::BindingSet active_applications_bindings_; + fidl::BindingSet active_applications_bindings_; std::unordered_map active_applications_; // |component::ApplicationRunner| - void StartApplication(component::ApplicationPackagePtr application, - component::ApplicationStartupInfoPtr startup_info, - f1dl::InterfaceRequest + void StartApplication(component::ApplicationPackage application, + component::ApplicationStartupInfo startup_info, + fidl::InterfaceRequest controller) override; void RegisterApplication( - f1dl::InterfaceRequest request); + fidl::InterfaceRequest request); void UnregisterApplication(const Application* application); diff --git a/content_handler/compositor_context.h b/content_handler/compositor_context.h index a6e5429c6072c7fbb7802ddc7e428276cff433fc..d5bed1f267d969c41dfc74a9b6df9d184b6647b4 100644 --- a/content_handler/compositor_context.h +++ b/content_handler/compositor_context.h @@ -4,8 +4,9 @@ #pragma once +#include + #include "flutter/flow/compositor_context.h" -#include "garnet/public/lib/ui/scenic/fidl/scenic.fidl-common.h" #include "lib/fxl/macros.h" #include "session_connection.h" diff --git a/content_handler/engine.cc b/content_handler/engine.cc index 3349c09bdf1af7d676b1fdd64e65b3d3ea00bfad..ebdaff84f3bd7688961bca62b894ca340311c3c2 100644 --- a/content_handler/engine.cc +++ b/content_handler/engine.cc @@ -15,19 +15,15 @@ #include "lib/fxl/synchronization/waitable_event.h" #include "platform_view.h" -#ifdef ERROR -#undef ERROR -#endif - namespace flutter { Engine::Engine(Delegate& delegate, std::string thread_label, component::ApplicationContext& application_context, blink::Settings settings, - f1dl::InterfaceRequest view_owner, + fidl::InterfaceRequest view_owner, const UniqueFDIONS& fdio_ns, - f1dl::InterfaceRequest + fidl::InterfaceRequest outgoing_services_request) : delegate_(delegate), thread_label_(std::move(thread_label)), @@ -39,7 +35,7 @@ Engine::Engine(Delegate& delegate, thread.Run(); } - mozart::ViewManagerPtr view_manager; + views_v1::ViewManagerPtr view_manager; application_context.ConnectToEnvironmentService(view_manager.NewRequest()); zx::eventpair import_token, export_token; @@ -66,10 +62,21 @@ Engine::Engine(Delegate& delegate, // Grab the accessibilty context writer that can understand the semtics tree // on the platform view. - maxwell::ContextWriterPtr accessibility_context_writer; + modular::ContextWriterPtr accessibility_context_writer; application_context.ConnectToEnvironmentService( accessibility_context_writer.NewRequest()); + // Create the compositor context from the scenic pointer to create the + // rasterizer. + std::unique_ptr compositor_context = + std::make_unique( + scenic, // scenic + thread_label_, // debug label + std::move(import_token), // import token + on_session_metrics_change_callback, // session metrics did change + on_session_error_callback // session did encounter error + ); + // Setup the callback that will instantiate the platform view. shell::Shell::CreateCallback on_create_platform_view = fxl::MakeCopyable([debug_label = thread_label_, // @@ -80,10 +87,8 @@ Engine::Engine(Delegate& delegate, scenic = std::move(scenic), // accessibility_context_writer = std::move(accessibility_context_writer), // - export_token = std::move(export_token), // - import_token = std::move(import_token), // - on_session_metrics_change_callback, // - on_session_error_callback // + export_token = std::move(export_token) // + ](shell::Shell& shell) mutable { return std::make_unique( shell, // delegate @@ -94,21 +99,20 @@ Engine::Engine(Delegate& delegate, std::move(view_owner), // view owner std::move(scenic), // scenic std::move(export_token), // export token - std::move(import_token), // import token std::move( - accessibility_context_writer), // accessibility context writer - std::move(on_session_metrics_change_callback), // metrics change - std::move(on_session_error_callback) // session_error + accessibility_context_writer) // accessibility context writer ); }); // Setup the callback that will instantiate the rasterizer. shell::Shell::CreateCallback on_create_rasterizer = - [](shell::Shell& shell) { + fxl::MakeCopyable([compositor_context = std::move(compositor_context)]( + shell::Shell& shell) mutable { return std::make_unique( - shell.GetTaskRunners() // task runners + shell.GetTaskRunners(), // task runners + std::move(compositor_context) // compositor context ); - }; + }); // Get the task runners from the managed threads. The current thread will be // used as the "platform" thread. diff --git a/content_handler/engine.h b/content_handler/engine.h index 60c0ad7c2f80d2f4fcca31c62bc6080fe1fff389..c881726cac5a2f80b1941ff718758c987c83d594 100644 --- a/content_handler/engine.h +++ b/content_handler/engine.h @@ -4,13 +4,15 @@ #pragma once +#include +#include + #include "flutter/shell/common/shell.h" #include "isolate_configurator.h" #include "lib/app/cpp/application_context.h" #include "lib/fsl/threading/thread.h" #include "lib/fxl/macros.h" #include "lib/fxl/memory/weak_ptr.h" -#include "lib/ui/views/fidl/view_manager.fidl.h" namespace flutter { @@ -27,9 +29,9 @@ class Engine final { std::string thread_label, component::ApplicationContext& application_context, blink::Settings settings, - f1dl::InterfaceRequest view_owner, + fidl::InterfaceRequest view_owner, const UniqueFDIONS& fdio_ns, - f1dl::InterfaceRequest + fidl::InterfaceRequest outgoing_services_request); ~Engine(); diff --git a/content_handler/fuchsia_font_manager.cc b/content_handler/fuchsia_font_manager.cc index 877c931130eb48c8b3b0cc23b5d4952793257bfd..c369e54400e107c0672af186e50f7462a9ea1d7e 100644 --- a/content_handler/fuchsia_font_manager.cc +++ b/content_handler/fuchsia_font_manager.cc @@ -32,14 +32,14 @@ void UnmapMemory(const void* buffer, void* context) { zx::vmar::root_self().unmap(reinterpret_cast(buffer), size); } -sk_sp MakeSkDataFromVMO(const fsl::SizedVmoTransportPtr& vmo) { - if (!fsl::SizedVmo::IsSizeValid(vmo->vmo, vmo->size) || - vmo->size > std::numeric_limits::max()) { +sk_sp MakeSkDataFromBuffer(const mem::Buffer& data) { + if (!fsl::SizedVmo::IsSizeValid(data.vmo, data.size) || + data.size > std::numeric_limits::max()) { return nullptr; } - uint64_t size = vmo->size; + uint64_t size = data.size; uintptr_t buffer = 0; - zx_status_t status = zx::vmar::root_self().map(0, vmo->vmo, 0, size, + zx_status_t status = zx::vmar::root_self().map(0, data.vmo, 0, size, ZX_VM_FLAG_PERM_READ, &buffer); if (status != ZX_OK) return nullptr; @@ -90,11 +90,11 @@ SkFontStyleSet* FuchsiaFontManager::onMatchFamily( SkTypeface* FuchsiaFontManager::onMatchFamilyStyle( const char family_name[], const SkFontStyle& style) const { - auto request = fonts::FontRequest::New(); - request->family = family_name; - request->weight = style.weight(); - request->width = style.width(); - request->slant = ToFontSlant(style.slant()); + fonts::FontRequest request; + request.family = family_name; + request.weight = style.weight(); + request.width = style.width(); + request.slant = ToFontSlant(style.slant()); fonts::FontResponsePtr response; font_provider_->GetFont( @@ -108,7 +108,7 @@ SkTypeface* FuchsiaFontManager::onMatchFamilyStyle( return nullptr; } - sk_sp data = MakeSkDataFromVMO(response->data->vmo); + sk_sp data = MakeSkDataFromBuffer(response->data.buffer); if (!data) return nullptr; diff --git a/content_handler/isolate_configurator.cc b/content_handler/isolate_configurator.cc index d085bea698b9540bbf537d975c369946e6b00326..99a9bee78e3e622236ca0e4ba874ddc690960979 100644 --- a/content_handler/isolate_configurator.cc +++ b/content_handler/isolate_configurator.cc @@ -16,9 +16,9 @@ namespace flutter { IsolateConfigurator::IsolateConfigurator( const UniqueFDIONS& fdio_ns, - mozart::ViewPtr& view, + views_v1::ViewPtr& view, component::ApplicationEnvironmentPtr application_environment, - f1dl::InterfaceRequest + fidl::InterfaceRequest outgoing_services_request) : fdio_ns_(fdio_ns), view_(view), @@ -42,7 +42,7 @@ bool IsolateConfigurator::ConfigureCurrentIsolate() { } // |mozart::NativesDelegate| -mozart::View* IsolateConfigurator::GetMozartView() { +views_v1::View* IsolateConfigurator::GetMozartView() { return view_.get(); } @@ -102,7 +102,7 @@ void IsolateConfigurator::BindScenic() { tonic::ToDart("_context"), // tonic::DartConverter::ToDart(reinterpret_cast( static_cast(this))))); - mozart::ViewContainerPtr view_container; + views_v1::ViewContainerPtr view_container; view_->GetContainer(view_container.NewRequest()); DART_CHECK_VALID( Dart_SetField(mozart_internal, // diff --git a/content_handler/isolate_configurator.h b/content_handler/isolate_configurator.h index a5da083633ee76348201902296227bb9bf2fd06a..b7cc438418bc62394c5545ca6d88ef0d5b9804a5 100644 --- a/content_handler/isolate_configurator.h +++ b/content_handler/isolate_configurator.h @@ -4,11 +4,12 @@ #pragma once -#include "lib/app/fidl/application_environment.fidl.h" +#include +#include +#include + #include "lib/fxl/macros.h" #include "lib/ui/flutter/sdk_ext/src/natives.h" -#include "lib/ui/views/fidl/view_containers.fidl.h" -#include "lib/ui/views/fidl/views.fidl.h" #include "unique_fdio_ns.h" namespace flutter { @@ -20,9 +21,9 @@ class IsolateConfigurator final : mozart::NativesDelegate { public: IsolateConfigurator( const UniqueFDIONS& fdio_ns, - mozart::ViewPtr& view, + views_v1::ViewPtr& view, component::ApplicationEnvironmentPtr application_environment, - f1dl::InterfaceRequest + fidl::InterfaceRequest outgoing_services_request); ~IsolateConfigurator(); @@ -34,12 +35,12 @@ class IsolateConfigurator final : mozart::NativesDelegate { private: bool used_ = false; const UniqueFDIONS& fdio_ns_; - mozart::ViewPtr& view_; + views_v1::ViewPtr& view_; component::ApplicationEnvironmentPtr application_environment_; - f1dl::InterfaceRequest outgoing_services_request_; + fidl::InterfaceRequest outgoing_services_request_; // |mozart::NativesDelegate| - mozart::View* GetMozartView() override; + views_v1::View* GetMozartView() override; void BindFuchsia(); diff --git a/content_handler/platform_view.cc b/content_handler/platform_view.cc index 8ac41613e449b08d9e3eff2b810bda22c1186e1a..00f46e477923425ea11775ece5ec9599b6d3669e 100644 --- a/content_handler/platform_view.cc +++ b/content_handler/platform_view.cc @@ -25,14 +25,11 @@ PlatformView::PlatformView( std::string debug_label, blink::TaskRunners task_runners, component::ServiceProviderPtr parent_environment_service_provider, - mozart::ViewManagerPtr& view_manager, - f1dl::InterfaceRequest view_owner, + views_v1::ViewManagerPtr& view_manager, + fidl::InterfaceRequest view_owner, ui::ScenicPtr scenic, zx::eventpair export_token, - zx::eventpair import_token, - maxwell::ContextWriterPtr accessibility_context_writer, - OnMetricsUpdate on_session_metrics_did_change, - fxl::Closure session_error_callback) + modular::ContextWriterPtr accessibility_context_writer) : shell::PlatformView(delegate, std::move(task_runners)), debug_label_(std::move(debug_label)), view_listener_(this), @@ -40,12 +37,7 @@ PlatformView::PlatformView( ime_client_(this), scenic_(std::move(scenic)), accessibility_bridge_(std::move(accessibility_context_writer)), - surface_( - std::make_unique(scenic_, - debug_label_, - std::move(import_token), - std::move(on_session_metrics_did_change), - std::move(session_error_callback))) { + surface_(std::make_unique(debug_label_)) { // Create the view. view_manager->CreateView(view_.NewRequest(), // view std::move(view_owner), // view owner @@ -86,30 +78,26 @@ void PlatformView::RegisterPlatformMessageHandlers() { std::placeholders::_1); } -mozart::ViewPtr& PlatformView::GetMozartView() { +views_v1::ViewPtr& PlatformView::GetMozartView() { return view_; } -// |mozart::ViewListener| -void PlatformView::OnPropertiesChanged( - mozart::ViewPropertiesPtr properties, - const OnPropertiesChangedCallback& callback) { - UpdateViewportMetrics(properties->view_layout); +// |views_v1::ViewListener| +void PlatformView::OnPropertiesChanged(views_v1::ViewProperties properties, + OnPropertiesChangedCallback callback) { + if (properties.view_layout) { + UpdateViewportMetrics(*properties.view_layout); + } callback(); } -void PlatformView::UpdateViewportMetrics(const mozart::ViewLayoutPtr& layout) { - if (!layout) { - return; - } - - metrics_.size.width = layout->size->width; - metrics_.size.height = layout->size->height; - - metrics_.padding.left = layout->inset->left; - metrics_.padding.top = layout->inset->top; - metrics_.padding.right = layout->inset->right; - metrics_.padding.bottom = layout->inset->bottom; +void PlatformView::UpdateViewportMetrics(const views_v1::ViewLayout& layout) { + metrics_.size.width = layout.size.width; + metrics_.size.height = layout.size.height; + metrics_.padding.left = layout.inset.left; + metrics_.padding.top = layout.inset.top; + metrics_.padding.right = layout.inset.right; + metrics_.padding.bottom = layout.inset.bottom; FlushViewportMetrics(); } @@ -150,31 +138,30 @@ void PlatformView::FlushViewportMetrics() { SetViewportMetrics(metrics); } -// |mozart::InputMethodEditorClient| -void PlatformView::DidUpdateState(mozart::TextInputStatePtr state, - mozart::InputEventPtr event) { +// |input::InputMethodEditorClient| +void PlatformView::DidUpdateState(input::TextInputState state, + std::unique_ptr) { rapidjson::Document document; auto& allocator = document.GetAllocator(); rapidjson::Value encoded_state(rapidjson::kObjectType); - encoded_state.AddMember("text", state->text.get(), allocator); - encoded_state.AddMember("selectionBase", state->selection->base, allocator); - encoded_state.AddMember("selectionExtent", state->selection->extent, - allocator); - switch (state->selection->affinity) { - case mozart::TextAffinity::UPSTREAM: + encoded_state.AddMember("text", state.text.get(), allocator); + encoded_state.AddMember("selectionBase", state.selection.base, allocator); + encoded_state.AddMember("selectionExtent", state.selection.extent, allocator); + switch (state.selection.affinity) { + case input::TextAffinity::UPSTREAM: encoded_state.AddMember("selectionAffinity", rapidjson::Value("TextAffinity.upstream"), allocator); break; - case mozart::TextAffinity::DOWNSTREAM: + case input::TextAffinity::DOWNSTREAM: encoded_state.AddMember("selectionAffinity", rapidjson::Value("TextAffinity.downstream"), allocator); break; } encoded_state.AddMember("selectionIsDirectional", true, allocator); - encoded_state.AddMember("composingBase", state->composing->start, allocator); - encoded_state.AddMember("composingExtent", state->composing->end, allocator); + encoded_state.AddMember("composingBase", state.composing.start, allocator); + encoded_state.AddMember("composingExtent", state.composing.end, allocator); rapidjson::Value args(rapidjson::kArrayType); args.PushBack(current_text_input_client_, allocator); @@ -198,8 +185,8 @@ void PlatformView::DidUpdateState(mozart::TextInputStatePtr state, ); } -// |mozart::InputMethodEditorClient| -void PlatformView::OnAction(mozart::InputMethodAction action) { +// |input::InputMethodEditorClient| +void PlatformView::OnAction(input::InputMethodAction action) { rapidjson::Document document; auto& allocator = document.GetAllocator(); @@ -226,21 +213,20 @@ void PlatformView::OnAction(mozart::InputMethodAction action) { ); } -// |mozart::InputListener| -void PlatformView::OnEvent(mozart::InputEventPtr event, - const OnEventCallback& callback) { - using Type = mozart::InputEvent::Tag; - switch (event->which()) { - case Type::POINTER: - callback(OnHandlePointerEvent(event->get_pointer())); +// |input::InputListener| +void PlatformView::OnEvent(input::InputEvent event, OnEventCallback callback) { + using Type = input::InputEvent::Tag; + switch (event.Which()) { + case Type::kPointer: + callback(OnHandlePointerEvent(event.pointer())); return; - case Type::KEYBOARD: - callback(OnHandleKeyboardEvent(event->get_keyboard())); + case Type::kKeyboard: + callback(OnHandleKeyboardEvent(event.keyboard())); return; - case Type::FOCUS: - callback(OnHandleFocusEvent(event->get_focus())); + case Type::kFocus: + callback(OnHandleFocusEvent(event.focus())); return; - case Type::__UNKNOWN__: + default: break; } @@ -248,21 +234,21 @@ void PlatformView::OnEvent(mozart::InputEventPtr event, } static blink::PointerData::Change GetChangeFromPointerEventPhase( - mozart::PointerEvent::Phase phase) { + input::PointerEventPhase phase) { switch (phase) { - case mozart::PointerEvent::Phase::ADD: + case input::PointerEventPhase::ADD: return blink::PointerData::Change::kAdd; - case mozart::PointerEvent::Phase::HOVER: + case input::PointerEventPhase::HOVER: return blink::PointerData::Change::kHover; - case mozart::PointerEvent::Phase::DOWN: + case input::PointerEventPhase::DOWN: return blink::PointerData::Change::kDown; - case mozart::PointerEvent::Phase::MOVE: + case input::PointerEventPhase::MOVE: return blink::PointerData::Change::kMove; - case mozart::PointerEvent::Phase::UP: + case input::PointerEventPhase::UP: return blink::PointerData::Change::kUp; - case mozart::PointerEvent::Phase::REMOVE: + case input::PointerEventPhase::REMOVE: return blink::PointerData::Change::kRemove; - case mozart::PointerEvent::Phase::CANCEL: + case input::PointerEventPhase::CANCEL: return blink::PointerData::Change::kCancel; default: return blink::PointerData::Change::kCancel; @@ -270,26 +256,27 @@ static blink::PointerData::Change GetChangeFromPointerEventPhase( } static blink::PointerData::DeviceKind GetKindFromPointerType( - mozart::PointerEvent::Type type) { + input::PointerEventType type) { switch (type) { - case mozart::PointerEvent::Type::TOUCH: + case input::PointerEventType::TOUCH: return blink::PointerData::DeviceKind::kTouch; - case mozart::PointerEvent::Type::MOUSE: + case input::PointerEventType::MOUSE: return blink::PointerData::DeviceKind::kMouse; default: return blink::PointerData::DeviceKind::kTouch; } } -bool PlatformView::OnHandlePointerEvent( - const mozart::PointerEventPtr& pointer) { +bool PlatformView::OnHandlePointerEvent(const input::PointerEvent& pointer) { blink::PointerData pointer_data; - pointer_data.time_stamp = pointer->event_time / 1000; - pointer_data.change = GetChangeFromPointerEventPhase(pointer->phase); - pointer_data.kind = GetKindFromPointerType(pointer->type); - pointer_data.device = pointer->pointer_id; - pointer_data.physical_x = pointer->x * metrics_.scale; - pointer_data.physical_y = pointer->y * metrics_.scale; + pointer_data.time_stamp = pointer.event_time / 1000; + pointer_data.change = GetChangeFromPointerEventPhase(pointer.phase); + pointer_data.kind = GetKindFromPointerType(pointer.type); + pointer_data.device = pointer.pointer_id; + pointer_data.physical_x = pointer.x * metrics_.scale; + pointer_data.physical_y = pointer.y * metrics_.scale; + // Buttons are single bit values starting with kMousePrimaryButton = 1. + pointer_data.buttons = static_cast(pointer.buttons); switch (pointer_data.change) { case blink::PointerData::Change::kDown: @@ -327,14 +314,13 @@ bool PlatformView::OnHandlePointerEvent( return true; } -bool PlatformView::OnHandleKeyboardEvent( - const mozart::KeyboardEventPtr& keyboard) { +bool PlatformView::OnHandleKeyboardEvent(const input::KeyboardEvent& keyboard) { const char* type = nullptr; - if (keyboard->phase == mozart::KeyboardEvent::Phase::PRESSED) { + if (keyboard.phase == input::KeyboardEventPhase::PRESSED) { type = "keydown"; - } else if (keyboard->phase == mozart::KeyboardEvent::Phase::REPEAT) { + } else if (keyboard.phase == input::KeyboardEventPhase::REPEAT) { type = "keydown"; // TODO change this to keyrepeat - } else if (keyboard->phase == mozart::KeyboardEvent::Phase::RELEASED) { + } else if (keyboard.phase == input::KeyboardEventPhase::RELEASED) { type = "keyup"; } @@ -348,9 +334,9 @@ bool PlatformView::OnHandleKeyboardEvent( document.SetObject(); document.AddMember("type", rapidjson::Value(type, strlen(type)), allocator); document.AddMember("keymap", rapidjson::Value("fuchsia"), allocator); - document.AddMember("hidUsage", keyboard->hid_usage, allocator); - document.AddMember("codePoint", keyboard->code_point, allocator); - document.AddMember("modifiers", keyboard->modifiers, allocator); + document.AddMember("hidUsage", keyboard.hid_usage, allocator); + document.AddMember("codePoint", keyboard.code_point, allocator); + document.AddMember("modifiers", keyboard.modifiers, allocator); rapidjson::StringBuffer buffer; rapidjson::Writer writer(buffer); document.Accept(writer); @@ -365,8 +351,8 @@ bool PlatformView::OnHandleKeyboardEvent( return true; } -bool PlatformView::OnHandleFocusEvent(const mozart::FocusEventPtr& focus) { - if (!focus->focused && current_text_input_client_ != 0) { +bool PlatformView::OnHandleFocusEvent(const input::FocusEvent& focus) { + if (!focus.focused && current_text_input_client_ != 0) { current_text_input_client_ = 0; if (ime_) { ime_->Hide(); @@ -434,13 +420,13 @@ void PlatformView::HandleFlutterPlatformChannelPlatformMessage( clipboard_->Push(text); response->CompleteEmpty(); } else if (method->value == "Clipboard.getData") { - clipboard_->Peek([response](const f1dl::String& text) { + clipboard_->Peek([response](fidl::StringPtr text) { rapidjson::StringBuffer json_buffer; rapidjson::Writer writer(json_buffer); writer.StartArray(); writer.StartObject(); writer.Key("text"); - writer.String(text); + writer.String(text.get()); writer.EndObject(); writer.EndArray(); std::string result = json_buffer.GetString(); @@ -491,13 +477,14 @@ void PlatformView::HandleFlutterTextInputChannelPlatformMessage( } // TODO(abarth): Read the keyboard type from the configuration. current_text_input_client_ = args->value[0].GetInt(); - mozart::TextInputStatePtr state = mozart::TextInputState::New(); - state->text = std::string(); - state->selection = mozart::TextSelection::New(); - state->composing = mozart::TextRange::New(); + input_connection_->GetInputMethodEditor( - mozart::KeyboardType::TEXT, mozart::InputMethodAction::DONE, - std::move(state), ime_client_.NewBinding(), ime_.NewRequest()); + input::KeyboardType::TEXT, // keyboard type + input::InputMethodAction::DONE, // input method action + input::TextInputState{}, // initial state + ime_client_.NewBinding(), // client + ime_.NewRequest() // editor + ); } else if (method->value == "TextInput.setEditingState") { if (ime_) { auto args_it = root.FindMember("args"); @@ -505,36 +492,34 @@ void PlatformView::HandleFlutterTextInputChannelPlatformMessage( return; } const auto& args = args_it->value; - mozart::TextInputStatePtr state = mozart::TextInputState::New(); - state->selection = mozart::TextSelection::New(); - state->composing = mozart::TextRange::New(); + input::TextInputState state; // TODO(abarth): Deserialize state. auto text = args.FindMember("text"); if (text != args.MemberEnd() && text->value.IsString()) - state->text = text->value.GetString(); + state.text = text->value.GetString(); auto selection_base = args.FindMember("selectionBase"); if (selection_base != args.MemberEnd() && selection_base->value.IsInt()) - state->selection->base = selection_base->value.GetInt(); + state.selection.base = selection_base->value.GetInt(); auto selection_extent = args.FindMember("selectionExtent"); if (selection_extent != args.MemberEnd() && selection_extent->value.IsInt()) - state->selection->extent = selection_extent->value.GetInt(); + state.selection.extent = selection_extent->value.GetInt(); auto selection_affinity = args.FindMember("selectionAffinity"); if (selection_affinity != args.MemberEnd() && selection_affinity->value.IsString() && selection_affinity->value == "TextAffinity.upstream") - state->selection->affinity = mozart::TextAffinity::UPSTREAM; + state.selection.affinity = input::TextAffinity::UPSTREAM; else - state->selection->affinity = mozart::TextAffinity::DOWNSTREAM; + state.selection.affinity = input::TextAffinity::DOWNSTREAM; // We ignore selectionIsDirectional because that concept doesn't exist on // Fuchsia. auto composing_base = args.FindMember("composingBase"); if (composing_base != args.MemberEnd() && composing_base->value.IsInt()) - state->composing->start = composing_base->value.GetInt(); + state.composing.start = composing_base->value.GetInt(); auto composing_extent = args.FindMember("composingExtent"); if (composing_extent != args.MemberEnd() && composing_extent->value.IsInt()) - state->composing->end = composing_extent->value.GetInt(); + state.composing.end = composing_extent->value.GetInt(); ime_->SetState(std::move(state)); } } else if (method->value == "TextInput.clearClient") { diff --git a/content_handler/platform_view.h b/content_handler/platform_view.h index 9888d061352bbe89bac61529dd3844f597497895..44deee166374c0bdf10daeb1a0bd0fdc17f0b50c 100644 --- a/content_handler/platform_view.h +++ b/content_handler/platform_view.h @@ -7,15 +7,16 @@ #include #include +#include +#include +#include +#include + #include "accessibility_bridge.h" #include "flutter/lib/ui/window/viewport_metrics.h" #include "flutter/shell/common/platform_view.h" -#include "lib/clipboard/fidl/clipboard.fidl.h" -#include "lib/fidl/cpp/bindings/binding.h" +#include "lib/fidl/cpp/binding.h" #include "lib/fxl/macros.h" -#include "lib/ui/input/fidl/input_connection.fidl.h" -#include "lib/ui/views/fidl/view_manager.fidl.h" -#include "lib/ui/views/fidl/views.fidl.h" #include "surface.h" namespace flutter { @@ -23,39 +24,36 @@ namespace flutter { // The per engine component residing on the platform thread is responsible for // all platform specific integrations. class PlatformView final : public shell::PlatformView, - public mozart::ViewListener, - public mozart::InputMethodEditorClient, - public mozart::InputListener { + public views_v1::ViewListener, + public input::InputMethodEditorClient, + public input::InputListener { public: PlatformView( PlatformView::Delegate& delegate, std::string debug_label, blink::TaskRunners task_runners, component::ServiceProviderPtr parent_environment_service_provider, - mozart::ViewManagerPtr& view_manager, - f1dl::InterfaceRequest view_owner, + views_v1::ViewManagerPtr& view_manager, + fidl::InterfaceRequest view_owner, ui::ScenicPtr scenic, zx::eventpair export_token, - zx::eventpair import_token, - maxwell::ContextWriterPtr accessibility_context_writer, - OnMetricsUpdate on_session_metrics_did_change, - fxl::Closure session_error_callback); + modular::ContextWriterPtr accessibility_context_writer); ~PlatformView(); void UpdateViewportMetrics(double pixel_ratio); - mozart::ViewPtr& GetMozartView(); + views_v1::ViewPtr& GetMozartView(); private: const std::string debug_label_; - mozart::ViewPtr view_; - f1dl::Binding view_listener_; - mozart::InputConnectionPtr input_connection_; - f1dl::Binding input_listener_; + views_v1::ViewPtr view_; + fidl::Binding view_listener_; + input::InputConnectionPtr input_connection_; + fidl::Binding input_listener_; int current_text_input_client_ = 0; - f1dl::Binding ime_client_; - mozart::InputMethodEditorPtr ime_; + fidl::Binding ime_client_; + input::InputMethodEditorPtr ime_; modular::ClipboardPtr clipboard_; ui::ScenicPtr scenic_; AccessibilityBridge accessibility_bridge_; @@ -70,31 +68,29 @@ class PlatformView final : public shell::PlatformView, void RegisterPlatformMessageHandlers(); - void UpdateViewportMetrics(const mozart::ViewLayoutPtr& layout); + void UpdateViewportMetrics(const views_v1::ViewLayout& layout); void FlushViewportMetrics(); - // |mozart::ViewListener| - void OnPropertiesChanged( - mozart::ViewPropertiesPtr properties, - const OnPropertiesChangedCallback& callback) override; + // |views_v1::ViewListener| + void OnPropertiesChanged(views_v1::ViewProperties properties, + OnPropertiesChangedCallback callback) override; - // |mozart::InputMethodEditorClient| - void DidUpdateState(mozart::TextInputStatePtr state, - mozart::InputEventPtr event) override; + // |input::InputMethodEditorClient| + void DidUpdateState(input::TextInputState state, + std::unique_ptr event) override; - // |mozart::InputMethodEditorClient| - void OnAction(mozart::InputMethodAction action) override; + // |input::InputMethodEditorClient| + void OnAction(input::InputMethodAction action) override; - // |mozart::InputListener| - void OnEvent(mozart::InputEventPtr event, - const OnEventCallback& callback) override; + // |input::InputListener| + void OnEvent(input::InputEvent event, OnEventCallback callback) override; - bool OnHandlePointerEvent(const mozart::PointerEventPtr& pointer); + bool OnHandlePointerEvent(const input::PointerEvent& pointer); - bool OnHandleKeyboardEvent(const mozart::KeyboardEventPtr& keyboard); + bool OnHandleKeyboardEvent(const input::KeyboardEvent& keyboard); - bool OnHandleFocusEvent(const mozart::FocusEventPtr& focus); + bool OnHandleFocusEvent(const input::FocusEvent& focus); // |shell::PlatformView| std::unique_ptr CreateRenderingSurface() override; diff --git a/content_handler/session_connection.cc b/content_handler/session_connection.cc index 870020abb670f5b7630cafaeea34e2c2f785858f..b1b6951f957992e40321cf2f2644730b85d64fcf 100644 --- a/content_handler/session_connection.cc +++ b/content_handler/session_connection.cc @@ -4,6 +4,7 @@ #include "session_connection.h" +#include "lib/fidl/cpp/optional.h" #include "lib/ui/scenic/fidl_helpers.h" namespace flutter { @@ -26,28 +27,29 @@ SessionConnection::SessionConnection( this, std::placeholders::_1)); root_node_.Bind(std::move(import_token)); - root_node_.SetEventMask(ui::gfx::kMetricsEventMask); - session_.Present(0, [](ui::PresentationInfoPtr info) {}); + root_node_.SetEventMask(gfx::kMetricsEventMask); + session_.Present(0, [](auto) {}); } SessionConnection::~SessionConnection() = default; -void SessionConnection::OnSessionEvents(f1dl::Array events) { - using Type = ui::gfx::Event::Tag; +void SessionConnection::OnSessionEvents(fidl::VectorPtr events) { + using Type = gfx::Event::Tag; for (auto& raw_event : *events) { - if (!raw_event->is_gfx()) { + if (!raw_event.is_gfx()) { continue; } - auto& event = raw_event->get_gfx(); + auto& event = raw_event.gfx(); - switch (event->which()) { - case Type::METRICS: { - if (event->get_metrics()->node_id == root_node_.id()) { - auto& metrics = event->get_metrics()->metrics; - double device_pixel_ratio = metrics->scale_x; - scene_update_context_.set_metrics(std::move(metrics)); + switch (event.Which()) { + case Type::kMetrics: { + if (event.metrics().node_id == root_node_.id()) { + auto& metrics = event.metrics().metrics; + double device_pixel_ratio = metrics.scale_x; + scene_update_context_.set_metrics( + fidl::MakeOptional(std::move(metrics))); if (metrics_changed_callback_) { metrics_changed_callback_(device_pixel_ratio); } @@ -63,8 +65,8 @@ void SessionConnection::Present(flow::CompositorContext::ScopedFrame& frame) { // Flush all session ops. Paint tasks have not yet executed but those are // fenced. The compositor can start processing ops while we finalize paint // tasks. - session_.Present(0, // presentation_time. (placeholder). - [](ui::PresentationInfoPtr) {} // callback + session_.Present(0, // presentation_time. (placeholder). + [](auto) {} // callback ); // Execute paint tasks and signal fences. diff --git a/content_handler/session_connection.h b/content_handler/session_connection.h index e4f39d314c98fc4965bed4a0c9f51cecae401c0d..3cd128b86724c3f828ece06d962da71434e9e4bd 100644 --- a/content_handler/session_connection.h +++ b/content_handler/session_connection.h @@ -8,7 +8,7 @@ #include "flutter/flow/compositor_context.h" #include "flutter/flow/scene_update_context.h" -#include "lib/fidl/cpp/bindings/interface_handle.h" +#include "lib/fidl/cpp/interface_handle.h" #include "lib/fxl/functional/closure.h" #include "lib/fxl/macros.h" #include "lib/ui/scenic/client/resources.h" @@ -33,7 +33,7 @@ class SessionConnection final { bool has_metrics() const { return scene_update_context_.has_metrics(); } - const ui::gfx::MetricsPtr& metrics() const { + const gfx::MetricsPtr& metrics() const { return scene_update_context_.metrics(); } @@ -53,7 +53,7 @@ class SessionConnection final { flow::SceneUpdateContext scene_update_context_; OnMetricsUpdate metrics_changed_callback_; - void OnSessionEvents(f1dl::Array events); + void OnSessionEvents(fidl::VectorPtr events); void EnqueueClearOps(); diff --git a/content_handler/surface.cc b/content_handler/surface.cc index 8efe1975fbfdb08bb5d2bf039f16c8f7f9c9a07e..8f3699aa04da065035a23bc942213f9220b41412 100644 --- a/content_handler/surface.cc +++ b/content_handler/surface.cc @@ -13,18 +13,8 @@ namespace flutter { -Surface::Surface(const ui::ScenicPtr& scenic, - std::string debug_label, - zx::eventpair import_token, - OnMetricsUpdate session_metrics_did_change_callback, - fxl::Closure session_error_callback) - : shell::Surface(std::make_unique( - scenic, - debug_label, - std::move(import_token), - std::move(session_metrics_did_change_callback), - std::move(session_error_callback))), - debug_label_(debug_label) {} +Surface::Surface(std::string debug_label) + : debug_label_(std::move(debug_label)) {} Surface::~Surface() = default; @@ -58,15 +48,15 @@ static zx_status_t DriverWatcher(int dirfd, } bool Surface::CanConnectToDisplay() { - constexpr char kDisplayDriverClass[] = "/dev/class/display"; - fxl::UniqueFD fd(open(kDisplayDriverClass, O_DIRECTORY | O_RDONLY)); + constexpr char kGpuDriverClass[] = "/dev/class/gpu"; + fxl::UniqueFD fd(open(kGpuDriverClass, O_DIRECTORY | O_RDONLY)); if (fd.get() < 0) { - FXL_DLOG(ERROR) << "Failed to open " << kDisplayDriverClass; + FXL_DLOG(ERROR) << "Failed to open " << kGpuDriverClass; return false; } zx_status_t status = fdio_watch_directory( - fd.get(), DriverWatcher, zx_deadline_after(ZX_SEC(1)), nullptr); + fd.get(), DriverWatcher, zx_deadline_after(ZX_SEC(5)), nullptr); return status == ZX_ERR_STOP; } diff --git a/content_handler/surface.h b/content_handler/surface.h index 4ad27aaf540f3d889773a1b11c0c7e7f138de5d6..99f4079f9c2df61ef382b874e6dcf30b700ef758 100644 --- a/content_handler/surface.h +++ b/content_handler/surface.h @@ -16,18 +16,13 @@ namespace flutter { // thread. class Surface final : public shell::Surface { public: - Surface(const ui::ScenicPtr& scenic, - std::string debug_label, - zx::eventpair import_token, - OnMetricsUpdate session_metrics_did_change_callback, - fxl::Closure session_error_callback); + Surface(std::string debug_label); ~Surface() override; private: const bool valid_ = CanConnectToDisplay(); const std::string debug_label_; - std::unique_ptr compositor_context_; // |shell::Surface| bool IsValid() override; diff --git a/content_handler/vulkan_surface.cc b/content_handler/vulkan_surface.cc index 53d0fd2da63d9205f54f1b51d785540bf2d6236b..524fa385a6dc742026e07c8c24c4267fbcb73990 100644 --- a/content_handler/vulkan_surface.cc +++ b/content_handler/vulkan_surface.cc @@ -48,11 +48,8 @@ VulkanSurface::VulkanSurface(vulkan::VulkanProvider& vulkan_provider, } VulkanSurface::~VulkanSurface() { - if (async_) { - wait_.Cancel(async_); - wait_.set_object(ZX_HANDLE_INVALID); - async_ = nullptr; - } + wait_.Cancel(); + wait_.set_object(ZX_HANDLE_INVALID); } bool VulkanSurface::IsValid() const { @@ -192,10 +189,12 @@ bool VulkanSurface::AllocateDeviceMemory(sk_sp context, break; } } + VkExportMemoryAllocateInfoKHR export_allocate_info = { .sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR, .pNext = nullptr, .handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_FUCHSIA_VMO_BIT_KHR}; + const VkMemoryAllocateInfo alloc_info = { .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .pNext = &export_allocate_info, @@ -262,12 +261,12 @@ bool VulkanSurface::SetupSkiaSurface(sk_sp context, } const GrVkImageInfo image_info = { - vk_image_, // image - {vk_memory_, 0, memory_reqs.size, 0}, // alloc - image_create_info.tiling, // tiling - image_create_info.initialLayout, // layout - image_create_info.format, // format - image_create_info.mipLevels, // level count + vk_image_, // image + {vk_memory_, 0, memory_reqs.size, 0}, // alloc + image_create_info.tiling, // tiling + image_create_info.initialLayout, // layout + image_create_info.format, // format + image_create_info.mipLevels, // level count }; GrBackendRenderTarget sk_render_target(size.width(), size.height(), 0, @@ -399,10 +398,10 @@ void VulkanSurface::Reset() { } } -async_wait_result_t VulkanSurface::OnHandleReady( - async_t* async, - zx_status_t status, - const zx_packet_signal_t* signal) { +void VulkanSurface::OnHandleReady(async_t* async, + async::WaitBase* wait, + zx_status_t status, + const zx_packet_signal_t* signal) { if (status != ZX_OK) return; FXL_DCHECK(signal->observed & ZX_EVENT_SIGNALED); diff --git a/content_handler/vulkan_surface_producer.cc b/content_handler/vulkan_surface_producer.cc index f29b0f1a8bdace07b6addd727bbab30ac3a5fc17..d6bdfe372a7761fccd5a847a83828ab56cef240c 100644 --- a/content_handler/vulkan_surface_producer.cc +++ b/content_handler/vulkan_surface_producer.cc @@ -151,13 +151,14 @@ bool VulkanSurfaceProducer::TransitionSurfacesToExternal( if (!command_buffer->Begin()) return false; - GrBackendRenderTarget backendRT = vk_surface->GetSkiaSurface()->getBackendRenderTarget( - SkSurface::kFlushRead_BackendHandleAccess); + GrBackendRenderTarget backendRT = + vk_surface->GetSkiaSurface()->getBackendRenderTarget( + SkSurface::kFlushRead_BackendHandleAccess); if (!backendRT.isValid()) { return false; } GrVkImageInfo imageInfo; - if(!backendRT.getVkImageInfo(&imageInfo)) { + if (!backendRT.getVkImageInfo(&imageInfo)) { return false; } diff --git a/fml/native_library.h b/fml/native_library.h index a52d01a3e09ad467c0fdf8668a63c910c95ce2b6..a223802b8d5df7954db63a47b409dc48c74dd09d 100644 --- a/fml/native_library.h +++ b/fml/native_library.h @@ -26,6 +26,10 @@ class NativeLibrary : public fxl::RefCountedThreadSafe { static fxl::RefPtr Create(const char* path); + static fxl::RefPtr CreateWithHandle( + Handle handle, + bool close_handle_when_done); + static fxl::RefPtr CreateForCurrentProcess(); const uint8_t* ResolveSymbol(const char* symbol); diff --git a/fml/platform/posix/native_library_posix.cc b/fml/platform/posix/native_library_posix.cc index 1255c38fc082153036eb1f4a9d206f9ba4e555bd..934d1d1a7c611be142f38f979db36cf7d78a24c2 100644 --- a/fml/platform/posix/native_library_posix.cc +++ b/fml/platform/posix/native_library_posix.cc @@ -45,6 +45,14 @@ fxl::RefPtr NativeLibrary::Create(const char* path) { return library->GetHandle() != nullptr ? library : nullptr; } +fxl::RefPtr NativeLibrary::CreateWithHandle( + Handle handle, + bool close_handle_when_done) { + auto library = + fxl::AdoptRef(new NativeLibrary(handle, close_handle_when_done)); + return library->GetHandle() != nullptr ? library : nullptr; +} + fxl::RefPtr NativeLibrary::CreateForCurrentProcess() { return fxl::AdoptRef(new NativeLibrary(RTLD_DEFAULT, false)); } diff --git a/fml/platform/win/native_library_win.cc b/fml/platform/win/native_library_win.cc index 6992f06f3e8862208105e10897a7eed34bf43a29..55da45fcd1fc017ae2067fafee1ed1054274de62 100644 --- a/fml/platform/win/native_library_win.cc +++ b/fml/platform/win/native_library_win.cc @@ -37,6 +37,14 @@ fxl::RefPtr NativeLibrary::Create(const char* path) { return library->GetHandle() != nullptr ? library : nullptr; } +fxl::RefPtr NativeLibrary::CreateWithHandle( + Handle handle, + bool close_handle_when_done) { + auto library = + fxl::AdoptRef(new NativeLibrary(handle, close_handle_when_done)); + return library->GetHandle() != nullptr ? library : nullptr; +} + fxl::RefPtr NativeLibrary::CreateForCurrentProcess() { return fxl::AdoptRef(new NativeLibrary(::GetModuleHandle(nullptr), false)); } diff --git a/lib/snapshot/BUILD.gn b/lib/snapshot/BUILD.gn index 8c568f4773c9029773aabddd7e9f0456c0534f76..1f119da0a8f457360cbc4f211d143e8653893a65 100644 --- a/lib/snapshot/BUILD.gn +++ b/lib/snapshot/BUILD.gn @@ -29,33 +29,14 @@ if (is_fuchsia) { # The sole purpose of this target is to generate a .packages file. sources = [] - dot_packages_file = "$target_gen_dir/snapshot.packages" - outputs = [ - dot_packages_file, - ] - deps = [] - foreach(dep, dart_deps) { - deps += [ "$dep($dart_toolchain)" ] - } + infer_package_name = true disable_analysis = true - script = "//build/dart/gen_dot_packages.py" - args = [ - "--out", - rebase_path(dot_packages_file, root_build_dir), - "--source-dir", - rebase_path("."), - "--root-build-dir", - rebase_path(root_build_dir), - "--root-gen-dir", - rebase_path(dart_root_gen_dir), - "--package-name", - "snapshot_root", - "--depfile", - rebase_path(depfile), - "--deps", - ] + dart_deps + deps = [ + "//topaz/public/dart/fuchsia", + "//topaz/public/dart/zircon", + ] } } @@ -148,10 +129,11 @@ action("generate_snapshot_bin") { } if (is_fuchsia) { - package_gen_dir = get_label_info(":bogus($dart_toolchain)", - "target_gen_dir") + package_gen_dir = + get_label_info(":bogus($dart_toolchain)", "target_gen_dir") package_file = "$package_gen_dir/generate_package_map.packages" - inputs += zircon_sdk_ext_files + mozart_dart_sdk_ext_files + [package_file] + inputs += + zircon_sdk_ext_files + mozart_dart_sdk_ext_files + [ package_file ] zircon_path = rebase_path(zircon_sdk_ext_lib) fuchsia_path = rebase_path(fuchsia_sdk_ext_lib) mozart_internal_path = rebase_path(mozart_dart_sdk_ext_lib) @@ -329,7 +311,7 @@ copy_entry_points_extra_json("entry_points_extra_json") { group("entry_points_json_files") { public_deps = [ - ":entry_points_json", ":entry_points_extra_json", + ":entry_points_json", ] } diff --git a/lib/ui/compositing/scene.cc b/lib/ui/compositing/scene.cc index 37514350b412ff1d418524792c14595746e51ba2..69279c1375fcdf5f193d298980da44e36455b450 100644 --- a/lib/ui/compositing/scene.cc +++ b/lib/ui/compositing/scene.cc @@ -4,7 +4,7 @@ #include "flutter/lib/ui/compositing/scene.h" -#include "flutter/fml/trace_event.h" +#include "flutter/glue/trace_event.h" #include "flutter/lib/ui/painting/image.h" #include "lib/fxl/functional/make_copyable.h" #include "lib/tonic/converter/dart_converter.h" diff --git a/shell/common/rasterizer.cc b/shell/common/rasterizer.cc index 9c1b8efd7e1cda4769dad35a927dca8373772602..db940ce9440a3a7ecb4a8f188db0a94f23e117b0 100644 --- a/shell/common/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -16,7 +16,17 @@ namespace shell { Rasterizer::Rasterizer(blink::TaskRunners task_runners) - : task_runners_(std::move(task_runners)), weak_factory_(this) {} + : Rasterizer(std::move(task_runners), + std::make_unique()) {} + +Rasterizer::Rasterizer( + blink::TaskRunners task_runners, + std::unique_ptr compositor_context) + : task_runners_(std::move(task_runners)), + compositor_context_(std::move(compositor_context)), + weak_factory_(this) { + FXL_DCHECK(compositor_context_); +} Rasterizer::~Rasterizer() = default; @@ -26,17 +36,17 @@ fml::WeakPtr Rasterizer::GetWeakPtr() const { void Rasterizer::Setup(std::unique_ptr surface) { surface_ = std::move(surface); - compositor_context_.OnGrContextCreated(); + compositor_context_->OnGrContextCreated(); } void Rasterizer::Teardown() { - compositor_context_.OnGrContextDestroyed(); + compositor_context_->OnGrContextDestroyed(); surface_.reset(); last_layer_tree_.reset(); } flow::TextureRegistry* Rasterizer::GetTextureRegistry() { - return &compositor_context_.texture_registry(); + return &compositor_context_->texture_registry(); } flow::LayerTree* Rasterizer::GetLastLayerTree() { @@ -96,12 +106,12 @@ bool Rasterizer::DrawToSurface(flow::LayerTree& layer_tree) { // There is no way for the compositor to know how long the layer tree // construction took. Fortunately, the layer tree does. Grab that time // for instrumentation. - compositor_context_.engine_time().SetLapTime(layer_tree.construction_time()); + compositor_context_->engine_time().SetLapTime(layer_tree.construction_time()); auto canvas = frame->SkiaCanvas(); auto compositor_frame = - compositor_context_.AcquireFrame(surface_->GetContext(), canvas, true); + compositor_context_->AcquireFrame(surface_->GetContext(), canvas, true); if (canvas) { canvas->clear(SK_ColorBLACK); diff --git a/shell/common/rasterizer.h b/shell/common/rasterizer.h index 79dda4ac9ceeb311cfec211cbe4fc98731090195..873b817f8db0f4ac8c58d100a18c3316ecbf502d 100644 --- a/shell/common/rasterizer.h +++ b/shell/common/rasterizer.h @@ -8,6 +8,7 @@ #include #include "flutter/common/task_runners.h" +#include "flutter/flow/compositor_context.h" #include "flutter/flow/layers/layer_tree.h" #include "flutter/fml/memory/weak_ptr.h" #include "flutter/shell/common/surface.h" @@ -21,6 +22,9 @@ class Rasterizer final { public: Rasterizer(blink::TaskRunners task_runners); + Rasterizer(blink::TaskRunners task_runners, + std::unique_ptr compositor_context); + ~Rasterizer(); void Setup(std::unique_ptr surface); @@ -62,7 +66,7 @@ class Rasterizer final { private: blink::TaskRunners task_runners_; std::unique_ptr surface_; - flow::CompositorContext compositor_context_; + std::unique_ptr compositor_context_; std::unique_ptr last_layer_tree_; fxl::Closure next_frame_callback_; fml::WeakPtrFactory weak_factory_; diff --git a/vulkan/vulkan_swapchain.cc b/vulkan/vulkan_swapchain.cc index 2eb6d6e1c7be26b0aa21658ddb8ef130fbc87d27..c59c16620fbfed7c9f201e7ac9708b23f316b0cd 100644 --- a/vulkan/vulkan_swapchain.cc +++ b/vulkan/vulkan_swapchain.cc @@ -223,12 +223,12 @@ sk_sp VulkanSwapchain::CreateSkiaSurface( } const GrVkImageInfo image_info = { - image, // image - GrVkAlloc(), // alloc - VK_IMAGE_TILING_OPTIMAL, // tiling - VK_IMAGE_LAYOUT_UNDEFINED, // layout - surface_format_.format, // format - 1, // level count + image, // image + GrVkAlloc(), // alloc + VK_IMAGE_TILING_OPTIMAL, // tiling + VK_IMAGE_LAYOUT_UNDEFINED, // layout + surface_format_.format, // format + 1, // level count }; // TODO(chinmaygarde): Setup the stencil buffer and the sampleCnt. @@ -460,7 +460,7 @@ VulkanSwapchain::AcquireResult VulkanSwapchain::AcquireSurface() { FXL_DLOG(INFO) << "Could not access surface at the image index."; return error; } - + GrBackendRenderTarget backendRT = surface->getBackendRenderTarget( SkSurface::kFlushRead_BackendHandleAccess); if (!backendRT.isValid()) {