From 294cb8fa86c575d0ff96c954704dc289b374a023 Mon Sep 17 00:00:00 2001 From: Ian McKellar Date: Tue, 22 Aug 2017 13:32:46 -0700 Subject: [PATCH] Update to new Dart FIDL bindings API. (flutter/engine#3988) * Update to new Dart FIDL bindings API. --- engine/src/flutter/flow/BUILD.gn | 1 + engine/src/flutter/flow/export_node.cc | 4 ++-- engine/src/flutter/flow/export_node.h | 3 ++- .../snapshot/fuchsia_compilation_trace.txt | 1 - engine/src/flutter/lib/ui/BUILD.gn | 3 +++ engine/src/flutter/lib/ui/compositing.dart | 8 +++++-- .../flutter/lib/ui/compositing/scene_host.cc | 23 ++++++++++++------- .../flutter/lib/ui/compositing/scene_host.h | 13 +++++++++-- .../runtime/dart_vm_entry_points_fuchsia.txt | 1 - 9 files changed, 40 insertions(+), 17 deletions(-) diff --git a/engine/src/flutter/flow/BUILD.gn b/engine/src/flutter/flow/BUILD.gn index e278ed10e0..15e4139ee3 100644 --- a/engine/src/flutter/flow/BUILD.gn +++ b/engine/src/flutter/flow/BUILD.gn @@ -71,6 +71,7 @@ source_set("flow") { deps += [ "//apps/mozart/lib/scene:client", "//apps/mozart/services/scene", + "//lib/fidl/dart/sdk_ext", ] public_deps = [ diff --git a/engine/src/flutter/flow/export_node.cc b/engine/src/flutter/flow/export_node.cc index a5462ac3c0..5a2ab94fe4 100644 --- a/engine/src/flutter/flow/export_node.cc +++ b/engine/src/flutter/flow/export_node.cc @@ -6,8 +6,8 @@ namespace flow { -ExportNode::ExportNode(uint32_t export_token_handle) - : export_token_(export_token_handle) {} +ExportNode::ExportNode(ftl::RefPtr export_token_handle) + : export_token_(export_token_handle->ReleaseHandle()) {} ExportNode::~ExportNode() { // TODO(MZ-190): Ensure the node is properly unregistered on the rasterizer diff --git a/engine/src/flutter/flow/export_node.h b/engine/src/flutter/flow/export_node.h index 7183e05ac3..31bfaf7d3b 100644 --- a/engine/src/flutter/flow/export_node.h +++ b/engine/src/flutter/flow/export_node.h @@ -11,6 +11,7 @@ #include "apps/mozart/lib/scene/client/resources.h" #include "flutter/flow/scene_update_context.h" +#include "lib/fidl/dart/sdk_ext/src/handle.h" #include "lib/ftl/build_config.h" #include "lib/ftl/macros.h" #include "lib/ftl/memory/ref_counted.h" @@ -27,7 +28,7 @@ namespace flow { // Therefore this object is thread-safe. class ExportNode : public ftl::RefCountedThreadSafe { public: - ExportNode(uint32_t export_token_handle); + ExportNode(ftl::RefPtr export_token_handle); // Binds the export token to the entity node and adds it as a child of // the specified container. diff --git a/engine/src/flutter/lib/snapshot/fuchsia_compilation_trace.txt b/engine/src/flutter/lib/snapshot/fuchsia_compilation_trace.txt index 167514e76c..c2f38dab9c 100644 --- a/engine/src/flutter/lib/snapshot/fuchsia_compilation_trace.txt +++ b/engine/src/flutter/lib/snapshot/fuchsia_compilation_trace.txt @@ -1193,7 +1193,6 @@ dart:fidl.internal,HandleWaiter,asyncWait dart:fidl.internal,HandleWaiter,cancelWait dart:fidl.internal,HandleWaiter,_asyncWait dart:fidl.internal,HandleWaiter,_cancelWait -dart:fidl.internal,HandleWaiter,onWaitComplete dart:fidl.internal,HandleWaiter,get:_callback dart:fidl.internal,HandleWaiter,set:_callback dart:fidl.internal,MxStartupInfo,takeEnvironment diff --git a/engine/src/flutter/lib/ui/BUILD.gn b/engine/src/flutter/lib/ui/BUILD.gn index ef0fd76044..d22fad22cb 100644 --- a/engine/src/flutter/lib/ui/BUILD.gn +++ b/engine/src/flutter/lib/ui/BUILD.gn @@ -87,4 +87,7 @@ source_set("ui") { "//third_party/skia", "//third_party/skia:gpu", ] + if (is_fuchsia) { + deps += [ "//lib/fidl/dart/sdk_ext" ] + } } diff --git a/engine/src/flutter/lib/ui/compositing.dart b/engine/src/flutter/lib/ui/compositing.dart index fef66bcb9f..1f923404e1 100644 --- a/engine/src/flutter/lib/ui/compositing.dart +++ b/engine/src/flutter/lib/ui/compositing.dart @@ -271,11 +271,15 @@ class SceneHost extends NativeFieldWrapperClass2 { /// sending the corresponding import token (the other endpoint of the event pair) /// to the child. /// + /// The export token is a dart:fidl.internal Handle, but that type isn't + /// available here. This is called by ChildViewConnection in + /// //apps/mozart/lib/flutter/. + /// /// The scene host takes ownership of the provided export token handle. - SceneHost(int export_token_handle) { + SceneHost(dynamic export_token_handle) { _constructor(export_token_handle); } - void _constructor(int export_token_handle) native "SceneHost_constructor"; + void _constructor(dynamic export_token_handle) native "SceneHost_constructor"; /// Releases the resources associated with the child scene host. /// diff --git a/engine/src/flutter/lib/ui/compositing/scene_host.cc b/engine/src/flutter/lib/ui/compositing/scene_host.cc index 63be9f7aa6..b40d23ab08 100644 --- a/engine/src/flutter/lib/ui/compositing/scene_host.cc +++ b/engine/src/flutter/lib/ui/compositing/scene_host.cc @@ -7,9 +7,10 @@ #include "lib/tonic/dart_args.h" #include "lib/tonic/dart_binding_macros.h" #include "lib/tonic/dart_library_natives.h" +#include "lib/tonic/dart_wrappable.h" -#if defined(OS_FUCHSIA) -#include "lib/tonic/handle_table.h" +#ifdef OS_FUCHSIA +#include "lib/fidl/dart/sdk_ext/src/handle.h" #endif namespace blink { @@ -29,16 +30,22 @@ void SceneHost::RegisterNatives(tonic::DartLibraryNatives* natives) { FOR_EACH_BINDING(DART_REGISTER_NATIVE)}); } -ftl::RefPtr SceneHost::create(int export_token_handle) { +#if defined(OS_FUCHSIA) +ftl::RefPtr SceneHost::create( + ftl::RefPtr export_token_handle) { return ftl::MakeRefCounted(export_token_handle); } -SceneHost::SceneHost(int export_token_handle) { -#if defined(OS_FUCHSIA) - export_node_ = ftl::MakeRefCounted( - tonic::HandleTable::Current().Unwrap(export_token_handle)); -#endif +SceneHost::SceneHost(ftl::RefPtr export_token_handle) { + export_node_ = ftl::MakeRefCounted(export_token_handle); } +#else +ftl::RefPtr SceneHost::create(Dart_Handle export_token_handle) { + return ftl::MakeRefCounted(export_token_handle); +} + +SceneHost::SceneHost(Dart_Handle export_token_handle) {} +#endif SceneHost::~SceneHost() {} diff --git a/engine/src/flutter/lib/ui/compositing/scene_host.h b/engine/src/flutter/lib/ui/compositing/scene_host.h index 33e7ee53df..f2962a392f 100644 --- a/engine/src/flutter/lib/ui/compositing/scene_host.h +++ b/engine/src/flutter/lib/ui/compositing/scene_host.h @@ -25,7 +25,12 @@ class SceneHost : public ftl::RefCountedThreadSafe, FRIEND_MAKE_REF_COUNTED(SceneHost); public: - static ftl::RefPtr create(int export_token_handle); +#if defined(OS_FUCHSIA) + static ftl::RefPtr create( + ftl::RefPtr export_token_handle); +#else + static ftl::RefPtr create(Dart_Handle export_token_handle); +#endif ~SceneHost() override; @@ -44,7 +49,11 @@ class SceneHost : public ftl::RefCountedThreadSafe, ftl::RefPtr export_node_; #endif - explicit SceneHost(int export_token_handle); +#if defined(OS_FUCHSIA) + explicit SceneHost(ftl::RefPtr export_token_handle); +#else + explicit SceneHost(Dart_Handle export_token_handle); +#endif }; } // namespace blink diff --git a/engine/src/flutter/runtime/dart_vm_entry_points_fuchsia.txt b/engine/src/flutter/runtime/dart_vm_entry_points_fuchsia.txt index 6c93094bf5..246c17fba8 100644 --- a/engine/src/flutter/runtime/dart_vm_entry_points_fuchsia.txt +++ b/engine/src/flutter/runtime/dart_vm_entry_points_fuchsia.txt @@ -1,5 +1,4 @@ dart:fidl.internal,::,_environment dart:fidl.internal,::,_outgoingServices -dart:fidl.internal,HandleWaiter,onWaitComplete dart:mozart.internal,::,_viewContainer dart:mozart.internal,::,_context