Migrate to a standalone Tonic repository separated from Topaz (flutter/engine#5817)

This commit is contained in:
Jason Simmons
2018-07-23 11:49:35 -07:00
committed by GitHub
parent 4164eac513
commit ebbdba1aea
81 changed files with 484 additions and 489 deletions

4
DEPS
View File

@@ -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',

View File

@@ -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 += [

View File

@@ -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;

View File

@@ -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" ]

View File

@@ -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;

View File

@@ -9,7 +9,7 @@
#include <memory>
#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<Scene>,
public tonic::DartWrappable {
class Scene : public RefCountedDartWrappable<Scene> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(Scene);

View File

@@ -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<flow::ClipMode>(clipMode));
layer_builder_->PushClipRect(SkRect::MakeLTRB(left, top, right, bottom),
static_cast<flow::ClipMode>(clipMode));
}
void SceneBuilder::pushClipRRect(const RRect& rrect, int clipMode) {
layer_builder_->PushClipRoundedRect(rrect.sk_rrect, static_cast<flow::ClipMode>(clipMode));
layer_builder_->PushClipRoundedRect(rrect.sk_rrect,
static_cast<flow::ClipMode>(clipMode));
}
void SceneBuilder::pushClipPath(const CanvasPath* path, int clipMode) {
layer_builder_->PushClipPath(path->path(), static_cast<flow::ClipMode>(clipMode));
layer_builder_->PushClipPath(path->path(),
static_cast<flow::ClipMode>(clipMode));
}
void SceneBuilder::pushOpacity(int alpha) {

View File

@@ -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<SceneBuilder>,
public tonic::DartWrappable {
class SceneBuilder : public RefCountedDartWrappable<SceneBuilder> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(SceneBuilder);
@@ -35,7 +34,11 @@ class SceneBuilder : public fxl::RefCountedThreadSafe<SceneBuilder>,
~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<SceneBuilder>,
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();

View File

@@ -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"

View File

@@ -7,7 +7,7 @@
#include <stdint.h>
#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<SceneHost>,
public tonic::DartWrappable {
class SceneHost : public RefCountedDartWrappable<SceneHost> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(SceneHost);

View File

@@ -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 <android/log.h>

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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 <typename T>
class RefCountedDartWrappable : public fxl::RefCountedThreadSafe<T>,
public tonic::DartWrappable {
public:
virtual void RetainDartWrappableReference() const override {
fxl::RefCountedThreadSafe<T>::AddRef();
}
virtual void ReleaseDartWrappableReference() const override {
fxl::RefCountedThreadSafe<T>::Release();
}
};
} // namespace blink
#endif // FLUTTER_LIB_UI_DART_WRAPPER_H_

View File

@@ -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 {

View File

@@ -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) {

View File

@@ -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<Canvas>,
public tonic::DartWrappable {
class Canvas : public RefCountedDartWrappable<Canvas> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(Canvas);

View File

@@ -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> codec,
std::unique_ptr<DartPersistentValue> callback,
size_t trace_id) {
tonic::DartState* dart_state = callback->dart_state().get();
std::shared_ptr<tonic::DartState> 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> frameInfo,
std::unique_ptr<DartPersistentValue> callback,
size_t trace_id) {
tonic::DartState* dart_state = callback->dart_state().get();
std::shared_ptr<tonic::DartState> 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<DartPersistentValue>(
tonic::DartState::Current(), callback_handle);
tonic::DartState* dart_state = callback->dart_state().get();
std::shared_ptr<tonic::DartState> dart_state = callback->dart_state().lock();
if (!dart_state) {
return ToDart("Invalid dart state");
}

View File

@@ -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<Codec>,
public tonic::DartWrappable {
class Codec : public RefCountedDartWrappable<Codec> {
DEFINE_WRAPPERTYPEINFO();
public:

View File

@@ -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 {

View File

@@ -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<FrameInfo>,
public tonic::DartWrappable {
class FrameInfo final : public RefCountedDartWrappable<FrameInfo> {
DEFINE_WRAPPERTYPEINFO();
public:

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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<CanvasImage>,
public tonic::DartWrappable {
class CanvasImage final : public RefCountedDartWrappable<CanvasImage> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(CanvasImage);

View File

@@ -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<DartPersistentValue> callback,
sk_sp<SkData> buffer) {
tonic::DartState* dart_state = callback->dart_state().get();
std::shared_ptr<tonic::DartState> dart_state = callback->dart_state().lock();
if (!dart_state) {
return;
}

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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<ImageFilter>,
public tonic::DartWrappable {
class ImageFilter : public RefCountedDartWrappable<ImageFilter> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(ImageFilter);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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<blink::Paint>::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<blink::Paint>::FromArguments(
}
blink::PaintData DartConverter<blink::PaintData>::FromArguments(
Dart_NativeArguments args, int index, Dart_Handle& exception) {
Dart_NativeArguments args,
int index,
Dart_Handle& exception) {
return blink::PaintData();
}

View File

@@ -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 {

View File

@@ -8,10 +8,10 @@
#include <math.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/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_);
}

View File

@@ -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<CanvasPath>,
public tonic::DartWrappable {
class CanvasPath : public RefCountedDartWrappable<CanvasPath> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(CanvasPath);

View File

@@ -8,10 +8,10 @@
#include <math.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/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;

View File

@@ -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<CanvasPathMeasure>,
public tonic::DartWrappable {
class CanvasPathMeasure : public RefCountedDartWrappable<CanvasPathMeasure> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(CanvasPathMeasure);
public:
~CanvasPathMeasure() override;
static fxl::RefPtr<CanvasPathMeasure> Create(const CanvasPath* path, bool forceClosed);
static fxl::RefPtr<CanvasPathMeasure> Create(const CanvasPath* path,
bool forceClosed);
void setPath(const CanvasPath* path, bool isClosed);
float getLength();
tonic::Float32List getPosTan(float distance);
fxl::RefPtr<CanvasPath> getSegment(float startD, float stopD, bool startWithMoveTo);
fxl::RefPtr<CanvasPath> getSegment(float startD,
float stopD,
bool startWithMoveTo);
bool isClosed();
bool nextContour();

View File

@@ -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 {

View File

@@ -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<Picture>,
public tonic::DartWrappable {
class Picture : public RefCountedDartWrappable<Picture> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(Picture);

View File

@@ -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 {

View File

@@ -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<PictureRecorder>,
public tonic::DartWrappable {
class PictureRecorder : public RefCountedDartWrappable<PictureRecorder> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(PictureRecorder);

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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<Shader>,
public tonic::DartWrappable {
class Shader : public RefCountedDartWrappable<Shader> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(Shader);

View File

@@ -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 {

View File

@@ -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<Vertices>,
public tonic::DartWrappable {
class Vertices : public RefCountedDartWrappable<Vertices> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(Vertices);

View File

@@ -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;

View File

@@ -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 {

View File

@@ -7,10 +7,10 @@
#include <memory>
#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> SemanticsUpdate::create(
SemanticsNodeUpdates nodes,
CustomAccessibilityActionUpdates actions) {
return fxl::MakeRefCounted<SemanticsUpdate>(std::move(nodes), std::move(actions));
return fxl::MakeRefCounted<SemanticsUpdate>(std::move(nodes),
std::move(actions));
}
SemanticsUpdate::SemanticsUpdate(SemanticsNodeUpdates nodes,

View File

@@ -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<SemanticsUpdate>,
public tonic::DartWrappable {
class SemanticsUpdate : public RefCountedDartWrappable<SemanticsUpdate> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(SemanticsUpdate);
public:
~SemanticsUpdate() override;
static fxl::RefPtr<SemanticsUpdate> create(SemanticsNodeUpdates nodes,
CustomAccessibilityActionUpdates actions);
static fxl::RefPtr<SemanticsUpdate> create(
SemanticsNodeUpdates nodes,
CustomAccessibilityActionUpdates actions);
SemanticsNodeUpdates takeNodes();

View File

@@ -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<int32_t>(
childrenInTraversalOrder.data(), childrenInTraversalOrder.data() + childrenInTraversalOrder.num_elements());
node.childrenInTraversalOrder =
std::vector<int32_t>(childrenInTraversalOrder.data(),
childrenInTraversalOrder.data() +
childrenInTraversalOrder.num_elements());
node.childrenInHitTestOrder = std::vector<int32_t>(
childrenInHitTestOrder.data(), childrenInHitTestOrder.data() + childrenInHitTestOrder.num_elements());
childrenInHitTestOrder.data(),
childrenInHitTestOrder.data() + childrenInHitTestOrder.num_elements());
node.customAccessibilityActions = std::vector<int32_t>(
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;

View File

@@ -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<SemanticsUpdateBuilder>,
public tonic::DartWrappable {
: public RefCountedDartWrappable<SemanticsUpdateBuilder> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(SemanticsUpdateBuilder);

View File

@@ -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;

View File

@@ -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<Paragraph>,
public tonic::DartWrappable {
class Paragraph : public RefCountedDartWrappable<Paragraph> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(Paragraph);

View File

@@ -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 {

View File

@@ -6,11 +6,11 @@
#define FLUTTER_LIB_UI_TEXT_PARAGRAPH_BUILDER_H_
#include <memory>
#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<ParagraphBuilder>,
public tonic::DartWrappable {
class ParagraphBuilder : public RefCountedDartWrappable<ParagraphBuilder> {
DEFINE_WRAPPERTYPEINFO();
FRIEND_MAKE_REF_COUNTED(ParagraphBuilder);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<fml::Mapping> 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<tonic::DartState> 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<tonic::DartState> dart_state =
callback.dart_state().lock();
if (!dart_state)
return;
tonic::DartState::Scope scope(dart_state);

View File

@@ -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 {

View File

@@ -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<tonic::DartState> 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<tonic::DartState> 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<tonic::DartState> 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<tonic::DartState> 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<tonic::DartState> 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<PlatformMessage> message) {
tonic::DartState* dart_state = library_.dart_state().get();
std::shared_ptr<tonic::DartState> 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<PlatformMessage> message) {
}
void Window::DispatchPointerDataPacket(const PointerDataPacket& packet) {
tonic::DartState* dart_state = library_.dart_state().get();
std::shared_ptr<tonic::DartState> 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<uint8_t> args) {
tonic::DartState* dart_state = library_.dart_state().get();
std::shared_ptr<tonic::DartState> 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<tonic::DartState> dart_state = library_.dart_state().lock();
if (!dart_state)
return;
tonic::DartState::Scope scope(dart_state);

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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> DartIsolate::CreateRootIsolate(
std::weak_ptr<DartIsolate> DartIsolate::CreateRootIsolate(
DartVM* vm,
fxl::RefPtr<DartSnapshot> isolate_snapshot,
fxl::RefPtr<DartSnapshot> shared_snapshot,
@@ -45,25 +45,26 @@ fml::WeakPtr<DartIsolate> DartIsolate::CreateRootIsolate(
Dart_IsolateFlags* flags) {
TRACE_EVENT0("flutter", "DartIsolate::CreateRootIsolate");
Dart_Isolate vm_isolate = nullptr;
fml::WeakPtr<DartIsolate> embedder_isolate;
std::weak_ptr<DartIsolate> 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<DartIsolate>(
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::shared_ptr<DartIsolate>>(
std::make_shared<DartIsolate>(
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> DartIsolate::CreateRootIsolate(
return {};
}
if (embedder_isolate) {
std::shared_ptr<DartIsolate> 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<fml::WeakPtrFactory<DartIsolate>>(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<std::shared_ptr<DartIsolate>*>(
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<void()> task) {
task_runner->PostTask(task);
};
message_handler().Initialize(dispatcher);
}
}
@@ -576,7 +584,7 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate(
flags->load_vmservice_library = true;
fml::WeakPtr<DartIsolate> weak_service_isolate =
std::weak_ptr<DartIsolate> 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<DartIsolate> 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<DartIsolate>* 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<Dart_Isolate, fml::WeakPtr<DartIsolate>>
std::pair<Dart_Isolate, std::weak_ptr<DartIsolate>>
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<DartIsolate>* p_parent_embedder_isolate,
bool is_root_isolate,
char** error) {
TRACE_EVENT0("flutter", "DartIsolate::CreateDartVMAndEmbedderObjectPair");
std::unique_ptr<DartIsolate> embedder_isolate{p_parent_embedder_isolate};
std::unique_ptr<std::shared_ptr<DartIsolate>> 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<DartIsolate>(
vm, // vm
raw_embedder_isolate->GetIsolateSnapshot(), // isolate_snapshot
raw_embedder_isolate->GetSharedSnapshot(), // shared_snapshot
null_task_runners, // task_runners
fml::WeakPtr<GrContext>{}, // 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::shared_ptr<DartIsolate>>(
std::make_shared<DartIsolate>(
vm, // vm
(*raw_embedder_isolate)->GetIsolateSnapshot(), // isolate_snapshot
(*raw_embedder_isolate)->GetSharedSnapshot(), // shared_snapshot
null_task_runners, // task_runners
fml::WeakPtr<GrContext>{}, // 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<DartIsolate>* 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<DartIsolate>* embedder_isolate) {
delete embedder_isolate;
}
@@ -808,14 +813,8 @@ fxl::RefPtr<DartSnapshot> DartIsolate::GetSharedSnapshot() const {
return shared_snapshot_;
}
fml::WeakPtr<DartIsolate> DartIsolate::GetWeakIsolatePtr() const {
return weak_factory_ ? weak_factory_->GetWeakPtr()
: fml::WeakPtr<DartIsolate>();
}
void DartIsolate::ResetWeakPtrFactory() {
FXL_CHECK(weak_factory_);
weak_factory_.reset();
std::weak_ptr<DartIsolate> DartIsolate::GetWeakIsolatePtr() {
return std::static_pointer_cast<DartIsolate>(shared_from_this());
}
void DartIsolate::AddIsolateShutdownCallback(fxl::Closure closure) {

View File

@@ -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<DartIsolate> CreateRootIsolate(
static std::weak_ptr<DartIsolate> CreateRootIsolate(
DartVM* vm,
fxl::RefPtr<DartSnapshot> isolate_snapshot,
fxl::RefPtr<DartSnapshot> shared_snapshot,
@@ -93,7 +93,7 @@ class DartIsolate : public UIDartState {
fxl::RefPtr<DartSnapshot> GetIsolateSnapshot() const;
fxl::RefPtr<DartSnapshot> GetSharedSnapshot() const;
fml::WeakPtr<DartIsolate> GetWeakIsolatePtr() const;
std::weak_ptr<DartIsolate> GetWeakIsolatePtr();
private:
bool LoadScriptSnapshot(std::shared_ptr<const fml::Mapping> mapping,
@@ -125,7 +125,6 @@ class DartIsolate : public UIDartState {
std::vector<std::shared_ptr<const fml::Mapping>> kernel_buffers_;
std::vector<std::unique_ptr<AutoFireClosure>> shutdown_callbacks_;
ChildIsolatePreparer child_isolate_preparer_;
std::unique_ptr<fml::WeakPtrFactory<DartIsolate>> 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<DartIsolate>* embedder_isolate,
char** error);
static Dart_Isolate DartCreateAndStartServiceIsolate(
@@ -159,21 +156,24 @@ class DartIsolate : public UIDartState {
char** error);
static std::pair<Dart_Isolate /* vm */,
fml::WeakPtr<DartIsolate> /* 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<DartIsolate> /* 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<DartIsolate>* parent_embedder_isolate,
bool is_root_isolate,
char** error);
// |Dart_IsolateShutdownCallback|
static void DartIsolateShutdownCallback(DartIsolate* embedder_isolate);
static void DartIsolateShutdownCallback(
std::shared_ptr<DartIsolate>* embedder_isolate);
// |Dart_IsolateCleanupCallback|
static void DartIsolateCleanupCallback(DartIsolate* embedder_isolate);
static void DartIsolateCleanupCallback(
std::shared_ptr<DartIsolate>* embedder_isolate);
FXL_DISALLOW_COPY_AND_ASSIGN(DartIsolate);
};

View File

@@ -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(

View File

@@ -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)) { \

View File

@@ -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

View File

@@ -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<DartIsolate> 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<DartIsolate> 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<DartIsolate> 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<DartIsolate> 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<DartIsolate> 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<DartIsolate> 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<DartIsolate> root_isolate = root_isolate_.lock();
return root_isolate ? root_isolate->debug_name() : "";
}
bool RuntimeController::HasLivePorts() {
if (!root_isolate_) {
std::shared_ptr<DartIsolate> 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<DartIsolate> root_isolate = root_isolate_.lock();
return root_isolate ? root_isolate->GetLastError() : tonic::kNoError;
}
fml::WeakPtr<DartIsolate> RuntimeController::GetRootIsolate() {
std::weak_ptr<DartIsolate> RuntimeController::GetRootIsolate() {
return root_isolate_;
}

View File

@@ -71,7 +71,7 @@ class RuntimeController final : public WindowClient {
tonic::DartErrorHandleType GetLastError();
fml::WeakPtr<DartIsolate> GetRootIsolate();
std::weak_ptr<DartIsolate> GetRootIsolate();
std::pair<bool, uint32_t> 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<DartIsolate> root_isolate_;
std::weak_ptr<DartIsolate> root_isolate_;
std::pair<bool, uint32_t> root_isolate_return_code_ = {false, 0};
RuntimeController(RuntimeDelegate& client,

View File

@@ -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" ]

View File

@@ -117,7 +117,8 @@ bool Engine::Run(RunConfiguration configuration) {
return false;
}
auto isolate = runtime_controller_->GetRootIsolate();
std::shared_ptr<blink::DartIsolate> 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<blink::DartIsolate> 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;
}

View File

@@ -16,19 +16,14 @@ IsolateConfiguration::IsolateConfiguration() = default;
IsolateConfiguration::~IsolateConfiguration() = default;
bool IsolateConfiguration::PrepareIsolate(
fml::WeakPtr<blink::DartIsolate> 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 {

View File

@@ -40,7 +40,7 @@ class IsolateConfiguration {
virtual ~IsolateConfiguration();
bool PrepareIsolate(fml::WeakPtr<blink::DartIsolate> isolate);
bool PrepareIsolate(blink::DartIsolate& isolate);
protected:
virtual bool DoPrepareIsolate(blink::DartIsolate& isolate) = 0;

View File

@@ -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" ]

View File

@@ -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) {

View File

@@ -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"