提交 0aea498f 编写于 作者: A Adam Barth 提交者: GitHub

Remove MojoServices from dart:ui (#3161)

We no longer offer mojo handles via this mechanism.
上级 d4ad63b5
......@@ -9,7 +9,6 @@
#include "flutter/assets/zip_asset_bundle.h"
#include "flutter/common/threads.h"
#include "flutter/content_handler/rasterizer.h"
#include "flutter/lib/ui/mojo_services.h"
#include "flutter/lib/ui/window/pointer_data_packet.h"
#include "flutter/runtime/asset_font_selector.h"
#include "flutter/runtime/dart_controller.h"
......@@ -154,9 +153,6 @@ void RuntimeHolder::HandlePlatformMessage(
}
void RuntimeHolder::DidCreateMainIsolate(Dart_Isolate isolate) {
blink::MojoServices::Create(isolate, nullptr, nullptr,
std::move(root_bundle_));
if (asset_store_)
blink::AssetFontSelector::Install(asset_store_);
}
......
......@@ -12,8 +12,6 @@ source_set("ui") {
"dart_runtime_hooks.h",
"dart_ui.cc",
"dart_ui.h",
"mojo_services.cc",
"mojo_services.h",
"painting/canvas.cc",
"painting/canvas.h",
"painting/gradient.cc",
......@@ -81,11 +79,6 @@ source_set("ui") {
"//flutter/skia",
"//flutter/sky/engine",
"//lib/tonic",
"//lib/tonic/mojo",
"//mojo/public/cpp/application",
"//mojo/public/cpp/bindings",
"//mojo/public/interfaces/application",
"//mojo/services/asset_bundle/interfaces",
]
if (is_android) {
......
......@@ -185,12 +185,12 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
}
void _addPicture(double dx, double dy, Picture picture, int hints) native "SceneBuilder_addPicture";
/// (mojo-only) Adds a scene rendered by another application to the scene for
/// this application.
/// (Fuchsia-only) Adds a scene rendered by another application to the scene
/// for this application.
///
/// Applications typically obtain scene tokens when embedding other views via
/// the Mojo view manager, but this function is agnostic as to the source of
/// scene token.
/// the Fuchsia view manager, but this function is agnostic as to the source
/// of scene token.
void addChildScene(Offset offset,
double devicePixelRatio,
int physicalWidth,
......
......@@ -42,8 +42,6 @@ namespace blink {
#define DECLARE_FUNCTION(name, count) \
extern void name(Dart_NativeArguments args);
// Lists the native functions implementing basic functionality in
// the Mojo embedder dart, such as printing, and file I/O.
#define BUILTIN_NATIVE_LIST(V) \
V(Logger_PrintString, 1) \
V(ScheduleMicrotask, 1)
......
......@@ -7,7 +7,6 @@
#include "flutter/lib/ui/compositing/scene.h"
#include "flutter/lib/ui/compositing/scene_builder.h"
#include "flutter/lib/ui/dart_runtime_hooks.h"
#include "flutter/lib/ui/mojo_services.h"
#include "flutter/lib/ui/painting/canvas.h"
#include "flutter/lib/ui/painting/gradient.h"
#include "flutter/lib/ui/painting/image.h"
......@@ -58,7 +57,6 @@ void DartUI::InitForGlobal() {
ImageFilter::RegisterNatives(g_natives);
ImageShader::RegisterNatives(g_natives);
MaskFilter::RegisterNatives(g_natives);
MojoServices::RegisterNatives(g_natives);
Paragraph::RegisterNatives(g_natives);
ParagraphBuilder::RegisterNatives(g_natives);
Picture::RegisterNatives(g_natives);
......
......@@ -8,7 +8,6 @@ dart_ui_files = [
"//flutter/lib/ui/hash_codes.dart",
"//flutter/lib/ui/hooks.dart",
"//flutter/lib/ui/lerp.dart",
"//flutter/lib/ui/mojo_services.dart",
"//flutter/lib/ui/natives.dart",
"//flutter/lib/ui/painting.dart",
"//flutter/lib/ui/pointer.dart",
......
// Copyright 2016 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.
#include "flutter/lib/ui/mojo_services.h"
#include "flutter/lib/ui/ui_dart_state.h"
#include "lib/tonic/converter/dart_converter.h"
#include "lib/tonic/dart_library_natives.h"
#include "lib/tonic/dart_state.h"
#include "lib/tonic/logging/dart_error.h"
#include "mojo/public/cpp/application/connect.h"
#include "mojo/public/cpp/bindings/array.h"
using tonic::DartState;
namespace blink {
namespace {
MojoServices* GetMojoServices() {
return static_cast<UIDartState*>(DartState::Current())->mojo_services();
}
void DartTakeRootBundle(Dart_NativeArguments args) {
int handle = MOJO_HANDLE_INVALID;
if (MojoServices* services = GetMojoServices())
handle = services->TakeRootBundle();
Dart_SetIntegerReturnValue(args, handle);
}
void DartTakeIncomingServices(Dart_NativeArguments args) {
int handle = MOJO_HANDLE_INVALID;
if (MojoServices* services = GetMojoServices())
handle = services->TakeIncomingServices();
Dart_SetIntegerReturnValue(args, handle);
}
void DartTakeOutgoingServices(Dart_NativeArguments args) {
int handle = MOJO_HANDLE_INVALID;
if (MojoServices* services = GetMojoServices())
handle = services->TakeOutgoingServices();
Dart_SetIntegerReturnValue(args, handle);
}
void DartTakeShell(Dart_NativeArguments args) {
int handle = MOJO_HANDLE_INVALID;
if (MojoServices* services = GetMojoServices())
handle = services->TakeShell();
Dart_SetIntegerReturnValue(args, handle);
}
void DartTakeViewServices(Dart_NativeArguments args) {
int handle = MOJO_HANDLE_INVALID;
if (MojoServices* services = GetMojoServices())
handle = services->TakeViewServices();
Dart_SetIntegerReturnValue(args, handle);
}
} // namespace
void MojoServices::RegisterNatives(tonic::DartLibraryNatives* natives) {
natives->Register({
{"MojoServices_takeRootBundle", DartTakeRootBundle, 0, true},
{"MojoServices_takeIncomingServices", DartTakeIncomingServices, 0, true},
{"MojoServices_takeOutgoingServices", DartTakeOutgoingServices, 0, true},
{"MojoServices_takeShell", DartTakeShell, 0, true},
{"MojoServices_takeViewServices", DartTakeViewServices, 0, true},
});
}
void MojoServices::Create(Dart_Isolate isolate,
sky::ServicesDataPtr services,
mojo::ServiceProviderPtr incoming_services,
mojo::asset_bundle::AssetBundlePtr root_bundle) {
UIDartState* state = static_cast<UIDartState*>(DartState::From(isolate));
state->set_mojo_services(std::unique_ptr<MojoServices>(
new MojoServices(std::move(services), std::move(incoming_services),
std::move(root_bundle))));
}
MojoServices::MojoServices(sky::ServicesDataPtr services,
mojo::ServiceProviderPtr incoming_services,
mojo::asset_bundle::AssetBundlePtr root_bundle)
: services_(std::move(services)),
root_bundle_(std::move(root_bundle)),
incoming_services_(std::move(incoming_services)) {
if (services_ && services_->outgoing_services.is_pending()) {
outgoing_services_ = std::move(services_->outgoing_services);
} else {
outgoing_services_ = GetProxy(&services_from_dart_);
}
}
MojoServices::~MojoServices() {}
int MojoServices::TakeRootBundle() {
return root_bundle_.PassInterfaceHandle().PassHandle().release().value();
}
int MojoServices::TakeIncomingServices() {
return incoming_services_.PassInterfaceHandle()
.PassHandle()
.release()
.value();
}
int MojoServices::TakeOutgoingServices() {
return outgoing_services_.PassMessagePipe().release().value();
}
int MojoServices::TakeShell() {
if (services_)
return services_->shell.PassHandle().release().value();
return MOJO_HANDLE_INVALID;
}
int MojoServices::TakeViewServices() {
if (services_)
return services_->view_services.PassHandle().release().value();
return MOJO_HANDLE_INVALID;
}
} // namespace blink
// Copyright 2016 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.
part of dart_ui;
/// Mojo handles provided to the application at startup.
///
/// The application can take ownership of these handles by calling the static
/// "take" functions on this object. Once taken, the application is responsible
/// for managing the handles.
class MojoServices {
MojoServices._();
static int takeRootBundle() native "MojoServices_takeRootBundle";
static int takeIncomingServices() native "MojoServices_takeIncomingServices";
static int takeOutgoingServices() native "MojoServices_takeOutgoingServices";
static int takeShell() native "MojoServices_takeShell";
static int takeViewServices() native "MojoServices_takeViewServices";
}
// Copyright 2016 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 SKY_ENGINE_BINDINGS_MOJO_SERVICES_H_
#define SKY_ENGINE_BINDINGS_MOJO_SERVICES_H_
#include "dart/runtime/include/dart_api.h"
#include "lib/ftl/macros.h"
#include "mojo/public/cpp/application/service_provider_impl.h"
#include "mojo/public/interfaces/application/service_provider.mojom.h"
#include "mojo/services/asset_bundle/interfaces/asset_bundle.mojom.h"
#include "flutter/services/engine/sky_engine.mojom.h"
namespace mojo {
class ApplicationConnection;
}
namespace tonic {
class DartLibraryNatives;
} // namespace tonic
namespace blink {
class MojoServices {
public:
~MojoServices();
static void Create(Dart_Isolate isolate,
sky::ServicesDataPtr services,
mojo::ServiceProviderPtr incoming_services,
mojo::asset_bundle::AssetBundlePtr root_bundle);
static void RegisterNatives(tonic::DartLibraryNatives* natives);
int TakeRootBundle();
int TakeIncomingServices();
int TakeOutgoingServices();
int TakeShell();
int TakeView();
int TakeViewServices();
private:
explicit MojoServices(sky::ServicesDataPtr services,
mojo::ServiceProviderPtr incoming_services,
mojo::asset_bundle::AssetBundlePtr root_bundle);
sky::ServicesDataPtr services_;
mojo::asset_bundle::AssetBundlePtr root_bundle_;
mojo::ServiceProviderPtr incoming_services_;
mojo::InterfaceRequest<mojo::ServiceProvider> outgoing_services_;
// We need to hold this object to work around
// https://github.com/domokit/mojo/issues/536
mojo::ServiceProviderPtr services_from_dart_;
FTL_DISALLOW_COPY_AND_ASSIGN(MojoServices);
};
} // namespace blink
#endif // SKY_ENGINE_BINDINGS_MOJO_SERVICES_H_
......@@ -545,8 +545,7 @@ class Paint {
/// Opaque handle to raw decoded image data (pixels).
///
/// To obtain an Image object, use the [decodeImageFromDataPipe] or
/// [decodeImageFromList] functions.
/// To obtain an Image object, use [decodeImageFromList].
///
/// To draw an Image, use one of the methods on the [Canvas] class, such as
/// [drawImage].
......@@ -565,13 +564,9 @@ abstract class Image extends NativeFieldWrapperClass2 {
String toString() => '[$width\u00D7$height]';
}
/// Callback signature for [decodeImageFromDataPipe] and [decodeImageFromList].
/// Callback signature for [decodeImageFromList].
typedef void ImageDecoderCallback(Image result);
/// Convert an image file from a mojo pipe into an [Image] object.
void decodeImageFromDataPipe(int handle, ImageDecoderCallback callback)
native "decodeImageFromDataPipe";
/// Convert an image file from a byte array into an [Image] object.
void decodeImageFromList(Uint8List list, ImageDecoderCallback callback)
native "decodeImageFromList";
......
......@@ -7,7 +7,6 @@
#include "flutter/common/threads.h"
#include "flutter/flow/bitmap_image.h"
#include "flutter/flow/texture_image.h"
#include "flutter/glue/drain_data_pipe_job.h"
#include "flutter/glue/movable_wrapper.h"
#include "flutter/glue/trace_event.h"
#include "flutter/lib/ui/painting/image.h"
......@@ -15,7 +14,6 @@
#include "lib/tonic/dart_persistent_value.h"
#include "lib/tonic/dart_state.h"
#include "lib/tonic/logging/dart_invoke.h"
#include "lib/tonic/mojo/mojo_converter.h"
#include "lib/tonic/typed_data/uint8_list.h"
#include "third_party/skia/include/core/SkImageGenerator.h"
......@@ -77,36 +75,6 @@ void DecodeImageAndInvokeImageCallback(
});
}
void DecodeImageFromDataPipe(Dart_NativeArguments args) {
Dart_Handle exception = nullptr;
auto consumer = glue::WrapMovable(
tonic::DartConverter<mojo::ScopedDataPipeConsumerHandle>::FromArguments(
args, 0, exception));
if (exception) {
Dart_ThrowException(exception);
return;
}
Dart_Handle callback_handle = Dart_GetNativeArgument(args, 1);
if (!Dart_IsClosure(callback_handle)) {
Dart_ThrowException(ToDart("Callback must be a function"));
return;
}
auto callback = glue::WrapMovable(std::unique_ptr<DartPersistentValue>(
new DartPersistentValue(tonic::DartState::Current(), callback_handle)));
Threads::IO()->PostTask([callback, consumer]() mutable {
glue::DrainDataPipeJob* job = nullptr;
job = new glue::DrainDataPipeJob(
consumer.Unwrap(), [callback, job](std::vector<uint8_t> buffer) {
delete job;
DecodeImageAndInvokeImageCallback(callback, std::move(buffer));
});
});
}
void DecodeImageFromList(Dart_NativeArguments args) {
Dart_Handle exception = nullptr;
......@@ -138,7 +106,6 @@ void DecodeImageFromList(Dart_NativeArguments args) {
void ImageDecoding::RegisterNatives(tonic::DartLibraryNatives* natives) {
natives->Register({
{"decodeImageFromDataPipe", DecodeImageFromDataPipe, 2, true},
{"decodeImageFromList", DecodeImageFromList, 2, true},
});
}
......
......@@ -7,10 +7,8 @@
/// To use, import `dart:ui`.
///
/// This library exposes the lowest-level services that Flutter frameworks use
/// to bootstrap applications, such as methods to obtain handles for the mojo
/// IPC system, classes for driving the graphics and text layout and rendering
/// subsystems, callbacks for integrating with the engine scheduler and the
/// pointer input system, and functions for image decoding.
/// to bootstrap applications, such as classes for driving the input, graphics
/// text, layout, and rendering subsystems.
library dart_ui;
import 'dart:_internal';
......@@ -27,7 +25,6 @@ part 'geometry.dart';
part 'hash_codes.dart';
part 'hooks.dart';
part 'lerp.dart';
part 'mojo_services.dart';
part 'natives.dart';
part 'painting.dart';
part 'pointer.dart';
......
......@@ -4,7 +4,6 @@
#include "flutter/lib/ui/ui_dart_state.h"
#include "flutter/lib/ui/mojo_services.h"
#include "flutter/lib/ui/window/window.h"
#include "flutter/sky/engine/platform/fonts/FontSelector.h"
#include "lib/tonic/converter/dart_converter.h"
......@@ -55,15 +54,6 @@ UIDartState* UIDartState::Current() {
return static_cast<UIDartState*>(DartState::Current());
}
void UIDartState::set_mojo_services(
std::unique_ptr<MojoServices> mojo_services) {
mojo_services_ = std::move(mojo_services);
}
MojoServices* UIDartState::mojo_services() {
return mojo_services_.get();
}
#if defined(OS_ANDROID)
DartJniIsolateData* UIDartState::jni_data() {
return jni_data_.get();
......
......@@ -16,7 +16,6 @@
namespace blink {
struct DartJniIsolateData;
class FontSelector;
class MojoServices;
class Window;
class IsolateClient {
......@@ -41,9 +40,6 @@ class UIDartState : public tonic::DartState {
const std::string& debug_name() const { return debug_name_; }
Window* window() const { return window_.get(); }
void set_mojo_services(std::unique_ptr<MojoServices> mojo_services);
MojoServices* mojo_services();
#if defined(OS_ANDROID)
DartJniIsolateData* jni_data();
#endif
......@@ -57,7 +53,6 @@ class UIDartState : public tonic::DartState {
IsolateClient* isolate_client_;
Dart_Port main_port_;
std::string debug_name_;
std::unique_ptr<MojoServices> mojo_services_;
std::unique_ptr<Window> window_;
RefPtr<FontSelector> font_selector_;
......
......@@ -14,7 +14,6 @@
#include "flutter/common/threads.h"
#include "flutter/glue/movable_wrapper.h"
#include "flutter/glue/trace_event.h"
#include "flutter/lib/ui/mojo_services.h"
#include "flutter/runtime/asset_font_selector.h"
#include "flutter/runtime/dart_controller.h"
#include "flutter/runtime/dart_init.h"
......@@ -302,29 +301,11 @@ void Engine::OnAppLifecycleStateChanged(sky::AppLifecycleState state) {
}
void Engine::DidCreateMainIsolate(Dart_Isolate isolate) {
mojo::ServiceProviderPtr services_from_embedder;
service_provider_bindings_.AddBinding(
&service_provider_impl_, mojo::GetProxy(&services_from_embedder));
blink::MojoServices::Create(isolate, std::move(services_),
std::move(services_from_embedder),
std::move(root_bundle_));
if (asset_store_)
blink::AssetFontSelector::Install(asset_store_);
}
void Engine::DidCreateSecondaryIsolate(Dart_Isolate isolate) {
mojo::ServiceProviderPtr services_from_embedder;
auto request = glue::WrapMovable(mojo::GetProxy(&services_from_embedder));
ftl::WeakPtr<Engine> engine = weak_factory_.GetWeakPtr();
blink::Threads::UI()->PostTask([engine, request]() mutable {
if (engine)
engine->BindToServiceProvider(request.Unwrap());
});
blink::MojoServices::Create(isolate, nullptr,
std::move(services_from_embedder), nullptr);
}
void Engine::DidCreateSecondaryIsolate(Dart_Isolate isolate) {}
void Engine::BindToServiceProvider(
mojo::InterfaceRequest<mojo::ServiceProvider> request) {
......
......@@ -2,5 +2,4 @@
/// Use of this source code is governed by a BSD-style license that can be
/// found in the LICENSE file.
import 'package:sky_services/flutter/platform/app_messages.mojom.dart';
export 'package:sky_services/flutter/platform/app_messages.mojom.dart';
// TODO(abarth): Remove this package.
/// Copyright 2016 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.
import 'package:mojo_services/mojo/asset_bundle/asset_bundle.mojom.dart';
export 'package:mojo_services/mojo/asset_bundle/asset_bundle.mojom.dart';
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册