Skip to content

Commit

Permalink
Unlink from mojo (flutter#3187)
Browse files Browse the repository at this point in the history
After this patch, we no longer link with Mojo. We still use some gn definitions
from //mojo to create Dart packages.
  • Loading branch information
abarth authored Oct 28, 2016
1 parent c5c69a2 commit 63e7180
Show file tree
Hide file tree
Showing 40 changed files with 99 additions and 304 deletions.
5 changes: 2 additions & 3 deletions glue/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@

source_set("glue") {
sources = [
"movable_wrapper.h",
"stack_trace.h",
"thread.h",
"trace_event.h",
]

deps = [
"//lib/ftl",
"//mojo/public/cpp/environment",
"//mojo/public/cpp/system",
]

if (is_fuchsia) {
Expand All @@ -26,6 +23,8 @@ source_set("glue") {

deps += [
"//lib/mtl",
"//mojo/public/cpp/environment",
"//mojo/public/cpp/system",
]

public_deps = [
Expand Down
37 changes: 0 additions & 37 deletions glue/movable_wrapper.h

This file was deleted.

24 changes: 0 additions & 24 deletions lib/mojo/BUILD.gn

This file was deleted.

47 changes: 0 additions & 47 deletions lib/mojo/dart_mojo_internal.cc

This file was deleted.

25 changes: 0 additions & 25 deletions lib/mojo/dart_mojo_internal.h

This file was deleted.

7 changes: 0 additions & 7 deletions lib/snapshot/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import("//flutter/lib/jni/dart_jni.gni")
import("//flutter/lib/snapshot/toolchain.gni")
import("//flutter/lib/ui/dart_ui.gni")
import("//flutter/lib/ui/dart_ui.gni")
import("//mojo/dart/packages/mojo/sdk_ext_sources.gni")

bindings_output_dir = "$root_gen_dir/sky/bindings"

Expand Down Expand Up @@ -37,18 +36,13 @@ action("generate_snapshot_bin") {
"snapshot.dart",
] + dart_ui_files
+ dart_jni_files
+ rebase_path(dart_mojo_internal_sdk_sources,
"",
"//mojo/dart/packages/mojo")
vm_isolate_snapshot = "$target_gen_dir/vm_isolate_snapshot.bin"
isolate_snapshot = "$target_gen_dir/isolate_snapshot.bin"
outputs = [
vm_isolate_snapshot,
isolate_snapshot,
]

dart_mojo_internal_path =
rebase_path("//mojo/dart/packages/mojo/sdk_ext/internal.dart")
rebased_dart_ui_path = rebase_path(dart_ui_path)
rebased_dart_jni_path = rebase_path(dart_jni_path)

Expand All @@ -70,7 +64,6 @@ action("generate_snapshot_bin") {
rebase_path(isolate_snapshot, root_build_dir),
"--target_os",
target_os,
"--url_mapping=dart:mojo.internal,$dart_mojo_internal_path",
"--url_mapping=dart:ui,$rebased_dart_ui_path",
"--url_mapping=dart:jni,$rebased_dart_jni_path",
]
Expand Down
1 change: 0 additions & 1 deletion lib/snapshot/snapshot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ import 'dart:io';
import 'dart:isolate';
import 'dart:jni';
import 'dart:math';
import 'dart:mojo.internal';
import 'dart:ui';
import 'dart:typed_data';
1 change: 0 additions & 1 deletion lib/snapshot/toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//mojo/dart/packages/mojo/sdk_ext_sources.gni")
import("//flutter/common/config.gni") # for flutter_aot

if (target_os == "ios") {
Expand Down
24 changes: 10 additions & 14 deletions lib/ui/dart_runtime_hooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,17 @@ static void InitDartInternal(Dart_Handle builtin_library,
// Call |_setupHooks| to configure |VMLibraryHooks|.
Dart_Handle method_name = Dart_NewStringFromCString("_setupHooks");
DART_CHECK_VALID(Dart_Invoke(builtin_library, method_name, 0, NULL))

// Call |_setupHooks| to configure |VMLibraryHooks|.
Dart_Handle isolate_lib = Dart_LookupLibrary(ToDart("dart:isolate"));
DART_CHECK_VALID(isolate_lib);
DART_CHECK_VALID(Dart_Invoke(isolate_lib, method_name, 0, NULL));
} else {
FTL_CHECK(isolate_type == DartRuntimeHooks::SecondaryIsolate);
Dart_Handle io_lib = Dart_LookupLibrary(ToDart("dart:io"));
DART_CHECK_VALID(io_lib);
Dart_Handle setup_hooks = Dart_NewStringFromCString("_setupHooks");
DART_CHECK_VALID(Dart_Invoke(io_lib, setup_hooks, 0, NULL));
Dart_Handle isolate_lib = Dart_LookupLibrary(ToDart("dart:isolate"));
DART_CHECK_VALID(isolate_lib);
DART_CHECK_VALID(Dart_Invoke(isolate_lib, setup_hooks, 0, NULL));
}

Dart_Handle setup_hooks = Dart_NewStringFromCString("_setupHooks");

Dart_Handle io_lib = Dart_LookupLibrary(ToDart("dart:io"));
DART_CHECK_VALID(io_lib);
DART_CHECK_VALID(Dart_Invoke(io_lib, setup_hooks, 0, NULL));

Dart_Handle isolate_lib = Dart_LookupLibrary(ToDart("dart:isolate"));
DART_CHECK_VALID(isolate_lib);
DART_CHECK_VALID(Dart_Invoke(isolate_lib, setup_hooks, 0, NULL));
}

static void InitDartCore(Dart_Handle builtin, const std::string& script_uri) {
Expand Down
3 changes: 0 additions & 3 deletions lib/ui/natives.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ Future<developer.ServiceExtensionResponse> _scheduleFrame(
}

void _setupHooks() {
// Wire up timer implementation that is driven by MojoHandleWatcher.
VMLibraryHooks.eventHandlerSendData = MojoHandleWatcher.timer;
VMLibraryHooks.timerMillisecondClock = MojoCoreNatives.timerMillisecondClock;
assert(() {
// In debug mode, register the schedule frame extension.
developer.registerExtension('ext.ui.window.scheduleFrame', _scheduleFrame);
Expand Down
24 changes: 13 additions & 11 deletions lib/ui/painting/image_decoding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#include "flutter/common/threads.h"
#include "flutter/flow/bitmap_image.h"
#include "flutter/flow/texture_image.h"
#include "flutter/glue/movable_wrapper.h"
#include "flutter/glue/trace_event.h"
#include "flutter/lib/ui/painting/image.h"
#include "flutter/lib/ui/painting/resource_context.h"
#include "lib/ftl/functional/make_copyable.h"
#include "lib/tonic/dart_persistent_value.h"
#include "lib/tonic/dart_state.h"
#include "lib/tonic/logging/dart_invoke.h"
Expand Down Expand Up @@ -67,12 +67,13 @@ void InvokeImageCallback(sk_sp<SkImage> image,
}

void DecodeImageAndInvokeImageCallback(
glue::MovableWrapper<std::unique_ptr<DartPersistentValue>> callback,
std::unique_ptr<DartPersistentValue> callback,
std::vector<uint8_t> buffer) {
sk_sp<SkImage> image = DecodeImage(std::move(buffer));
Threads::UI()->PostTask([callback, image]() mutable {
InvokeImageCallback(image, callback.Unwrap());
});
Threads::UI()->PostTask(
ftl::MakeCopyable([ callback = std::move(callback), image ]() mutable {
InvokeImageCallback(image, std::move(callback));
}));
}

void DecodeImageFromList(Dart_NativeArguments args) {
Expand All @@ -91,15 +92,16 @@ void DecodeImageFromList(Dart_NativeArguments args) {
return;
}

auto callback = glue::WrapMovable(std::unique_ptr<DartPersistentValue>(
new DartPersistentValue(tonic::DartState::Current(), callback_handle)));

const uint8_t* bytes = reinterpret_cast<const uint8_t*>(list.data());
std::vector<uint8_t> buffer(bytes, bytes + list.num_elements());

Threads::IO()->PostTask([ callback, buffer = std::move(buffer) ]() mutable {
DecodeImageAndInvokeImageCallback(callback, std::move(buffer));
});
Threads::IO()->PostTask(ftl::MakeCopyable([
callback = std::make_unique<DartPersistentValue>(
tonic::DartState::Current(), callback_handle),
buffer = std::move(buffer)
]() mutable {
DecodeImageAndInvokeImageCallback(std::move(callback), std::move(buffer));
}));
}

} // namespace
Expand Down
1 change: 0 additions & 1 deletion lib/ui/ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import 'dart:async';
import 'dart:convert';
import 'dart:developer' as developer;
import 'dart:math' as math;
import 'dart:mojo.internal';
import 'dart:nativewrappers';
import 'dart:typed_data';

Expand Down
6 changes: 2 additions & 4 deletions runtime/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ action("gen_embedded_resources_cc") {
"--output",
rebase_path(output_file),
"--outer_namespace",
"mojo", # TODO(abarth): Change namespace.
"flutter",
"--inner_namespace",
"dart", # TODO(abarth): Change namespace.
"runtime",
"--table_name",
"flutter_embedded_service_isolate",
"--root_prefix",
Expand Down Expand Up @@ -71,13 +71,11 @@ source_set("runtime") {
"//flutter/flow",
"//flutter/glue",
"//flutter/lib/io",
"//flutter/lib/mojo",
"//flutter/lib/ui",
"//flutter/skia",
"//flutter/sky/engine/platform",
"//lib/ftl",
"//lib/tonic",
"//mojo/public/platform/dart:mojo_internal_impl",
"//third_party/rapidjson",
]

Expand Down
6 changes: 2 additions & 4 deletions runtime/dart_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "flutter/common/threads.h"
#include "flutter/glue/trace_event.h"
#include "flutter/lib/io/dart_io.h"
#include "flutter/lib/mojo/dart_mojo_internal.h"
#include "flutter/lib/ui/dart_runtime_hooks.h"
#include "flutter/lib/ui/dart_ui.h"
#include "flutter/lib/ui/ui_dart_state.h"
Expand Down Expand Up @@ -137,8 +136,8 @@ void DartController::CreateIsolateFor(const std::string& script_uri,
char* error = nullptr;
Dart_Isolate isolate = Dart_CreateIsolate(
script_uri.c_str(), "main",
reinterpret_cast<uint8_t*>(DART_SYMBOL(kIsolateSnapshot)),
nullptr, static_cast<tonic::DartState*>(state.get()), &error);
reinterpret_cast<uint8_t*>(DART_SYMBOL(kIsolateSnapshot)), nullptr,
static_cast<tonic::DartState*>(state.get()), &error);
FTL_CHECK(isolate) << error;
ui_dart_state_ = state.release();
dart_state()->message_handler().Initialize(blink::Threads::UI());
Expand All @@ -153,7 +152,6 @@ void DartController::CreateIsolateFor(const std::string& script_uri,
tonic::DartApiScope dart_api_scope;
DartIO::InitForIsolate();
DartUI::InitForIsolate();
DartMojoInternal::InitForIsolate();
DartRuntimeHooks::Install(DartRuntimeHooks::MainIsolate, script_uri);

std::unique_ptr<tonic::DartClassProvider> ui_class_provider(
Expand Down
Loading

0 comments on commit 63e7180

Please sign in to comment.