diff --git a/DEPS b/DEPS index 3004533ca9..3b1e18b73e 100644 --- a/DEPS +++ b/DEPS @@ -125,8 +125,8 @@ deps = { 'src/garnet': Var('fuchsia_git') + '/garnet' + '@' + 'b7492b5f34e32248b164eb48ae8e67995aebda67', - 'src/topaz': - Var('fuchsia_git') + '/topaz' + '@' + '5fa651cf9cc5f338379e34964ff5dd70052f6237', + 'src/third_party/tonic': + Var('fuchsia_git') + '/tonic' + '@' + 'e586d2975fedec0aa6c3ec87de287789172a0948', 'src/third_party/benchmark': Var('fuchsia_git') + '/third_party/benchmark' + '@' + '296537bc48d380adf21567c5d736ab79f5363d22', diff --git a/engine/src/flutter/lib/io/BUILD.gn b/engine/src/flutter/lib/io/BUILD.gn index d6240a4690..21e654f209 100644 --- a/engine/src/flutter/lib/io/BUILD.gn +++ b/engine/src/flutter/lib/io/BUILD.gn @@ -12,7 +12,7 @@ source_set("io") { "//third_party/dart/runtime:dart_api", "//third_party/dart/runtime/bin:embedded_dart_io", "//garnet/public/lib/fxl", - "//topaz/lib/tonic/converter", + "//third_party/tonic", ] configs += [ diff --git a/engine/src/flutter/lib/io/dart_io.cc b/engine/src/flutter/lib/io/dart_io.cc index 07cc17cdcd..272ea58de9 100644 --- a/engine/src/flutter/lib/io/dart_io.cc +++ b/engine/src/flutter/lib/io/dart_io.cc @@ -4,10 +4,10 @@ #include "flutter/lib/io/dart_io.h" -#include "lib/tonic/converter/dart_converter.h" #include "third_party/dart/runtime/bin/crypto.h" #include "third_party/dart/runtime/bin/io_natives.h" #include "third_party/dart/runtime/include/dart_api.h" +#include "third_party/tonic/converter/dart_converter.h" using tonic::ToDart; diff --git a/engine/src/flutter/lib/ui/BUILD.gn b/engine/src/flutter/lib/ui/BUILD.gn index f58ed6d102..81d0720a18 100644 --- a/engine/src/flutter/lib/ui/BUILD.gn +++ b/engine/src/flutter/lib/ui/BUILD.gn @@ -14,6 +14,7 @@ source_set("ui") { "dart_runtime_hooks.h", "dart_ui.cc", "dart_ui.h", + "dart_wrapper.h", "isolate_name_server/isolate_name_server.cc", "isolate_name_server/isolate_name_server.h", "isolate_name_server/isolate_name_server_natives.cc", @@ -102,12 +103,13 @@ source_set("ui") { "$flutter_root/fml", "$flutter_root/glue", "$flutter_root/runtime:test_font", + "//garnet/public/lib/fxl", "//third_party/dart/runtime/bin:embedded_dart_io", "//third_party/rapidjson", "//third_party/skia", "//third_party/skia:effects", "//third_party/skia:gpu", - "//topaz/lib/tonic", + "//third_party/tonic", ] if (is_fuchsia) { deps += [ "//topaz/public/dart-pkg/zircon" ] diff --git a/engine/src/flutter/lib/ui/compositing/scene.cc b/engine/src/flutter/lib/ui/compositing/scene.cc index 69279c1375..34970914f8 100644 --- a/engine/src/flutter/lib/ui/compositing/scene.cc +++ b/engine/src/flutter/lib/ui/compositing/scene.cc @@ -7,15 +7,14 @@ #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" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" -#include "lib/tonic/dart_persistent_value.h" -#include "lib/tonic/dart_wrappable.h" -#include "lib/tonic/logging/dart_invoke.h" #include "third_party/skia/include/core/SkImageInfo.h" #include "third_party/skia/include/core/SkSurface.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" +#include "third_party/tonic/dart_persistent_value.h" +#include "third_party/tonic/logging/dart_invoke.h" namespace blink { @@ -152,7 +151,7 @@ Dart_Handle Scene::toImage(uint32_t width, image_callback = std::move(image_callback), // unref_queue = std::move(unref_queue) // ]() mutable { - auto dart_state = image_callback->dart_state().get(); + auto dart_state = image_callback->dart_state().lock(); if (!dart_state) { // The root isolate could have died in the meantime. return; diff --git a/engine/src/flutter/lib/ui/compositing/scene.h b/engine/src/flutter/lib/ui/compositing/scene.h index 92f4b5ae15..fde6849936 100644 --- a/engine/src/flutter/lib/ui/compositing/scene.h +++ b/engine/src/flutter/lib/ui/compositing/scene.h @@ -9,7 +9,7 @@ #include #include "flutter/flow/layers/layer_tree.h" -#include "lib/tonic/dart_wrappable.h" +#include "flutter/lib/ui/dart_wrapper.h" #include "third_party/skia/include/core/SkPicture.h" namespace tonic { @@ -18,8 +18,7 @@ class DartLibraryNatives; namespace blink { -class Scene : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class Scene : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(Scene); diff --git a/engine/src/flutter/lib/ui/compositing/scene_builder.cc b/engine/src/flutter/lib/ui/compositing/scene_builder.cc index fda3b8ee85..f10690b5b3 100644 --- a/engine/src/flutter/lib/ui/compositing/scene_builder.cc +++ b/engine/src/flutter/lib/ui/compositing/scene_builder.cc @@ -9,11 +9,11 @@ #include "flutter/lib/ui/ui_dart_state.h" #include "flutter/lib/ui/window/window.h" #include "lib/fxl/build_config.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" #include "third_party/skia/include/core/SkColorFilter.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" namespace blink { @@ -64,15 +64,18 @@ void SceneBuilder::pushClipRect(double left, double top, double bottom, int clipMode) { - layer_builder_->PushClipRect(SkRect::MakeLTRB(left, top, right, bottom), static_cast(clipMode)); + layer_builder_->PushClipRect(SkRect::MakeLTRB(left, top, right, bottom), + static_cast(clipMode)); } void SceneBuilder::pushClipRRect(const RRect& rrect, int clipMode) { - layer_builder_->PushClipRoundedRect(rrect.sk_rrect, static_cast(clipMode)); + layer_builder_->PushClipRoundedRect(rrect.sk_rrect, + static_cast(clipMode)); } void SceneBuilder::pushClipPath(const CanvasPath* path, int clipMode) { - layer_builder_->PushClipPath(path->path(), static_cast(clipMode)); + layer_builder_->PushClipPath(path->path(), + static_cast(clipMode)); } void SceneBuilder::pushOpacity(int alpha) { diff --git a/engine/src/flutter/lib/ui/compositing/scene_builder.h b/engine/src/flutter/lib/ui/compositing/scene_builder.h index ebbc35efa2..b26dbf6803 100644 --- a/engine/src/flutter/lib/ui/compositing/scene_builder.h +++ b/engine/src/flutter/lib/ui/compositing/scene_builder.h @@ -12,18 +12,17 @@ #include "flutter/flow/layers/layer_builder.h" #include "flutter/lib/ui/compositing/scene.h" #include "flutter/lib/ui/compositing/scene_host.h" +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/painting/image_filter.h" #include "flutter/lib/ui/painting/path.h" #include "flutter/lib/ui/painting/picture.h" #include "flutter/lib/ui/painting/rrect.h" #include "flutter/lib/ui/painting/shader.h" -#include "lib/tonic/dart_wrappable.h" -#include "lib/tonic/typed_data/float64_list.h" +#include "third_party/tonic/typed_data/float64_list.h" namespace blink { -class SceneBuilder : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class SceneBuilder : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(SceneBuilder); @@ -35,7 +34,11 @@ class SceneBuilder : public fxl::RefCountedThreadSafe, ~SceneBuilder() override; void pushTransform(const tonic::Float64List& matrix4); - void pushClipRect(double left, double right, double top, double bottom, int clipMode); + void pushClipRect(double left, + double right, + double top, + double bottom, + int clipMode); void pushClipRRect(const RRect& rrect, int clipMode); void pushClipPath(const CanvasPath* path, int clipMode); void pushOpacity(int alpha); @@ -47,7 +50,11 @@ class SceneBuilder : public fxl::RefCountedThreadSafe, double maskRectTop, double maskRectBottom, int blendMode); - void pushPhysicalShape(const CanvasPath* path, double elevation, int color, int shadowColor, int clipMode); + void pushPhysicalShape(const CanvasPath* path, + double elevation, + int color, + int shadowColor, + int clipMode); void pop(); diff --git a/engine/src/flutter/lib/ui/compositing/scene_host.cc b/engine/src/flutter/lib/ui/compositing/scene_host.cc index f5e0cfb354..3503dccd0e 100644 --- a/engine/src/flutter/lib/ui/compositing/scene_host.cc +++ b/engine/src/flutter/lib/ui/compositing/scene_host.cc @@ -5,10 +5,9 @@ #include "flutter/lib/ui/compositing/scene_host.h" #include "flutter/lib/ui/ui_dart_state.h" -#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" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" #ifdef OS_FUCHSIA #include "dart-pkg/zircon/sdk_ext/handle.h" diff --git a/engine/src/flutter/lib/ui/compositing/scene_host.h b/engine/src/flutter/lib/ui/compositing/scene_host.h index 0d142b6199..e9e4068ce1 100644 --- a/engine/src/flutter/lib/ui/compositing/scene_host.h +++ b/engine/src/flutter/lib/ui/compositing/scene_host.h @@ -7,7 +7,7 @@ #include -#include "lib/tonic/dart_wrappable.h" +#include "flutter/lib/ui/dart_wrapper.h" #if defined(OS_FUCHSIA) #include "flutter/flow/export_node.h" @@ -19,8 +19,7 @@ class DartLibraryNatives; namespace blink { -class SceneHost : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class SceneHost : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(SceneHost); diff --git a/engine/src/flutter/lib/ui/dart_runtime_hooks.cc b/engine/src/flutter/lib/ui/dart_runtime_hooks.cc index e9b3cb3239..187913df31 100644 --- a/engine/src/flutter/lib/ui/dart_runtime_hooks.cc +++ b/engine/src/flutter/lib/ui/dart_runtime_hooks.cc @@ -16,17 +16,17 @@ #include "flutter/lib/ui/ui_dart_state.h" #include "lib/fxl/build_config.h" #include "lib/fxl/logging.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_library_natives.h" -#include "lib/tonic/dart_microtask_queue.h" -#include "lib/tonic/dart_state.h" -#include "lib/tonic/logging/dart_error.h" -#include "lib/tonic/logging/dart_invoke.h" -#include "lib/tonic/scopes/dart_api_scope.h" -#include "lib/tonic/scopes/dart_isolate_scope.h" #include "third_party/dart/runtime/bin/embedded_dart_io.h" #include "third_party/dart/runtime/include/dart_api.h" #include "third_party/dart/runtime/include/dart_tools_api.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_library_natives.h" +#include "third_party/tonic/dart_microtask_queue.h" +#include "third_party/tonic/dart_state.h" +#include "third_party/tonic/logging/dart_error.h" +#include "third_party/tonic/logging/dart_invoke.h" +#include "third_party/tonic/scopes/dart_api_scope.h" +#include "third_party/tonic/scopes/dart_isolate_scope.h" #if defined(OS_ANDROID) #include diff --git a/engine/src/flutter/lib/ui/dart_runtime_hooks.h b/engine/src/flutter/lib/ui/dart_runtime_hooks.h index 4574fa9f18..b71d57beda 100644 --- a/engine/src/flutter/lib/ui/dart_runtime_hooks.h +++ b/engine/src/flutter/lib/ui/dart_runtime_hooks.h @@ -6,8 +6,8 @@ #define FLUTTER_LIB_UI_DART_RUNTIME_HOOKS_H_ #include "lib/fxl/macros.h" -#include "lib/tonic/dart_library_natives.h" #include "third_party/dart/runtime/include/dart_api.h" +#include "third_party/tonic/dart_library_natives.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/dart_ui.cc b/engine/src/flutter/lib/ui/dart_ui.cc index 306743c82f..0bf84899ce 100644 --- a/engine/src/flutter/lib/ui/dart_ui.cc +++ b/engine/src/flutter/lib/ui/dart_ui.cc @@ -26,8 +26,8 @@ #include "flutter/lib/ui/text/paragraph_builder.h" #include "flutter/lib/ui/window/window.h" #include "lib/fxl/build_config.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/logging/dart_error.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/logging/dart_error.h" using tonic::ToDart; diff --git a/engine/src/flutter/lib/ui/dart_wrapper.h b/engine/src/flutter/lib/ui/dart_wrapper.h new file mode 100644 index 0000000000..fb30369e51 --- /dev/null +++ b/engine/src/flutter/lib/ui/dart_wrapper.h @@ -0,0 +1,28 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_LIB_UI_DART_WRAPPER_H_ +#define FLUTTER_LIB_UI_DART_WRAPPER_H_ + +#include "lib/fxl/memory/ref_counted.h" +#include "third_party/tonic/dart_wrappable.h" + +namespace blink { + +template +class RefCountedDartWrappable : public fxl::RefCountedThreadSafe, + public tonic::DartWrappable { + public: + virtual void RetainDartWrappableReference() const override { + fxl::RefCountedThreadSafe::AddRef(); + } + + virtual void ReleaseDartWrappableReference() const override { + fxl::RefCountedThreadSafe::Release(); + } +}; + +} // namespace blink + +#endif // FLUTTER_LIB_UI_DART_WRAPPER_H_ diff --git a/engine/src/flutter/lib/ui/isolate_name_server/isolate_name_server_natives.cc b/engine/src/flutter/lib/ui/isolate_name_server/isolate_name_server_natives.cc index 3919f9f489..543cd168b5 100644 --- a/engine/src/flutter/lib/ui/isolate_name_server/isolate_name_server_natives.cc +++ b/engine/src/flutter/lib/ui/isolate_name_server/isolate_name_server_natives.cc @@ -7,8 +7,8 @@ #include "flutter/lib/ui/isolate_name_server/isolate_name_server.h" #include "flutter/lib/ui/isolate_name_server/isolate_name_server_natives.h" #include "flutter/lib/ui/ui_dart_state.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/painting/canvas.cc b/engine/src/flutter/lib/ui/painting/canvas.cc index 30687c3442..6365897d7f 100644 --- a/engine/src/flutter/lib/ui/painting/canvas.cc +++ b/engine/src/flutter/lib/ui/painting/canvas.cc @@ -12,13 +12,13 @@ #include "flutter/lib/ui/painting/matrix.h" #include "flutter/lib/ui/ui_dart_state.h" #include "flutter/lib/ui/window/window.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkRSXform.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" using tonic::ToDart; @@ -164,7 +164,8 @@ void Canvas::clipRect(double left, bool doAntiAlias) { if (!canvas_) return; - canvas_->clipRect(SkRect::MakeLTRB(left, top, right, bottom), clipOp, doAntiAlias); + canvas_->clipRect(SkRect::MakeLTRB(left, top, right, bottom), clipOp, + doAntiAlias); } void Canvas::clipRRect(const RRect& rrect, bool doAntiAlias) { diff --git a/engine/src/flutter/lib/ui/painting/canvas.h b/engine/src/flutter/lib/ui/painting/canvas.h index e7d875ac4b..76ed5159bb 100644 --- a/engine/src/flutter/lib/ui/painting/canvas.h +++ b/engine/src/flutter/lib/ui/painting/canvas.h @@ -5,18 +5,18 @@ #ifndef FLUTTER_LIB_UI_PAINTING_CANVAS_H_ #define FLUTTER_LIB_UI_PAINTING_CANVAS_H_ +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/painting/paint.h" #include "flutter/lib/ui/painting/path.h" #include "flutter/lib/ui/painting/picture.h" #include "flutter/lib/ui/painting/picture_recorder.h" #include "flutter/lib/ui/painting/rrect.h" #include "flutter/lib/ui/painting/vertices.h" -#include "lib/tonic/dart_wrappable.h" -#include "lib/tonic/typed_data/float32_list.h" -#include "lib/tonic/typed_data/float64_list.h" -#include "lib/tonic/typed_data/int32_list.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/utils/SkShadowUtils.h" +#include "third_party/tonic/typed_data/float32_list.h" +#include "third_party/tonic/typed_data/float64_list.h" +#include "third_party/tonic/typed_data/int32_list.h" namespace tonic { class DartLibraryNatives; @@ -25,8 +25,7 @@ class DartLibraryNatives; namespace blink { class CanvasImage; -class Canvas : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class Canvas : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(Canvas); diff --git a/engine/src/flutter/lib/ui/painting/codec.cc b/engine/src/flutter/lib/ui/painting/codec.cc index 4b52881f54..4af9a99840 100644 --- a/engine/src/flutter/lib/ui/painting/codec.cc +++ b/engine/src/flutter/lib/ui/painting/codec.cc @@ -9,13 +9,13 @@ #include "flutter/lib/ui/painting/frame_info.h" #include "lib/fxl/functional/make_copyable.h" #include "lib/fxl/logging.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" -#include "lib/tonic/dart_state.h" -#include "lib/tonic/logging/dart_invoke.h" -#include "lib/tonic/typed_data/uint8_list.h" #include "third_party/skia/include/codec/SkCodec.h" #include "third_party/skia/include/core/SkPixelRef.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" +#include "third_party/tonic/dart_state.h" +#include "third_party/tonic/logging/dart_invoke.h" +#include "third_party/tonic/typed_data/uint8_list.h" #ifdef ERROR #undef ERROR @@ -46,7 +46,7 @@ struct ImageInfo { static void InvokeCodecCallback(fxl::RefPtr codec, std::unique_ptr callback, size_t trace_id) { - tonic::DartState* dart_state = callback->dart_state().get(); + std::shared_ptr dart_state = callback->dart_state().lock(); if (!dart_state) { TRACE_FLOW_END("flutter", kInitCodecTraceTag, trace_id); return; @@ -328,7 +328,7 @@ bool copy_to(SkBitmap* dst, SkColorType dstColorType, const SkBitmap& src) { void InvokeNextFrameCallback(fxl::RefPtr frameInfo, std::unique_ptr callback, size_t trace_id) { - tonic::DartState* dart_state = callback->dart_state().get(); + std::shared_ptr dart_state = callback->dart_state().lock(); if (!dart_state) { TRACE_FLOW_END("flutter", kCodecNextFrameTraceTag, trace_id); return; @@ -473,7 +473,7 @@ Dart_Handle SingleFrameCodec::getNextFrame(Dart_Handle callback_handle) { auto callback = std::make_unique( tonic::DartState::Current(), callback_handle); - tonic::DartState* dart_state = callback->dart_state().get(); + std::shared_ptr dart_state = callback->dart_state().lock(); if (!dart_state) { return ToDart("Invalid dart state"); } diff --git a/engine/src/flutter/lib/ui/painting/codec.h b/engine/src/flutter/lib/ui/painting/codec.h index 9fdce1a8c1..54fa44b6cd 100644 --- a/engine/src/flutter/lib/ui/painting/codec.h +++ b/engine/src/flutter/lib/ui/painting/codec.h @@ -5,8 +5,8 @@ #ifndef FLUTTER_LIB_UI_PAINTING_CODEC_H_ #define FLUTTER_LIB_UI_PAINTING_CODEC_H_ +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/painting/frame_info.h" -#include "lib/tonic/dart_wrappable.h" #include "third_party/skia/include/codec/SkCodec.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkImage.h" @@ -22,8 +22,7 @@ namespace blink { // A handle to an SkCodec object. // // Doesn't mirror SkCodec's API but provides a simple sequential access API. -class Codec : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class Codec : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); public: diff --git a/engine/src/flutter/lib/ui/painting/frame_info.cc b/engine/src/flutter/lib/ui/painting/frame_info.cc index 81c7c277d1..03af5b4feb 100644 --- a/engine/src/flutter/lib/ui/painting/frame_info.cc +++ b/engine/src/flutter/lib/ui/painting/frame_info.cc @@ -5,8 +5,8 @@ #include "flutter/lib/ui/painting/frame_info.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/painting/frame_info.h b/engine/src/flutter/lib/ui/painting/frame_info.h index 862d6f08a6..a1c6f1abbc 100644 --- a/engine/src/flutter/lib/ui/painting/frame_info.h +++ b/engine/src/flutter/lib/ui/painting/frame_info.h @@ -5,8 +5,8 @@ #ifndef FLUTTER_LIB_UI_PAINTING_FRAME_INFO_H_ #define FLUTTER_LIB_UI_PAINTING_FRAME_INFO_H_ +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/painting/image.h" -#include "lib/tonic/dart_wrappable.h" namespace tonic { class DartLibraryNatives; @@ -15,8 +15,7 @@ class DartLibraryNatives; namespace blink { // A single animation frame. -class FrameInfo final : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class FrameInfo final : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); public: diff --git a/engine/src/flutter/lib/ui/painting/gradient.cc b/engine/src/flutter/lib/ui/painting/gradient.cc index 71b2669100..9ec6f06304 100644 --- a/engine/src/flutter/lib/ui/painting/gradient.cc +++ b/engine/src/flutter/lib/ui/painting/gradient.cc @@ -6,10 +6,10 @@ #include "flutter/lib/ui/painting/gradient.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/painting/gradient.h b/engine/src/flutter/lib/ui/painting/gradient.h index 4d8e8ec091..ae695c8dda 100644 --- a/engine/src/flutter/lib/ui/painting/gradient.h +++ b/engine/src/flutter/lib/ui/painting/gradient.h @@ -5,13 +5,13 @@ #ifndef FLUTTER_LIB_UI_PAINTING_GRADIENT_H_ #define FLUTTER_LIB_UI_PAINTING_GRADIENT_H_ +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/painting/matrix.h" #include "flutter/lib/ui/painting/shader.h" -#include "lib/tonic/dart_wrappable.h" -#include "lib/tonic/typed_data/float32_list.h" -#include "lib/tonic/typed_data/float64_list.h" -#include "lib/tonic/typed_data/int32_list.h" #include "third_party/skia/include/effects/SkGradientShader.h" +#include "third_party/tonic/typed_data/float32_list.h" +#include "third_party/tonic/typed_data/float64_list.h" +#include "third_party/tonic/typed_data/int32_list.h" namespace tonic { class DartLibraryNatives; diff --git a/engine/src/flutter/lib/ui/painting/image.cc b/engine/src/flutter/lib/ui/painting/image.cc index ef45856230..d6ed502c03 100644 --- a/engine/src/flutter/lib/ui/painting/image.cc +++ b/engine/src/flutter/lib/ui/painting/image.cc @@ -5,10 +5,10 @@ #include "flutter/lib/ui/painting/image.h" #include "flutter/lib/ui/painting/image_encoding.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/painting/image.h b/engine/src/flutter/lib/ui/painting/image.h index e92db979ed..538c3af898 100644 --- a/engine/src/flutter/lib/ui/painting/image.h +++ b/engine/src/flutter/lib/ui/painting/image.h @@ -6,8 +6,8 @@ #define FLUTTER_LIB_UI_PAINTING_IMAGE_H_ #include "flutter/flow/skia_gpu_object.h" +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/ui_dart_state.h" -#include "lib/tonic/dart_wrappable.h" #include "third_party/skia/include/core/SkImage.h" namespace tonic { @@ -16,8 +16,7 @@ class DartLibraryNatives; namespace blink { -class CanvasImage final : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class CanvasImage final : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(CanvasImage); diff --git a/engine/src/flutter/lib/ui/painting/image_encoding.cc b/engine/src/flutter/lib/ui/painting/image_encoding.cc index b6ce6f4157..e403be9510 100644 --- a/engine/src/flutter/lib/ui/painting/image_encoding.cc +++ b/engine/src/flutter/lib/ui/painting/image_encoding.cc @@ -13,13 +13,13 @@ #include "flutter/lib/ui/ui_dart_state.h" #include "lib/fxl/build_config.h" #include "lib/fxl/functional/make_copyable.h" -#include "lib/tonic/dart_persistent_value.h" -#include "lib/tonic/logging/dart_invoke.h" -#include "lib/tonic/typed_data/uint8_list.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkEncodedImageFormat.h" #include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkSurface.h" +#include "third_party/tonic/dart_persistent_value.h" +#include "third_party/tonic/logging/dart_invoke.h" +#include "third_party/tonic/typed_data/uint8_list.h" using tonic::DartInvoke; using tonic::DartPersistentValue; @@ -41,7 +41,7 @@ enum ImageByteFormat { void InvokeDataCallback(std::unique_ptr callback, sk_sp buffer) { - tonic::DartState* dart_state = callback->dart_state().get(); + std::shared_ptr dart_state = callback->dart_state().lock(); if (!dart_state) { return; } diff --git a/engine/src/flutter/lib/ui/painting/image_encoding.h b/engine/src/flutter/lib/ui/painting/image_encoding.h index 2f7618db98..39e3144f12 100644 --- a/engine/src/flutter/lib/ui/painting/image_encoding.h +++ b/engine/src/flutter/lib/ui/painting/image_encoding.h @@ -5,7 +5,7 @@ #ifndef FLUTTER_LIB_UI_PAINTING_IMAGE_ENCODING_H_ #define FLUTTER_LIB_UI_PAINTING_IMAGE_ENCODING_H_ -#include "lib/tonic/dart_library_natives.h" +#include "third_party/tonic/dart_library_natives.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/painting/image_filter.cc b/engine/src/flutter/lib/ui/painting/image_filter.cc index 910b91569e..77cfeada86 100644 --- a/engine/src/flutter/lib/ui/painting/image_filter.cc +++ b/engine/src/flutter/lib/ui/painting/image_filter.cc @@ -5,13 +5,13 @@ #include "flutter/lib/ui/painting/image_filter.h" #include "flutter/lib/ui/painting/matrix.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" #include "third_party/skia/include/effects/SkBlurImageFilter.h" #include "third_party/skia/include/effects/SkImageSource.h" #include "third_party/skia/include/effects/SkPictureImageFilter.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/painting/image_filter.h b/engine/src/flutter/lib/ui/painting/image_filter.h index 0c3afa5c16..95d53ac85f 100644 --- a/engine/src/flutter/lib/ui/painting/image_filter.h +++ b/engine/src/flutter/lib/ui/painting/image_filter.h @@ -5,16 +5,15 @@ #ifndef FLUTTER_LIB_UI_PAINTING_IMAGE_FILTER_H_ #define FLUTTER_LIB_UI_PAINTING_IMAGE_FILTER_H_ +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/painting/image.h" #include "flutter/lib/ui/painting/picture.h" -#include "lib/tonic/dart_wrappable.h" -#include "lib/tonic/typed_data/float64_list.h" #include "third_party/skia/include/core/SkImageFilter.h" +#include "third_party/tonic/typed_data/float64_list.h" namespace blink { -class ImageFilter : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class ImageFilter : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(ImageFilter); diff --git a/engine/src/flutter/lib/ui/painting/image_shader.cc b/engine/src/flutter/lib/ui/painting/image_shader.cc index a4ddbba0ea..0094f565c9 100644 --- a/engine/src/flutter/lib/ui/painting/image_shader.cc +++ b/engine/src/flutter/lib/ui/painting/image_shader.cc @@ -5,10 +5,10 @@ #include "flutter/lib/ui/painting/image_shader.h" #include "flutter/lib/ui/ui_dart_state.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" using tonic::ToDart; diff --git a/engine/src/flutter/lib/ui/painting/image_shader.h b/engine/src/flutter/lib/ui/painting/image_shader.h index 1bdb310a59..6e031aebea 100644 --- a/engine/src/flutter/lib/ui/painting/image_shader.h +++ b/engine/src/flutter/lib/ui/painting/image_shader.h @@ -5,14 +5,14 @@ #ifndef FLUTTER_LIB_UI_PAINTING_IMAGE_SHADER_H_ #define FLUTTER_LIB_UI_PAINTING_IMAGE_SHADER_H_ +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/painting/gradient.h" #include "flutter/lib/ui/painting/image.h" #include "flutter/lib/ui/painting/matrix.h" #include "flutter/lib/ui/painting/shader.h" -#include "lib/tonic/dart_wrappable.h" -#include "lib/tonic/typed_data/float64_list.h" #include "third_party/skia/include/core/SkMatrix.h" #include "third_party/skia/include/core/SkShader.h" +#include "third_party/tonic/typed_data/float64_list.h" namespace tonic { class DartLibraryNatives; diff --git a/engine/src/flutter/lib/ui/painting/matrix.h b/engine/src/flutter/lib/ui/painting/matrix.h index af59739209..25307b1b38 100644 --- a/engine/src/flutter/lib/ui/painting/matrix.h +++ b/engine/src/flutter/lib/ui/painting/matrix.h @@ -5,8 +5,8 @@ #ifndef FLUTTER_LIB_UI_PAINTING_MATRIX_H_ #define FLUTTER_LIB_UI_PAINTING_MATRIX_H_ -#include "lib/tonic/typed_data/float64_list.h" #include "third_party/skia/include/core/SkMatrix.h" +#include "third_party/tonic/typed_data/float64_list.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/painting/paint.cc b/engine/src/flutter/lib/ui/painting/paint.cc index 2bb02b18bf..1c04f9781e 100644 --- a/engine/src/flutter/lib/ui/painting/paint.cc +++ b/engine/src/flutter/lib/ui/painting/paint.cc @@ -6,11 +6,11 @@ #include "flutter/lib/ui/painting/shader.h" #include "lib/fxl/logging.h" -#include "lib/tonic/typed_data/dart_byte_data.h" #include "third_party/skia/include/core/SkColorFilter.h" #include "third_party/skia/include/core/SkMaskFilter.h" #include "third_party/skia/include/core/SkShader.h" #include "third_party/skia/include/core/SkString.h" +#include "third_party/tonic/typed_data/dart_byte_data.h" namespace blink { @@ -140,7 +140,9 @@ Paint::Paint(Dart_Handle paint_objects, Dart_Handle paint_data) { namespace tonic { blink::Paint DartConverter::FromArguments( - Dart_NativeArguments args, int index, Dart_Handle& exception) { + Dart_NativeArguments args, + int index, + Dart_Handle& exception) { Dart_Handle paint_objects = Dart_GetNativeArgument(args, index); FXL_DCHECK(!LogIfError(paint_objects)); @@ -151,7 +153,9 @@ blink::Paint DartConverter::FromArguments( } blink::PaintData DartConverter::FromArguments( - Dart_NativeArguments args, int index, Dart_Handle& exception) { + Dart_NativeArguments args, + int index, + Dart_Handle& exception) { return blink::PaintData(); } diff --git a/engine/src/flutter/lib/ui/painting/paint.h b/engine/src/flutter/lib/ui/painting/paint.h index 29a0d359d2..2dd4ea14d9 100644 --- a/engine/src/flutter/lib/ui/painting/paint.h +++ b/engine/src/flutter/lib/ui/painting/paint.h @@ -5,8 +5,8 @@ #ifndef FLUTTER_LIB_UI_PAINTING_PAINT_H_ #define FLUTTER_LIB_UI_PAINTING_PAINT_H_ -#include "lib/tonic/converter/dart_converter.h" #include "third_party/skia/include/core/SkPaint.h" +#include "third_party/tonic/converter/dart_converter.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/painting/path.cc b/engine/src/flutter/lib/ui/painting/path.cc index 2ef610648e..a67ee9d2e3 100644 --- a/engine/src/flutter/lib/ui/painting/path.cc +++ b/engine/src/flutter/lib/ui/painting/path.cc @@ -8,10 +8,10 @@ #include #include "flutter/lib/ui/painting/matrix.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" using tonic::ToDart; @@ -213,9 +213,14 @@ void CanvasPath::addPath(CanvasPath* path, double dx, double dy) { path_.addPath(path->path(), dx, dy, SkPath::kAppend_AddPathMode); } -void CanvasPath::addPathWithMatrix(CanvasPath* path, double dx, double dy, tonic::Float64List& matrix4) { - if (!path) - Dart_ThrowException(ToDart("Path.addPathWithMatrix called with non-genuine Path.")); +void CanvasPath::addPathWithMatrix(CanvasPath* path, + double dx, + double dy, + tonic::Float64List& matrix4) { + if (!path) { + Dart_ThrowException( + ToDart("Path.addPathWithMatrix called with non-genuine Path.")); + } SkMatrix matrix = ToSkMatrix(matrix4); matrix.setTranslateX(matrix.getTranslateX() + dx); @@ -231,9 +236,14 @@ void CanvasPath::extendWithPath(CanvasPath* path, double dx, double dy) { path_.addPath(path->path(), dx, dy, SkPath::kExtend_AddPathMode); } -void CanvasPath::extendWithPathAndMatrix(CanvasPath* path, double dx, double dy, tonic::Float64List& matrix4) { - if (!path) - Dart_ThrowException(ToDart("Path.addPathWithMatrix called with non-genuine Path.")); +void CanvasPath::extendWithPathAndMatrix(CanvasPath* path, + double dx, + double dy, + tonic::Float64List& matrix4) { + if (!path) { + Dart_ThrowException( + ToDart("Path.addPathWithMatrix called with non-genuine Path.")); + } SkMatrix matrix = ToSkMatrix(matrix4); matrix.setTranslateX(matrix.getTranslateX() + dx); @@ -277,7 +287,6 @@ tonic::Float32List CanvasPath::getBounds() { return rect; } - bool CanvasPath::op(CanvasPath* path1, CanvasPath* path2, int operation) { return Op(path1->path(), path2->path(), (SkPathOp)operation, &path_); } diff --git a/engine/src/flutter/lib/ui/painting/path.h b/engine/src/flutter/lib/ui/painting/path.h index 69ba8d9099..c52d98cded 100644 --- a/engine/src/flutter/lib/ui/painting/path.h +++ b/engine/src/flutter/lib/ui/painting/path.h @@ -5,12 +5,12 @@ #ifndef FLUTTER_LIB_UI_PAINTING_PATH_H_ #define FLUTTER_LIB_UI_PAINTING_PATH_H_ +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/painting/rrect.h" -#include "lib/tonic/dart_wrappable.h" -#include "lib/tonic/typed_data/float32_list.h" -#include "lib/tonic/typed_data/float64_list.h" #include "third_party/skia/include/core/SkPath.h" #include "third_party/skia/include/pathops/SkPathOps.h" +#include "third_party/tonic/typed_data/float32_list.h" +#include "third_party/tonic/typed_data/float64_list.h" namespace tonic { class DartLibraryNatives; @@ -18,8 +18,7 @@ class DartLibraryNatives; namespace blink { -class CanvasPath : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class CanvasPath : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(CanvasPath); diff --git a/engine/src/flutter/lib/ui/painting/path_measure.cc b/engine/src/flutter/lib/ui/painting/path_measure.cc index e81e4b9c3b..17922325d1 100644 --- a/engine/src/flutter/lib/ui/painting/path_measure.cc +++ b/engine/src/flutter/lib/ui/painting/path_measure.cc @@ -8,10 +8,10 @@ #include #include "flutter/lib/ui/painting/matrix.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" using tonic::ToDart; diff --git a/engine/src/flutter/lib/ui/painting/path_measure.h b/engine/src/flutter/lib/ui/painting/path_measure.h index 7862081a88..db8ef6b3e3 100644 --- a/engine/src/flutter/lib/ui/painting/path_measure.h +++ b/engine/src/flutter/lib/ui/painting/path_measure.h @@ -5,11 +5,11 @@ #ifndef FLUTTER_LIB_UI_PAINTING_PATH_MEASURE_H_ #define FLUTTER_LIB_UI_PAINTING_PATH_MEASURE_H_ +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/painting/path.h" -#include "lib/tonic/dart_wrappable.h" -#include "lib/tonic/typed_data/float64_list.h" #include "third_party/skia/include/core/SkPath.h" #include "third_party/skia/include/core/SkPathMeasure.h" +#include "third_party/tonic/typed_data/float64_list.h" namespace tonic { class DartLibraryNatives; @@ -20,19 +20,21 @@ class DartLibraryNatives; namespace blink { -class CanvasPathMeasure : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class CanvasPathMeasure : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(CanvasPathMeasure); public: ~CanvasPathMeasure() override; - static fxl::RefPtr Create(const CanvasPath* path, bool forceClosed); + static fxl::RefPtr Create(const CanvasPath* path, + bool forceClosed); void setPath(const CanvasPath* path, bool isClosed); float getLength(); tonic::Float32List getPosTan(float distance); - fxl::RefPtr getSegment(float startD, float stopD, bool startWithMoveTo); + fxl::RefPtr getSegment(float startD, + float stopD, + bool startWithMoveTo); bool isClosed(); bool nextContour(); diff --git a/engine/src/flutter/lib/ui/painting/picture.cc b/engine/src/flutter/lib/ui/painting/picture.cc index 73e3a16254..096164de35 100644 --- a/engine/src/flutter/lib/ui/painting/picture.cc +++ b/engine/src/flutter/lib/ui/painting/picture.cc @@ -6,11 +6,11 @@ #include "flutter/lib/ui/painting/canvas.h" #include "flutter/lib/ui/ui_dart_state.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" #include "third_party/skia/include/core/SkImage.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/painting/picture.h b/engine/src/flutter/lib/ui/painting/picture.h index d916086b02..1578fab742 100644 --- a/engine/src/flutter/lib/ui/painting/picture.h +++ b/engine/src/flutter/lib/ui/painting/picture.h @@ -6,8 +6,8 @@ #define FLUTTER_LIB_UI_PAINTING_PICTURE_H_ #include "flutter/flow/skia_gpu_object.h" +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/painting/image.h" -#include "lib/tonic/dart_wrappable.h" #include "third_party/skia/include/core/SkPicture.h" namespace tonic { @@ -17,8 +17,7 @@ class DartLibraryNatives; namespace blink { class Canvas; -class Picture : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class Picture : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(Picture); diff --git a/engine/src/flutter/lib/ui/painting/picture_recorder.cc b/engine/src/flutter/lib/ui/painting/picture_recorder.cc index e870e400a7..af3fe130e8 100644 --- a/engine/src/flutter/lib/ui/painting/picture_recorder.cc +++ b/engine/src/flutter/lib/ui/painting/picture_recorder.cc @@ -6,10 +6,10 @@ #include "flutter/lib/ui/painting/canvas.h" #include "flutter/lib/ui/painting/picture.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/painting/picture_recorder.h b/engine/src/flutter/lib/ui/painting/picture_recorder.h index 61e83bd834..328fdefd91 100644 --- a/engine/src/flutter/lib/ui/painting/picture_recorder.h +++ b/engine/src/flutter/lib/ui/painting/picture_recorder.h @@ -5,7 +5,7 @@ #ifndef FLUTTER_LIB_UI_PAINTING_PICTURE_RECORDER_H_ #define FLUTTER_LIB_UI_PAINTING_PICTURE_RECORDER_H_ -#include "lib/tonic/dart_wrappable.h" +#include "flutter/lib/ui/dart_wrapper.h" #include "third_party/skia/include/core/SkPictureRecorder.h" namespace tonic { @@ -16,8 +16,7 @@ namespace blink { class Canvas; class Picture; -class PictureRecorder : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class PictureRecorder : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(PictureRecorder); diff --git a/engine/src/flutter/lib/ui/painting/rrect.cc b/engine/src/flutter/lib/ui/painting/rrect.cc index 3f1b6134ca..ad2d0da5e6 100644 --- a/engine/src/flutter/lib/ui/painting/rrect.cc +++ b/engine/src/flutter/lib/ui/painting/rrect.cc @@ -5,8 +5,8 @@ #include "flutter/lib/ui/painting/rrect.h" #include "lib/fxl/logging.h" -#include "lib/tonic/logging/dart_error.h" -#include "lib/tonic/typed_data/float32_list.h" +#include "third_party/tonic/logging/dart_error.h" +#include "third_party/tonic/typed_data/float32_list.h" using namespace blink; diff --git a/engine/src/flutter/lib/ui/painting/rrect.h b/engine/src/flutter/lib/ui/painting/rrect.h index 54cf8f7c1a..c06769bfec 100644 --- a/engine/src/flutter/lib/ui/painting/rrect.h +++ b/engine/src/flutter/lib/ui/painting/rrect.h @@ -5,9 +5,9 @@ #ifndef FLUTTER_LIB_UI_PAINTING_RRECT_H_ #define FLUTTER_LIB_UI_PAINTING_RRECT_H_ -#include "lib/tonic/converter/dart_converter.h" #include "third_party/dart/runtime/include/dart_api.h" #include "third_party/skia/include/core/SkRRect.h" +#include "third_party/tonic/converter/dart_converter.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/painting/shader.h b/engine/src/flutter/lib/ui/painting/shader.h index 205197250e..8b1cdb2469 100644 --- a/engine/src/flutter/lib/ui/painting/shader.h +++ b/engine/src/flutter/lib/ui/painting/shader.h @@ -6,14 +6,13 @@ #define FLUTTER_LIB_UI_PAINTING_SHADER_H_ #include "flutter/flow/skia_gpu_object.h" +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/ui_dart_state.h" -#include "lib/tonic/dart_wrappable.h" #include "third_party/skia/include/core/SkShader.h" namespace blink { -class Shader : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class Shader : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(Shader); diff --git a/engine/src/flutter/lib/ui/painting/vertices.cc b/engine/src/flutter/lib/ui/painting/vertices.cc index 24b1577a34..542451fb8d 100644 --- a/engine/src/flutter/lib/ui/painting/vertices.cc +++ b/engine/src/flutter/lib/ui/painting/vertices.cc @@ -4,8 +4,8 @@ #include "flutter/lib/ui/painting/vertices.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/painting/vertices.h b/engine/src/flutter/lib/ui/painting/vertices.h index 47b5133ae6..8178e9763b 100644 --- a/engine/src/flutter/lib/ui/painting/vertices.h +++ b/engine/src/flutter/lib/ui/painting/vertices.h @@ -5,10 +5,10 @@ #ifndef FLUTTER_LIB_UI_PAINTING_VERTICES_H_ #define FLUTTER_LIB_UI_PAINTING_VERTICES_H_ -#include "lib/tonic/dart_wrappable.h" -#include "lib/tonic/typed_data/float32_list.h" -#include "lib/tonic/typed_data/int32_list.h" +#include "flutter/lib/ui/dart_wrapper.h" #include "third_party/skia/include/core/SkVertices.h" +#include "third_party/tonic/typed_data/float32_list.h" +#include "third_party/tonic/typed_data/int32_list.h" namespace tonic { class DartLibraryNatives; @@ -16,8 +16,7 @@ class DartLibraryNatives; namespace blink { -class Vertices : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class Vertices : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(Vertices); diff --git a/engine/src/flutter/lib/ui/plugins/callback_cache.cc b/engine/src/flutter/lib/ui/plugins/callback_cache.cc index ad31891a2f..1799fcbc73 100644 --- a/engine/src/flutter/lib/ui/plugins/callback_cache.cc +++ b/engine/src/flutter/lib/ui/plugins/callback_cache.cc @@ -4,7 +4,7 @@ #include "flutter/lib/ui/plugins/callback_cache.h" #include "lib/fxl/logging.h" -#include "lib/tonic/converter/dart_converter.h" +#include "third_party/tonic/converter/dart_converter.h" using tonic::ToDart; diff --git a/engine/src/flutter/lib/ui/semantics/custom_accessibility_action.h b/engine/src/flutter/lib/ui/semantics/custom_accessibility_action.h index a5762b54af..07fe9a3c4a 100644 --- a/engine/src/flutter/lib/ui/semantics/custom_accessibility_action.h +++ b/engine/src/flutter/lib/ui/semantics/custom_accessibility_action.h @@ -5,10 +5,10 @@ #ifndef FLUTTER_LIB_UI_SEMANTICS_CUSTOM_ACCESSIBILITY_ACTION_H_ #define FLUTTER_LIB_UI_SEMANTICS_CUSTOM_ACCESSIBILITY_ACTION_H_ -#include "lib/tonic/dart_library_natives.h" -#include "lib/tonic/dart_wrappable.h" -#include "lib/tonic/typed_data/float64_list.h" -#include "lib/tonic/typed_data/int32_list.h" +#include "third_party/tonic/dart_library_natives.h" +#include "third_party/tonic/dart_wrappable.h" +#include "third_party/tonic/typed_data/float64_list.h" +#include "third_party/tonic/typed_data/int32_list.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/semantics/semantics_update.cc b/engine/src/flutter/lib/ui/semantics/semantics_update.cc index 4905d95f77..9e655b392b 100644 --- a/engine/src/flutter/lib/ui/semantics/semantics_update.cc +++ b/engine/src/flutter/lib/ui/semantics/semantics_update.cc @@ -7,10 +7,10 @@ #include #include "flutter/lib/ui/painting/matrix.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" namespace blink { @@ -23,7 +23,8 @@ DART_BIND_ALL(SemanticsUpdate, FOR_EACH_BINDING) fxl::RefPtr SemanticsUpdate::create( SemanticsNodeUpdates nodes, CustomAccessibilityActionUpdates actions) { - return fxl::MakeRefCounted(std::move(nodes), std::move(actions)); + return fxl::MakeRefCounted(std::move(nodes), + std::move(actions)); } SemanticsUpdate::SemanticsUpdate(SemanticsNodeUpdates nodes, diff --git a/engine/src/flutter/lib/ui/semantics/semantics_update.h b/engine/src/flutter/lib/ui/semantics/semantics_update.h index f6773239f4..f6984fea6e 100644 --- a/engine/src/flutter/lib/ui/semantics/semantics_update.h +++ b/engine/src/flutter/lib/ui/semantics/semantics_update.h @@ -5,9 +5,9 @@ #ifndef FLUTTER_LIB_UI_SEMANTICS_SEMANTICS_UPDATE_H_ #define FLUTTER_LIB_UI_SEMANTICS_SEMANTICS_UPDATE_H_ -#include "flutter/lib/ui/semantics/semantics_node.h" +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/semantics/custom_accessibility_action.h" -#include "lib/tonic/dart_wrappable.h" +#include "flutter/lib/ui/semantics/semantics_node.h" namespace tonic { class DartLibraryNatives; @@ -15,15 +15,15 @@ class DartLibraryNatives; namespace blink { -class SemanticsUpdate : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class SemanticsUpdate : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(SemanticsUpdate); public: ~SemanticsUpdate() override; - static fxl::RefPtr create(SemanticsNodeUpdates nodes, - CustomAccessibilityActionUpdates actions); + static fxl::RefPtr create( + SemanticsNodeUpdates nodes, + CustomAccessibilityActionUpdates actions); SemanticsNodeUpdates takeNodes(); diff --git a/engine/src/flutter/lib/ui/semantics/semantics_update_builder.cc b/engine/src/flutter/lib/ui/semantics/semantics_update_builder.cc index c39423a358..6950250761 100644 --- a/engine/src/flutter/lib/ui/semantics/semantics_update_builder.cc +++ b/engine/src/flutter/lib/ui/semantics/semantics_update_builder.cc @@ -4,10 +4,10 @@ #include "flutter/lib/ui/semantics/semantics_update_builder.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" namespace blink { @@ -17,8 +17,8 @@ static void SemanticsUpdateBuilder_constructor(Dart_NativeArguments args) { IMPLEMENT_WRAPPERTYPEINFO(ui, SemanticsUpdateBuilder); -#define FOR_EACH_BINDING(V) \ - V(SemanticsUpdateBuilder, updateNode) \ +#define FOR_EACH_BINDING(V) \ + V(SemanticsUpdateBuilder, updateNode) \ V(SemanticsUpdateBuilder, updateCustomAction) \ V(SemanticsUpdateBuilder, build) @@ -35,28 +35,29 @@ SemanticsUpdateBuilder::SemanticsUpdateBuilder() = default; SemanticsUpdateBuilder::~SemanticsUpdateBuilder() = default; -void SemanticsUpdateBuilder::updateNode(int id, - int flags, - int actions, - int textSelectionBase, - int textSelectionExtent, - double scrollPosition, - double scrollExtentMax, - double scrollExtentMin, - double left, - double top, - double right, - double bottom, - std::string label, - std::string hint, - std::string value, - std::string increasedValue, - std::string decreasedValue, - int textDirection, - const tonic::Float64List& transform, - const tonic::Int32List& childrenInTraversalOrder, - const tonic::Int32List& childrenInHitTestOrder, - const tonic::Int32List& localContextActions) { +void SemanticsUpdateBuilder::updateNode( + int id, + int flags, + int actions, + int textSelectionBase, + int textSelectionExtent, + double scrollPosition, + double scrollExtentMax, + double scrollExtentMin, + double left, + double top, + double right, + double bottom, + std::string label, + std::string hint, + std::string value, + std::string increasedValue, + std::string decreasedValue, + int textDirection, + const tonic::Float64List& transform, + const tonic::Int32List& childrenInTraversalOrder, + const tonic::Int32List& childrenInHitTestOrder, + const tonic::Int32List& localContextActions) { SemanticsNode node; node.id = id; node.flags = flags; @@ -74,17 +75,20 @@ void SemanticsUpdateBuilder::updateNode(int id, node.decreasedValue = decreasedValue; node.textDirection = textDirection; node.transform.setColMajord(transform.data()); - node.childrenInTraversalOrder = std::vector( - childrenInTraversalOrder.data(), childrenInTraversalOrder.data() + childrenInTraversalOrder.num_elements()); + node.childrenInTraversalOrder = + std::vector(childrenInTraversalOrder.data(), + childrenInTraversalOrder.data() + + childrenInTraversalOrder.num_elements()); node.childrenInHitTestOrder = std::vector( - childrenInHitTestOrder.data(), childrenInHitTestOrder.data() + childrenInHitTestOrder.num_elements()); + childrenInHitTestOrder.data(), + childrenInHitTestOrder.data() + childrenInHitTestOrder.num_elements()); node.customAccessibilityActions = std::vector( - localContextActions.data(), localContextActions.data() + localContextActions.num_elements()); + localContextActions.data(), + localContextActions.data() + localContextActions.num_elements()); nodes_[id] = node; } -void SemanticsUpdateBuilder::updateCustomAction(int id, - std::string label) { +void SemanticsUpdateBuilder::updateCustomAction(int id, std::string label) { CustomAccessibilityAction action; action.id = id; action.label = label; diff --git a/engine/src/flutter/lib/ui/semantics/semantics_update_builder.h b/engine/src/flutter/lib/ui/semantics/semantics_update_builder.h index 307590b573..b02a1d1a4d 100644 --- a/engine/src/flutter/lib/ui/semantics/semantics_update_builder.h +++ b/engine/src/flutter/lib/ui/semantics/semantics_update_builder.h @@ -5,16 +5,15 @@ #ifndef FLUTTER_LIB_UI_SEMANTICS_SEMANTICS_UPDATE_BUILDER_H_ #define FLUTTER_LIB_UI_SEMANTICS_SEMANTICS_UPDATE_BUILDER_H_ +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/semantics/semantics_update.h" -#include "lib/tonic/dart_wrappable.h" -#include "lib/tonic/typed_data/float64_list.h" -#include "lib/tonic/typed_data/int32_list.h" +#include "third_party/tonic/typed_data/float64_list.h" +#include "third_party/tonic/typed_data/int32_list.h" namespace blink { class SemanticsUpdateBuilder - : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { + : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(SemanticsUpdateBuilder); diff --git a/engine/src/flutter/lib/ui/text/paragraph.cc b/engine/src/flutter/lib/ui/text/paragraph.cc index 22871b9947..b26b0b94f0 100644 --- a/engine/src/flutter/lib/ui/text/paragraph.cc +++ b/engine/src/flutter/lib/ui/text/paragraph.cc @@ -8,10 +8,10 @@ #include "flutter/common/task_runners.h" #include "lib/fxl/logging.h" #include "lib/fxl/tasks/task_runner.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" using tonic::ToDart; diff --git a/engine/src/flutter/lib/ui/text/paragraph.h b/engine/src/flutter/lib/ui/text/paragraph.h index 473e9bb9dd..2b6ebf561f 100644 --- a/engine/src/flutter/lib/ui/text/paragraph.h +++ b/engine/src/flutter/lib/ui/text/paragraph.h @@ -6,12 +6,12 @@ #define FLUTTER_LIB_UI_TEXT_PARAGRAPH_H_ #include "flutter/fml/message_loop.h" +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/painting/canvas.h" #include "flutter/lib/ui/text/paragraph_impl.h" #include "flutter/lib/ui/text/paragraph_impl_txt.h" #include "flutter/lib/ui/text/text_box.h" #include "flutter/third_party/txt/src/txt/paragraph.h" -#include "lib/tonic/dart_wrappable.h" namespace tonic { class DartLibraryNatives; @@ -19,8 +19,7 @@ class DartLibraryNatives; namespace blink { -class Paragraph : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class Paragraph : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(Paragraph); diff --git a/engine/src/flutter/lib/ui/text/paragraph_builder.cc b/engine/src/flutter/lib/ui/text/paragraph_builder.cc index 80cc817c1b..47c97e6aab 100644 --- a/engine/src/flutter/lib/ui/text/paragraph_builder.cc +++ b/engine/src/flutter/lib/ui/text/paragraph_builder.cc @@ -15,11 +15,11 @@ #include "flutter/third_party/txt/src/txt/text_decoration.h" #include "flutter/third_party/txt/src/txt/text_style.h" #include "lib/fxl/tasks/task_runner.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_binding_macros.h" -#include "lib/tonic/dart_library_natives.h" #include "third_party/icu/source/common/unicode/ustring.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_binding_macros.h" +#include "third_party/tonic/dart_library_natives.h" namespace blink { namespace { diff --git a/engine/src/flutter/lib/ui/text/paragraph_builder.h b/engine/src/flutter/lib/ui/text/paragraph_builder.h index 723c3d78fd..82d88cc3ee 100644 --- a/engine/src/flutter/lib/ui/text/paragraph_builder.h +++ b/engine/src/flutter/lib/ui/text/paragraph_builder.h @@ -6,11 +6,11 @@ #define FLUTTER_LIB_UI_TEXT_PARAGRAPH_BUILDER_H_ #include +#include "flutter/lib/ui/dart_wrapper.h" #include "flutter/lib/ui/painting/paint.h" #include "flutter/lib/ui/text/paragraph.h" #include "flutter/third_party/txt/src/txt/paragraph_builder.h" -#include "lib/tonic/dart_wrappable.h" -#include "lib/tonic/typed_data/int32_list.h" +#include "third_party/tonic/typed_data/int32_list.h" namespace tonic { class DartLibraryNatives; @@ -20,8 +20,7 @@ namespace blink { class Paragraph; -class ParagraphBuilder : public fxl::RefCountedThreadSafe, - public tonic::DartWrappable { +class ParagraphBuilder : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FRIEND_MAKE_REF_COUNTED(ParagraphBuilder); diff --git a/engine/src/flutter/lib/ui/text/paragraph_impl_txt.cc b/engine/src/flutter/lib/ui/text/paragraph_impl_txt.cc index 28c6ea19a8..374f8d95d7 100644 --- a/engine/src/flutter/lib/ui/text/paragraph_impl_txt.cc +++ b/engine/src/flutter/lib/ui/text/paragraph_impl_txt.cc @@ -9,8 +9,8 @@ #include "flutter/lib/ui/text/paragraph_impl.h" #include "lib/fxl/logging.h" #include "lib/fxl/tasks/task_runner.h" -#include "lib/tonic/converter/dart_converter.h" #include "third_party/skia/include/core/SkPoint.h" +#include "third_party/tonic/converter/dart_converter.h" using tonic::ToDart; diff --git a/engine/src/flutter/lib/ui/text/text_box.cc b/engine/src/flutter/lib/ui/text/text_box.cc index 5c9c269351..6cfdab2bfb 100644 --- a/engine/src/flutter/lib/ui/text/text_box.cc +++ b/engine/src/flutter/lib/ui/text/text_box.cc @@ -5,9 +5,9 @@ #include "flutter/lib/ui/text/text_box.h" #include "lib/fxl/logging.h" -#include "lib/tonic/dart_class_library.h" -#include "lib/tonic/dart_state.h" -#include "lib/tonic/logging/dart_error.h" +#include "third_party/tonic/dart_class_library.h" +#include "third_party/tonic/dart_state.h" +#include "third_party/tonic/logging/dart_error.h" using namespace blink; diff --git a/engine/src/flutter/lib/ui/text/text_box.h b/engine/src/flutter/lib/ui/text/text_box.h index d7acd3e507..839142ddcb 100644 --- a/engine/src/flutter/lib/ui/text/text_box.h +++ b/engine/src/flutter/lib/ui/text/text_box.h @@ -5,9 +5,9 @@ #ifndef FLUTTER_LIB_UI_TEXT_TEXT_BOX_H_ #define FLUTTER_LIB_UI_TEXT_TEXT_BOX_H_ -#include "lib/tonic/converter/dart_converter.h" #include "third_party/dart/runtime/include/dart_api.h" #include "third_party/skia/include/core/SkRect.h" +#include "third_party/tonic/converter/dart_converter.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/ui_dart_state.cc b/engine/src/flutter/lib/ui/ui_dart_state.cc index 24de9180ed..863870f4b2 100644 --- a/engine/src/flutter/lib/ui/ui_dart_state.cc +++ b/engine/src/flutter/lib/ui/ui_dart_state.cc @@ -6,8 +6,8 @@ #include "flutter/fml/message_loop.h" #include "flutter/lib/ui/window/window.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_message_handler.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_message_handler.h" using tonic::ToDart; diff --git a/engine/src/flutter/lib/ui/ui_dart_state.h b/engine/src/flutter/lib/ui/ui_dart_state.h index 88b56b2cf0..597031ca7b 100644 --- a/engine/src/flutter/lib/ui/ui_dart_state.h +++ b/engine/src/flutter/lib/ui/ui_dart_state.h @@ -15,11 +15,11 @@ #include "flutter/fml/memory/weak_ptr.h" #include "flutter/lib/ui/isolate_name_server/isolate_name_server.h" #include "lib/fxl/build_config.h" -#include "lib/tonic/dart_microtask_queue.h" -#include "lib/tonic/dart_persistent_value.h" -#include "lib/tonic/dart_state.h" #include "third_party/dart/runtime/include/dart_api.h" #include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/tonic/dart_microtask_queue.h" +#include "third_party/tonic/dart_persistent_value.h" +#include "third_party/tonic/dart_state.h" namespace blink { class FontSelector; diff --git a/engine/src/flutter/lib/ui/window/platform_message_response_dart.cc b/engine/src/flutter/lib/ui/window/platform_message_response_dart.cc index 59660fe8d1..f6c21b5d5a 100644 --- a/engine/src/flutter/lib/ui/window/platform_message_response_dart.cc +++ b/engine/src/flutter/lib/ui/window/platform_message_response_dart.cc @@ -9,8 +9,8 @@ #include "flutter/common/task_runners.h" #include "flutter/lib/ui/window/window.h" #include "lib/fxl/functional/make_copyable.h" -#include "lib/tonic/dart_state.h" -#include "lib/tonic/logging/dart_invoke.h" +#include "third_party/tonic/dart_state.h" +#include "third_party/tonic/logging/dart_invoke.h" namespace blink { @@ -55,10 +55,8 @@ PlatformMessageResponseDart::PlatformMessageResponseDart( PlatformMessageResponseDart::~PlatformMessageResponseDart() { if (!callback_.is_empty()) { - ui_task_runner_->PostTask( - fxl::MakeCopyable([callback = std::move(callback_)]() mutable { - callback.Clear(); - })); + ui_task_runner_->PostTask(fxl::MakeCopyable( + [callback = std::move(callback_)]() mutable { callback.Clear(); })); } } @@ -68,8 +66,9 @@ void PlatformMessageResponseDart::Complete(std::unique_ptr data) { FXL_DCHECK(!is_complete_); is_complete_ = true; ui_task_runner_->PostTask(fxl::MakeCopyable( - [ callback = std::move(callback_), data = std::move(data) ]() mutable { - tonic::DartState* dart_state = callback.dart_state().get(); + [callback = std::move(callback_), data = std::move(data)]() mutable { + std::shared_ptr dart_state = + callback.dart_state().lock(); if (!dart_state) return; tonic::DartState::Scope scope(dart_state); @@ -86,7 +85,8 @@ void PlatformMessageResponseDart::CompleteEmpty() { is_complete_ = true; ui_task_runner_->PostTask( fxl::MakeCopyable([callback = std::move(callback_)]() mutable { - tonic::DartState* dart_state = callback.dart_state().get(); + std::shared_ptr dart_state = + callback.dart_state().lock(); if (!dart_state) return; tonic::DartState::Scope scope(dart_state); diff --git a/engine/src/flutter/lib/ui/window/platform_message_response_dart.h b/engine/src/flutter/lib/ui/window/platform_message_response_dart.h index 1d65c82b65..bb29df7446 100644 --- a/engine/src/flutter/lib/ui/window/platform_message_response_dart.h +++ b/engine/src/flutter/lib/ui/window/platform_message_response_dart.h @@ -7,7 +7,7 @@ #include "flutter/fml/message_loop.h" #include "flutter/lib/ui/window/platform_message_response.h" -#include "lib/tonic/dart_persistent_value.h" +#include "third_party/tonic/dart_persistent_value.h" namespace blink { diff --git a/engine/src/flutter/lib/ui/window/window.cc b/engine/src/flutter/lib/ui/window/window.cc index 3afbe602ad..160a9f2e03 100644 --- a/engine/src/flutter/lib/ui/window/window.cc +++ b/engine/src/flutter/lib/ui/window/window.cc @@ -7,12 +7,12 @@ #include "flutter/lib/ui/compositing/scene.h" #include "flutter/lib/ui/ui_dart_state.h" #include "flutter/lib/ui/window/platform_message_response_dart.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_args.h" -#include "lib/tonic/dart_library_natives.h" -#include "lib/tonic/dart_microtask_queue.h" -#include "lib/tonic/logging/dart_invoke.h" -#include "lib/tonic/typed_data/dart_byte_data.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/dart_library_natives.h" +#include "third_party/tonic/dart_microtask_queue.h" +#include "third_party/tonic/logging/dart_invoke.h" +#include "third_party/tonic/typed_data/dart_byte_data.h" using tonic::DartInvokeField; using tonic::DartState; @@ -142,7 +142,7 @@ void Window::DidCreateIsolate() { void Window::UpdateWindowMetrics(const ViewportMetrics& metrics) { viewport_metrics_ = metrics; - tonic::DartState* dart_state = library_.dart_state().get(); + std::shared_ptr dart_state = library_.dart_state().lock(); if (!dart_state) return; tonic::DartState::Scope scope(dart_state); @@ -164,7 +164,7 @@ void Window::UpdateWindowMetrics(const ViewportMetrics& metrics) { void Window::UpdateLocale(const std::string& language_code, const std::string& country_code) { - tonic::DartState* dart_state = library_.dart_state().get(); + std::shared_ptr dart_state = library_.dart_state().lock(); if (!dart_state) return; tonic::DartState::Scope scope(dart_state); @@ -177,7 +177,7 @@ void Window::UpdateLocale(const std::string& language_code, } void Window::UpdateUserSettingsData(const std::string& data) { - tonic::DartState* dart_state = library_.dart_state().get(); + std::shared_ptr dart_state = library_.dart_state().lock(); if (!dart_state) return; tonic::DartState::Scope scope(dart_state); @@ -189,7 +189,7 @@ void Window::UpdateUserSettingsData(const std::string& data) { } void Window::UpdateSemanticsEnabled(bool enabled) { - tonic::DartState* dart_state = library_.dart_state().get(); + std::shared_ptr dart_state = library_.dart_state().lock(); if (!dart_state) return; tonic::DartState::Scope scope(dart_state); @@ -199,7 +199,7 @@ void Window::UpdateSemanticsEnabled(bool enabled) { } void Window::UpdateAssistiveTechnologyEnabled(bool enabled) { - tonic::DartState* dart_state = library_.dart_state().get(); + std::shared_ptr dart_state = library_.dart_state().lock(); if (!dart_state) return; tonic::DartState::Scope scope(dart_state); @@ -209,7 +209,7 @@ void Window::UpdateAssistiveTechnologyEnabled(bool enabled) { } void Window::DispatchPlatformMessage(fxl::RefPtr message) { - tonic::DartState* dart_state = library_.dart_state().get(); + std::shared_ptr dart_state = library_.dart_state().lock(); if (!dart_state) return; tonic::DartState::Scope scope(dart_state); @@ -230,7 +230,7 @@ void Window::DispatchPlatformMessage(fxl::RefPtr message) { } void Window::DispatchPointerDataPacket(const PointerDataPacket& packet) { - tonic::DartState* dart_state = library_.dart_state().get(); + std::shared_ptr dart_state = library_.dart_state().lock(); if (!dart_state) return; tonic::DartState::Scope scope(dart_state); @@ -245,7 +245,7 @@ void Window::DispatchPointerDataPacket(const PointerDataPacket& packet) { void Window::DispatchSemanticsAction(int32_t id, SemanticsAction action, std::vector args) { - tonic::DartState* dart_state = library_.dart_state().get(); + std::shared_ptr dart_state = library_.dart_state().lock(); if (!dart_state) return; tonic::DartState::Scope scope(dart_state); @@ -261,7 +261,7 @@ void Window::DispatchSemanticsAction(int32_t id, } void Window::BeginFrame(fxl::TimePoint frameTime) { - tonic::DartState* dart_state = library_.dart_state().get(); + std::shared_ptr dart_state = library_.dart_state().lock(); if (!dart_state) return; tonic::DartState::Scope scope(dart_state); diff --git a/engine/src/flutter/lib/ui/window/window.h b/engine/src/flutter/lib/ui/window/window.h index e10fb8503a..650bb18f2e 100644 --- a/engine/src/flutter/lib/ui/window/window.h +++ b/engine/src/flutter/lib/ui/window/window.h @@ -12,8 +12,8 @@ #include "flutter/lib/ui/window/pointer_data_packet.h" #include "flutter/lib/ui/window/viewport_metrics.h" #include "lib/fxl/time/time_point.h" -#include "lib/tonic/dart_persistent_value.h" #include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/tonic/dart_persistent_value.h" namespace tonic { class DartLibraryNatives; diff --git a/engine/src/flutter/runtime/BUILD.gn b/engine/src/flutter/runtime/BUILD.gn index 7ec76542fb..fd649a3448 100644 --- a/engine/src/flutter/runtime/BUILD.gn +++ b/engine/src/flutter/runtime/BUILD.gn @@ -99,7 +99,7 @@ source_set("runtime") { "//third_party/dart/runtime/bin:embedded_dart_io", "//third_party/rapidjson", "//third_party/skia", - "//topaz/lib/tonic", + "//third_party/tonic", ] public_configs = [ "$flutter_root:config" ] @@ -134,7 +134,7 @@ executable("runtime_unittests") { "//garnet/public/lib/fxl", "//third_party/dart/runtime:libdart_jit", "//third_party/skia", - "//topaz/lib/tonic", + "//third_party/tonic", ] if (is_linux) { diff --git a/engine/src/flutter/runtime/dart_isolate.cc b/engine/src/flutter/runtime/dart_isolate.cc index 1b887a7748..bd2c235054 100644 --- a/engine/src/flutter/runtime/dart_isolate.cc +++ b/engine/src/flutter/runtime/dart_isolate.cc @@ -14,17 +14,17 @@ #include "flutter/runtime/dart_service_isolate.h" #include "flutter/runtime/dart_vm.h" #include "lib/fxl/files/path.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_class_library.h" -#include "lib/tonic/dart_class_provider.h" -#include "lib/tonic/dart_message_handler.h" -#include "lib/tonic/dart_state.h" -#include "lib/tonic/dart_sticky_error.h" -#include "lib/tonic/file_loader/file_loader.h" -#include "lib/tonic/scopes/dart_api_scope.h" -#include "lib/tonic/scopes/dart_isolate_scope.h" #include "third_party/dart/runtime/include/dart_api.h" #include "third_party/dart/runtime/include/dart_tools_api.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_class_library.h" +#include "third_party/tonic/dart_class_provider.h" +#include "third_party/tonic/dart_message_handler.h" +#include "third_party/tonic/dart_state.h" +#include "third_party/tonic/dart_sticky_error.h" +#include "third_party/tonic/file_loader/file_loader.h" +#include "third_party/tonic/scopes/dart_api_scope.h" +#include "third_party/tonic/scopes/dart_isolate_scope.h" #ifdef ERROR #undef ERROR @@ -32,7 +32,7 @@ namespace blink { -fml::WeakPtr DartIsolate::CreateRootIsolate( +std::weak_ptr DartIsolate::CreateRootIsolate( DartVM* vm, fxl::RefPtr isolate_snapshot, fxl::RefPtr shared_snapshot, @@ -45,25 +45,26 @@ fml::WeakPtr DartIsolate::CreateRootIsolate( Dart_IsolateFlags* flags) { TRACE_EVENT0("flutter", "DartIsolate::CreateRootIsolate"); Dart_Isolate vm_isolate = nullptr; - fml::WeakPtr embedder_isolate; + std::weak_ptr embedder_isolate; char* error = nullptr; // Since this is the root isolate, we fake a parent embedder data object. We // cannot use unique_ptr here because the destructor is private (since the // isolate lifecycle is entirely managed by the VM). - auto root_embedder_data = std::make_unique( - vm, // VM - std::move(isolate_snapshot), // isolate snapshot - std::move(shared_snapshot), // shared snapshot - task_runners, // task runners - std::move(resource_context), // resource context - std::move(unref_queue), // skia unref queue - advisory_script_uri, // advisory URI - advisory_script_entrypoint, // advisory entrypoint - nullptr // child isolate preparer will be set when this isolate is - // prepared to run - ); + auto root_embedder_data = std::make_unique>( + std::make_shared( + vm, // VM + std::move(isolate_snapshot), // isolate snapshot + std::move(shared_snapshot), // shared snapshot + task_runners, // task runners + std::move(resource_context), // resource context + std::move(unref_queue), // skia unref queue + advisory_script_uri, // advisory URI + advisory_script_entrypoint, // advisory entrypoint + nullptr // child isolate preparer will be set when this isolate is + // prepared to run + )); std::tie(vm_isolate, embedder_isolate) = CreateDartVMAndEmbedderObjectPair( advisory_script_uri.c_str(), // advisory script URI @@ -84,9 +85,11 @@ fml::WeakPtr DartIsolate::CreateRootIsolate( return {}; } - if (embedder_isolate) { + std::shared_ptr shared_embedder_isolate = + embedder_isolate.lock(); + if (shared_embedder_isolate) { // Only root isolates can interact with windows. - embedder_isolate->SetWindow(std::move(window)); + shared_embedder_isolate->SetWindow(std::move(window)); } root_embedder_data.release(); @@ -115,8 +118,7 @@ DartIsolate::DartIsolate(DartVM* vm, vm_(vm), isolate_snapshot_(std::move(isolate_snapshot)), shared_snapshot_(std::move(shared_snapshot)), - child_isolate_preparer_(std::move(child_isolate_preparer)), - weak_factory_(std::make_unique>(this)) { + child_isolate_preparer_(std::move(child_isolate_preparer)) { FXL_DCHECK(isolate_snapshot_) << "Must contain a valid isolate snapshot."; if (vm_ == nullptr) { @@ -150,7 +152,9 @@ bool DartIsolate::Initialize(Dart_Isolate dart_isolate, bool is_root_isolate) { return false; } - if (Dart_IsolateData(dart_isolate) != this) { + auto isolate_data = static_cast*>( + Dart_IsolateData(dart_isolate)); + if (isolate_data->get() != this) { return false; } @@ -168,8 +172,12 @@ bool DartIsolate::Initialize(Dart_Isolate dart_isolate, bool is_root_isolate) { if (is_root_isolate) { if (auto task_runner = GetTaskRunners().GetUITaskRunner()) { // Isolates may not have any particular thread affinity. Only initialize - // the message handler if a task runner is explicitly specified. - message_handler().Initialize(task_runner); + // the task dispatcher if a task runner is explicitly specified. + tonic::DartMessageHandler::TaskDispatcher dispatcher = + [task_runner](std::function task) { + task_runner->PostTask(task); + }; + message_handler().Initialize(dispatcher); } } @@ -576,7 +584,7 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate( flags->load_vmservice_library = true; - fml::WeakPtr weak_service_isolate = + std::weak_ptr weak_service_isolate = DartIsolate::CreateRootIsolate( vm.get(), // vm vm->GetIsolateSnapshot(), // isolate snapshot @@ -593,7 +601,8 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate( flags // flags ); - if (!weak_service_isolate) { + std::shared_ptr service_isolate = weak_service_isolate.lock(); + if (!service_isolate) { *error = strdup("Could not create the service isolate."); FXL_DLOG(ERROR) << *error; return nullptr; @@ -602,13 +611,6 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate( // The engine never holds a strong reference to the VM service isolate. Since // we are about to lose our last weak reference to it, start the VM service // while we have this reference. - DartIsolate* service_isolate = weak_service_isolate.get(); - - // The service isolate is created and destroyed on arbitrary Dart pool threads - // and can not support a weak pointer factory that must be bound to a specific - // thread. - service_isolate->ResetWeakPtrFactory(); - const bool isolate_snapshot_is_dart_2 = Dart_IsDart2Snapshot( vm->GetIsolateSnapshot()->GetData()->GetSnapshotPointer()); const bool is_preview_dart2 = @@ -642,7 +644,7 @@ Dart_Isolate DartIsolate::DartIsolateCreateCallback( const char* package_root, const char* package_config, Dart_IsolateFlags* flags, - DartIsolate* parent_embedder_isolate, + std::shared_ptr* parent_embedder_isolate, char** error) { if (parent_embedder_isolate == nullptr && strcmp(advisory_script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0) { @@ -673,28 +675,30 @@ Dart_Isolate DartIsolate::DartIsolateCreateCallback( .first; } -std::pair> +std::pair> DartIsolate::CreateDartVMAndEmbedderObjectPair( const char* advisory_script_uri, const char* advisory_script_entrypoint, const char* package_root, const char* package_config, Dart_IsolateFlags* flags, - DartIsolate* p_parent_embedder_isolate, + std::shared_ptr* p_parent_embedder_isolate, bool is_root_isolate, char** error) { TRACE_EVENT0("flutter", "DartIsolate::CreateDartVMAndEmbedderObjectPair"); - std::unique_ptr embedder_isolate{p_parent_embedder_isolate}; + std::unique_ptr> embedder_isolate( + p_parent_embedder_isolate); - if (embedder_isolate == nullptr || embedder_isolate->GetDartVM() == nullptr) { + if (embedder_isolate == nullptr || + (*embedder_isolate)->GetDartVM() == nullptr) { *error = strdup("Parent isolate did not have embedder specific callback data."); FXL_DLOG(ERROR) << *error; return {nullptr, {}}; } - DartVM* const vm = embedder_isolate->GetDartVM(); + DartVM* const vm = (*embedder_isolate)->GetDartVM(); if (!is_root_isolate) { auto raw_embedder_isolate = embedder_isolate.release(); @@ -702,17 +706,17 @@ DartIsolate::CreateDartVMAndEmbedderObjectPair( blink::TaskRunners null_task_runners(advisory_script_uri, nullptr, nullptr, nullptr, nullptr); - embedder_isolate = std::make_unique( - vm, // vm - raw_embedder_isolate->GetIsolateSnapshot(), // isolate_snapshot - raw_embedder_isolate->GetSharedSnapshot(), // shared_snapshot - null_task_runners, // task_runners - fml::WeakPtr{}, // resource_context - nullptr, // unref_queue - advisory_script_uri, // advisory_script_uri - advisory_script_entrypoint, // advisory_script_entrypoint - raw_embedder_isolate->child_isolate_preparer_ // child isolate preparer - ); + embedder_isolate = std::make_unique>( + std::make_shared( + vm, // vm + (*raw_embedder_isolate)->GetIsolateSnapshot(), // isolate_snapshot + (*raw_embedder_isolate)->GetSharedSnapshot(), // shared_snapshot + null_task_runners, // task_runners + fml::WeakPtr{}, // resource_context + nullptr, // unref_queue + advisory_script_uri, // advisory_script_uri + advisory_script_entrypoint, // advisory_script_entrypoint + (*raw_embedder_isolate)->child_isolate_preparer_)); } // Create the Dart VM isolate and give it the embedder object as the baton. @@ -728,52 +732,51 @@ DartIsolate::CreateDartVMAndEmbedderObjectPair( error // ) : Dart_CreateIsolate( - advisory_script_uri, // - advisory_script_entrypoint, // - embedder_isolate->GetIsolateSnapshot() + advisory_script_uri, advisory_script_entrypoint, + (*embedder_isolate) + ->GetIsolateSnapshot() ->GetData() - ->GetSnapshotPointer(), // - embedder_isolate->GetIsolateSnapshot() - ->GetInstructionsIfPresent(), // - embedder_isolate->GetSharedSnapshot()->GetDataIfPresent(), // - embedder_isolate->GetSharedSnapshot() - ->GetInstructionsIfPresent(), // - flags, // - embedder_isolate.get(), // - error // - ); + ->GetSnapshotPointer(), + (*embedder_isolate) + ->GetIsolateSnapshot() + ->GetInstructionsIfPresent(), + (*embedder_isolate)->GetSharedSnapshot()->GetDataIfPresent(), + (*embedder_isolate) + ->GetSharedSnapshot() + ->GetInstructionsIfPresent(), + flags, embedder_isolate.get(), error); if (isolate == nullptr) { FXL_DLOG(ERROR) << *error; return {nullptr, {}}; } - if (!embedder_isolate->Initialize(isolate, is_root_isolate)) { + if (!(*embedder_isolate)->Initialize(isolate, is_root_isolate)) { *error = strdup("Embedder could not initialize the Dart isolate."); FXL_DLOG(ERROR) << *error; return {nullptr, {}}; } - if (!embedder_isolate->LoadLibraries(is_root_isolate)) { + if (!(*embedder_isolate)->LoadLibraries(is_root_isolate)) { *error = strdup("Embedder could not load libraries in the new Dart isolate."); FXL_DLOG(ERROR) << *error; return {nullptr, {}}; } - auto weak_embedder_isolate = embedder_isolate->GetWeakIsolatePtr(); + auto weak_embedder_isolate = (*embedder_isolate)->GetWeakIsolatePtr(); // Root isolates will be setup by the engine and the service isolate (which is // also a root isolate) by the utility routines in the VM. However, secondary // isolates will be run by the VM if they are marked as runnable. if (!is_root_isolate) { - FXL_DCHECK(embedder_isolate->child_isolate_preparer_); - if (!embedder_isolate->child_isolate_preparer_(embedder_isolate.get())) { + FXL_DCHECK((*embedder_isolate)->child_isolate_preparer_); + if (!(*embedder_isolate) + ->child_isolate_preparer_((*embedder_isolate).get())) { *error = strdup("Could not prepare the child isolate to run."); FXL_DLOG(ERROR) << *error; return {nullptr, {}}; } - embedder_isolate->ResetWeakPtrFactory(); } // The ownership of the embedder object is controlled by the Dart VM. So the @@ -783,7 +786,8 @@ DartIsolate::CreateDartVMAndEmbedderObjectPair( } // |Dart_IsolateShutdownCallback| -void DartIsolate::DartIsolateShutdownCallback(DartIsolate* embedder_isolate) { +void DartIsolate::DartIsolateShutdownCallback( + std::shared_ptr* embedder_isolate) { if (!tonic::DartStickyError::IsSet()) { return; } @@ -796,7 +800,8 @@ void DartIsolate::DartIsolateShutdownCallback(DartIsolate* embedder_isolate) { } // |Dart_IsolateCleanupCallback| -void DartIsolate::DartIsolateCleanupCallback(DartIsolate* embedder_isolate) { +void DartIsolate::DartIsolateCleanupCallback( + std::shared_ptr* embedder_isolate) { delete embedder_isolate; } @@ -808,14 +813,8 @@ fxl::RefPtr DartIsolate::GetSharedSnapshot() const { return shared_snapshot_; } -fml::WeakPtr DartIsolate::GetWeakIsolatePtr() const { - return weak_factory_ ? weak_factory_->GetWeakPtr() - : fml::WeakPtr(); -} - -void DartIsolate::ResetWeakPtrFactory() { - FXL_CHECK(weak_factory_); - weak_factory_.reset(); +std::weak_ptr DartIsolate::GetWeakIsolatePtr() { + return std::static_pointer_cast(shared_from_this()); } void DartIsolate::AddIsolateShutdownCallback(fxl::Closure closure) { diff --git a/engine/src/flutter/runtime/dart_isolate.h b/engine/src/flutter/runtime/dart_isolate.h index 6ed4b04d41..b19c59fcd0 100644 --- a/engine/src/flutter/runtime/dart_isolate.h +++ b/engine/src/flutter/runtime/dart_isolate.h @@ -15,8 +15,8 @@ #include "flutter/runtime/dart_snapshot.h" #include "lib/fxl/compiler_specific.h" #include "lib/fxl/macros.h" -#include "lib/tonic/dart_state.h" #include "third_party/dart/runtime/include/dart_api.h" +#include "third_party/tonic/dart_state.h" namespace blink { class DartVM; @@ -38,7 +38,7 @@ class DartIsolate : public UIDartState { // The root isolate of a Flutter application is special because it gets Window // bindings. From the VM's perspective, this isolate is not special in any // way. - static fml::WeakPtr CreateRootIsolate( + static std::weak_ptr CreateRootIsolate( DartVM* vm, fxl::RefPtr isolate_snapshot, fxl::RefPtr shared_snapshot, @@ -93,7 +93,7 @@ class DartIsolate : public UIDartState { fxl::RefPtr GetIsolateSnapshot() const; fxl::RefPtr GetSharedSnapshot() const; - fml::WeakPtr GetWeakIsolatePtr() const; + std::weak_ptr GetWeakIsolatePtr(); private: bool LoadScriptSnapshot(std::shared_ptr mapping, @@ -125,7 +125,6 @@ class DartIsolate : public UIDartState { std::vector> kernel_buffers_; std::vector> shutdown_callbacks_; ChildIsolatePreparer child_isolate_preparer_; - std::unique_ptr> weak_factory_; FXL_WARN_UNUSED_RESULT bool Initialize(Dart_Isolate isolate, bool is_root_isolate); @@ -138,8 +137,6 @@ class DartIsolate : public UIDartState { FXL_WARN_UNUSED_RESULT bool MarkIsolateRunnable(); - void ResetWeakPtrFactory(); - // |Dart_IsolateCreateCallback| static Dart_Isolate DartIsolateCreateCallback( const char* advisory_script_uri, @@ -147,7 +144,7 @@ class DartIsolate : public UIDartState { const char* package_root, const char* package_config, Dart_IsolateFlags* flags, - DartIsolate* embedder_isolate, + std::shared_ptr* embedder_isolate, char** error); static Dart_Isolate DartCreateAndStartServiceIsolate( @@ -159,21 +156,24 @@ class DartIsolate : public UIDartState { char** error); static std::pair /* embedder */> - CreateDartVMAndEmbedderObjectPair(const char* advisory_script_uri, - const char* advisory_script_entrypoint, - const char* package_root, - const char* package_config, - Dart_IsolateFlags* flags, - DartIsolate* parent_embedder_isolate, - bool is_root_isolate, - char** error); + std::weak_ptr /* embedder */> + CreateDartVMAndEmbedderObjectPair( + const char* advisory_script_uri, + const char* advisory_script_entrypoint, + const char* package_root, + const char* package_config, + Dart_IsolateFlags* flags, + std::shared_ptr* parent_embedder_isolate, + bool is_root_isolate, + char** error); // |Dart_IsolateShutdownCallback| - static void DartIsolateShutdownCallback(DartIsolate* embedder_isolate); + static void DartIsolateShutdownCallback( + std::shared_ptr* embedder_isolate); // |Dart_IsolateCleanupCallback| - static void DartIsolateCleanupCallback(DartIsolate* embedder_isolate); + static void DartIsolateCleanupCallback( + std::shared_ptr* embedder_isolate); FXL_DISALLOW_COPY_AND_ASSIGN(DartIsolate); }; diff --git a/engine/src/flutter/runtime/dart_isolate_unittests.cc b/engine/src/flutter/runtime/dart_isolate_unittests.cc index c367484f4f..8a0de50acc 100644 --- a/engine/src/flutter/runtime/dart_isolate_unittests.cc +++ b/engine/src/flutter/runtime/dart_isolate_unittests.cc @@ -29,7 +29,7 @@ TEST_F(DartIsolateTest, RootIsolateCreationAndShutdown) { GetCurrentTaskRunner(), // GetCurrentTaskRunner() // ); - auto root_isolate = DartIsolate::CreateRootIsolate( + auto weak_isolate = DartIsolate::CreateRootIsolate( vm.get(), // vm vm->GetIsolateSnapshot(), // isolate snapshot vm->GetSharedSnapshot(), // shared snapshot @@ -40,6 +40,7 @@ TEST_F(DartIsolateTest, RootIsolateCreationAndShutdown) { "main.dart", // advisory uri "main" // advisory entrypoint ); + auto root_isolate = weak_isolate.lock(); ASSERT_TRUE(root_isolate); ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::LibrariesSetup); ASSERT_TRUE(root_isolate->Shutdown()); @@ -57,7 +58,7 @@ TEST_F(DartIsolateTest, IsolateCanAssociateSnapshot) { GetCurrentTaskRunner(), // GetCurrentTaskRunner() // ); - auto root_isolate = DartIsolate::CreateRootIsolate( + auto weak_isolate = DartIsolate::CreateRootIsolate( vm.get(), // vm vm->GetIsolateSnapshot(), // isolate snapshot vm->GetSharedSnapshot(), // shared snapshot @@ -68,6 +69,7 @@ TEST_F(DartIsolateTest, IsolateCanAssociateSnapshot) { "main.dart", // advisory uri "main" // advisory entrypoint ); + auto root_isolate = weak_isolate.lock(); ASSERT_TRUE(root_isolate); ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::LibrariesSetup); ASSERT_TRUE(root_isolate->PrepareForRunningFromSource( @@ -88,7 +90,7 @@ TEST_F(DartIsolateTest, CanResolveAndInvokeMethod) { GetCurrentTaskRunner(), // GetCurrentTaskRunner() // ); - auto root_isolate = DartIsolate::CreateRootIsolate( + auto weak_isolate = DartIsolate::CreateRootIsolate( vm.get(), // vm vm->GetIsolateSnapshot(), // isolate snapshot vm->GetSharedSnapshot(), // shared snapshot @@ -99,6 +101,7 @@ TEST_F(DartIsolateTest, CanResolveAndInvokeMethod) { "main.dart", // advisory uri "main" // advisory entrypoint ); + auto root_isolate = weak_isolate.lock(); ASSERT_TRUE(root_isolate); ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::LibrariesSetup); ASSERT_TRUE(root_isolate->PrepareForRunningFromSource( diff --git a/engine/src/flutter/runtime/dart_service_isolate.cc b/engine/src/flutter/runtime/dart_service_isolate.cc index 3239e4f437..212b880687 100644 --- a/engine/src/flutter/runtime/dart_service_isolate.cc +++ b/engine/src/flutter/runtime/dart_service_isolate.cc @@ -8,10 +8,10 @@ #include "flutter/runtime/embedder_resources.h" #include "lib/fxl/logging.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_library_natives.h" -#include "lib/tonic/logging/dart_error.h" #include "third_party/dart/runtime/include/dart_api.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_library_natives.h" +#include "third_party/tonic/logging/dart_error.h" #define RETURN_ERROR_HANDLE(handle) \ if (Dart_IsError(handle)) { \ diff --git a/engine/src/flutter/runtime/dart_vm.cc b/engine/src/flutter/runtime/dart_vm.cc index 40a8bfef58..072502ef7a 100644 --- a/engine/src/flutter/runtime/dart_vm.cc +++ b/engine/src/flutter/runtime/dart_vm.cc @@ -22,15 +22,15 @@ #include "lib/fxl/files/file.h" #include "lib/fxl/logging.h" #include "lib/fxl/time/time_delta.h" -#include "lib/tonic/converter/dart_converter.h" -#include "lib/tonic/dart_class_library.h" -#include "lib/tonic/dart_class_provider.h" -#include "lib/tonic/dart_sticky_error.h" -#include "lib/tonic/file_loader/file_loader.h" -#include "lib/tonic/logging/dart_error.h" -#include "lib/tonic/scopes/dart_api_scope.h" -#include "lib/tonic/typed_data/uint8_list.h" #include "third_party/dart/runtime/bin/embedded_dart_io.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_class_library.h" +#include "third_party/tonic/dart_class_provider.h" +#include "third_party/tonic/dart_sticky_error.h" +#include "third_party/tonic/file_loader/file_loader.h" +#include "third_party/tonic/logging/dart_error.h" +#include "third_party/tonic/scopes/dart_api_scope.h" +#include "third_party/tonic/typed_data/uint8_list.h" #ifdef ERROR #undef ERROR diff --git a/engine/src/flutter/runtime/runtime_controller.cc b/engine/src/flutter/runtime/runtime_controller.cc index e2cbfaf110..22b8457980 100644 --- a/engine/src/flutter/runtime/runtime_controller.cc +++ b/engine/src/flutter/runtime/runtime_controller.cc @@ -10,7 +10,7 @@ #include "flutter/lib/ui/ui_dart_state.h" #include "flutter/lib/ui/window/window.h" #include "flutter/runtime/runtime_delegate.h" -#include "lib/tonic/dart_message_handler.h" +#include "third_party/tonic/dart_message_handler.h" #ifdef ERROR #undef ERROR @@ -70,11 +70,12 @@ RuntimeController::RuntimeController( unref_queue_, p_advisory_script_uri, p_advisory_script_entrypoint)) { - root_isolate_->SetReturnCodeCallback([this](uint32_t code) { + std::shared_ptr root_isolate = root_isolate_.lock(); + root_isolate->SetReturnCodeCallback([this](uint32_t code) { root_isolate_return_code_ = {true, code}; }); if (auto window = GetWindowIfAvailable()) { - tonic::DartState::Scope scope(root_isolate_.get()); + tonic::DartState::Scope scope(root_isolate); window->DidCreateIsolate(); if (!FlushRuntimeStateToIsolate()) { FXL_DLOG(ERROR) << "Could not setup intial isolate state."; @@ -87,9 +88,10 @@ RuntimeController::RuntimeController( RuntimeController::~RuntimeController() { FXL_DCHECK(Dart_CurrentIsolate() == nullptr); - if (root_isolate_) { - root_isolate_->SetReturnCodeCallback(nullptr); - auto result = root_isolate_->Shutdown(); + std::shared_ptr root_isolate = root_isolate_.lock(); + if (root_isolate) { + root_isolate->SetReturnCodeCallback(nullptr); + auto result = root_isolate->Shutdown(); if (!result) { FXL_DLOG(ERROR) << "Could not shutdown the root isolate."; } @@ -98,8 +100,9 @@ RuntimeController::~RuntimeController() { } bool RuntimeController::IsRootIsolateRunning() const { - if (root_isolate_) { - return root_isolate_->GetPhase() == DartIsolate::Phase::Running; + std::shared_ptr root_isolate = root_isolate_.lock(); + if (root_isolate) { + return root_isolate->GetPhase() == DartIsolate::Phase::Running; } return false; } @@ -192,11 +195,12 @@ bool RuntimeController::BeginFrame(fxl::TimePoint frame_time) { } bool RuntimeController::NotifyIdle(int64_t deadline) { - if (!root_isolate_) { + std::shared_ptr root_isolate = root_isolate_.lock(); + if (!root_isolate) { return false; } - tonic::DartState::Scope scope(root_isolate_.get()); + tonic::DartState::Scope scope(root_isolate); Dart_NotifyIdle(deadline); return true; } @@ -236,7 +240,8 @@ bool RuntimeController::DispatchSemanticsAction(int32_t id, } Window* RuntimeController::GetWindowIfAvailable() { - return root_isolate_ ? root_isolate_->window() : nullptr; + std::shared_ptr root_isolate = root_isolate_.lock(); + return root_isolate ? root_isolate->window() : nullptr; } std::string RuntimeController::DefaultRouteName() { @@ -267,26 +272,30 @@ FontCollection& RuntimeController::GetFontCollection() { } Dart_Port RuntimeController::GetMainPort() { - return root_isolate_ ? root_isolate_->main_port() : ILLEGAL_PORT; + std::shared_ptr root_isolate = root_isolate_.lock(); + return root_isolate ? root_isolate->main_port() : ILLEGAL_PORT; } std::string RuntimeController::GetIsolateName() { - return root_isolate_ ? root_isolate_->debug_name() : ""; + std::shared_ptr root_isolate = root_isolate_.lock(); + return root_isolate ? root_isolate->debug_name() : ""; } bool RuntimeController::HasLivePorts() { - if (!root_isolate_) { + std::shared_ptr root_isolate = root_isolate_.lock(); + if (!root_isolate) { return false; } - tonic::DartState::Scope scope(root_isolate_.get()); + tonic::DartState::Scope scope(root_isolate); return Dart_HasLivePorts(); } tonic::DartErrorHandleType RuntimeController::GetLastError() { - return root_isolate_ ? root_isolate_->GetLastError() : tonic::kNoError; + std::shared_ptr root_isolate = root_isolate_.lock(); + return root_isolate ? root_isolate->GetLastError() : tonic::kNoError; } -fml::WeakPtr RuntimeController::GetRootIsolate() { +std::weak_ptr RuntimeController::GetRootIsolate() { return root_isolate_; } diff --git a/engine/src/flutter/runtime/runtime_controller.h b/engine/src/flutter/runtime/runtime_controller.h index bcb51c640c..a2d32c097d 100644 --- a/engine/src/flutter/runtime/runtime_controller.h +++ b/engine/src/flutter/runtime/runtime_controller.h @@ -71,7 +71,7 @@ class RuntimeController final : public WindowClient { tonic::DartErrorHandleType GetLastError(); - fml::WeakPtr GetRootIsolate(); + std::weak_ptr GetRootIsolate(); std::pair GetRootIsolateReturnCode(); @@ -95,7 +95,7 @@ class RuntimeController final : public WindowClient { std::string advisory_script_uri_; std::string advisory_script_entrypoint_; WindowData window_data_; - fml::WeakPtr root_isolate_; + std::weak_ptr root_isolate_; std::pair root_isolate_return_code_ = {false, 0}; RuntimeController(RuntimeDelegate& client, diff --git a/engine/src/flutter/shell/common/BUILD.gn b/engine/src/flutter/shell/common/BUILD.gn index 28718a9606..6748ecde87 100644 --- a/engine/src/flutter/shell/common/BUILD.gn +++ b/engine/src/flutter/shell/common/BUILD.gn @@ -109,7 +109,7 @@ source_set("common") { public_deps = [ "$flutter_root/third_party/txt", - "//topaz/lib/tonic", + "//third_party/tonic", ] public_configs = [ "$flutter_root:config" ] @@ -129,7 +129,7 @@ executable("shell_unittests") { "//garnet/public/lib/fxl", "//third_party/dart/runtime:libdart_jit", "//third_party/skia", - "//topaz/lib/tonic", + "//third_party/tonic", ] if (is_linux) { ldflags = [ "-rdynamic" ] diff --git a/engine/src/flutter/shell/common/engine.cc b/engine/src/flutter/shell/common/engine.cc index f872669747..790fb70a13 100644 --- a/engine/src/flutter/shell/common/engine.cc +++ b/engine/src/flutter/shell/common/engine.cc @@ -117,7 +117,8 @@ bool Engine::Run(RunConfiguration configuration) { return false; } - auto isolate = runtime_controller_->GetRootIsolate(); + std::shared_ptr isolate = + runtime_controller_->GetRootIsolate().lock(); bool isolate_running = isolate && isolate->GetPhase() == blink::DartIsolate::Phase::Running; @@ -145,9 +146,14 @@ bool Engine::PrepareAndLaunchIsolate(RunConfiguration configuration) { auto isolate_configuration = configuration.TakeIsolateConfiguration(); - auto isolate = runtime_controller_->GetRootIsolate(); + std::shared_ptr isolate = + runtime_controller_->GetRootIsolate().lock(); - if (!isolate_configuration->PrepareIsolate(isolate)) { + if (!isolate) { + return false; + } + + if (!isolate_configuration->PrepareIsolate(*isolate)) { FXL_LOG(ERROR) << "Could not prepare to run the isolate."; return false; } diff --git a/engine/src/flutter/shell/common/isolate_configuration.cc b/engine/src/flutter/shell/common/isolate_configuration.cc index 06e62fedfb..2b3474108b 100644 --- a/engine/src/flutter/shell/common/isolate_configuration.cc +++ b/engine/src/flutter/shell/common/isolate_configuration.cc @@ -16,19 +16,14 @@ IsolateConfiguration::IsolateConfiguration() = default; IsolateConfiguration::~IsolateConfiguration() = default; -bool IsolateConfiguration::PrepareIsolate( - fml::WeakPtr isolate) { - if (!isolate) { - return false; - } - - if (isolate->GetPhase() != blink::DartIsolate::Phase::LibrariesSetup) { +bool IsolateConfiguration::PrepareIsolate(blink::DartIsolate& isolate) { + if (isolate.GetPhase() != blink::DartIsolate::Phase::LibrariesSetup) { FXL_DLOG(ERROR) << "Isolate was in incorrect phase to be prepared for running."; return false; } - return DoPrepareIsolate(*isolate); + return DoPrepareIsolate(isolate); } class AppSnapshotIsolateConfiguration final : public IsolateConfiguration { diff --git a/engine/src/flutter/shell/common/isolate_configuration.h b/engine/src/flutter/shell/common/isolate_configuration.h index 19e4834c3e..1f88195179 100644 --- a/engine/src/flutter/shell/common/isolate_configuration.h +++ b/engine/src/flutter/shell/common/isolate_configuration.h @@ -40,7 +40,7 @@ class IsolateConfiguration { virtual ~IsolateConfiguration(); - bool PrepareIsolate(fml::WeakPtr isolate); + bool PrepareIsolate(blink::DartIsolate& isolate); protected: virtual bool DoPrepareIsolate(blink::DartIsolate& isolate) = 0; diff --git a/engine/src/flutter/shell/platform/embedder/BUILD.gn b/engine/src/flutter/shell/platform/embedder/BUILD.gn index 6761892bca..661facca6a 100644 --- a/engine/src/flutter/shell/platform/embedder/BUILD.gn +++ b/engine/src/flutter/shell/platform/embedder/BUILD.gn @@ -34,7 +34,7 @@ source_set("embedder") { "//third_party/dart/runtime/bin:embedded_dart_io", "//third_party/skia", "//third_party/skia:gpu", - "//topaz/lib/tonic", + "//third_party/tonic", ] public_configs = [ "$flutter_root:config" ] diff --git a/engine/src/flutter/shell/testing/BUILD.gn b/engine/src/flutter/shell/testing/BUILD.gn index 6c99a3466d..67d8f73d1d 100644 --- a/engine/src/flutter/shell/testing/BUILD.gn +++ b/engine/src/flutter/shell/testing/BUILD.gn @@ -23,7 +23,7 @@ executable("testing") { "//third_party/dart/runtime:libdart_jit", "//third_party/dart/runtime/bin:embedded_dart_io", "//third_party/skia", - "//topaz/lib/tonic", + "//third_party/tonic", ] if (is_fuchsia) { diff --git a/engine/src/flutter/tools/licenses/pubspec.lock b/engine/src/flutter/tools/licenses/pubspec.lock deleted file mode 100644 index ef590e2492..0000000000 --- a/engine/src/flutter/tools/licenses/pubspec.lock +++ /dev/null @@ -1,61 +0,0 @@ -# Generated by pub -# See https://www.dartlang.org/tools/pub/glossary#lockfile -packages: - archive: - dependency: "direct main" - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.33" - args: - dependency: "direct main" - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "0.13.7" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.2" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.14.10" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - crypto: - dependency: "direct main" - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.6" - path: - dependency: "direct main" - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.1" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.5" -sdks: - dart: ">=2.0.0-dev.62.0 <=2.0.0-dev.67.0.flutter-84ca27a09e"