Skip to content

Commit

Permalink
Add support for child view on Fuchsia (flutter#3217)
Browse files Browse the repository at this point in the history
  • Loading branch information
abarth authored Nov 11, 2016
1 parent c118c7e commit 5d13dc0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
3 changes: 2 additions & 1 deletion content_handler/rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ void Rasterizer::Draw(std::unique_ptr<flow::LayerTree> layer_tree,
root_node->op->set_image(mozart::ImageNodeOp::New());
root_node->op->get_image()->content_rect = bounds.Clone();
root_node->op->get_image()->image_resource_id = kContentImageResourceId;
update->nodes.insert(kRootNodeId, std::move(root_node));

layer_tree->UpdateScene(update.get(), root_node.get());

update->nodes.insert(kRootNodeId, std::move(root_node));
} else {
update->nodes.insert(kRootNodeId, mozart::Node::New());
}
Expand Down
13 changes: 13 additions & 0 deletions content_handler/runtime_holder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ void RuntimeHolder::DidCreateMainIsolate(Dart_Isolate isolate) {
if (asset_store_)
blink::AssetFontSelector::Install(asset_store_);
InitFidlInternal();
InitMozartInternal();
}

void RuntimeHolder::InitFidlInternal() {
Expand Down Expand Up @@ -200,6 +201,18 @@ void RuntimeHolder::InitFidlInternal() {
DartConverter<mx::channel>::ToDart(outgoing_services_.PassChannel())));
}

void RuntimeHolder::InitMozartInternal() {
fidl::InterfaceHandle<mozart::ViewContainer> view_container;
view_->GetContainer(fidl::GetProxy(&view_container));

Dart_Handle mozart_internal =
Dart_LookupLibrary(ToDart("dart:mozart.internal"));

DART_CHECK_VALID(Dart_SetField(
mozart_internal, ToDart("_viewContainer"),
DartConverter<mx::channel>::ToDart(view_container.PassHandle())));
}

void RuntimeHolder::InitRootBundle(std::vector<char> bundle) {
root_bundle_data_ = std::move(bundle);
asset_store_ = ftl::MakeRefCounted<blink::ZipAssetStore>(
Expand Down
1 change: 1 addition & 0 deletions content_handler/runtime_holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class RuntimeHolder : public blink::RuntimeDelegate,
void HandleAssetPlatformMessage(ftl::RefPtr<blink::PlatformMessage> message);

void InitFidlInternal();
void InitMozartInternal();

void BeginFrame();
void OnFrameComplete();
Expand Down
6 changes: 3 additions & 3 deletions lib/io/dart_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_TONIC_DART_IO_H_
#define FLUTTER_TONIC_DART_IO_H_
#ifndef FLUTTER_LIB_IO_DART_IO_H_
#define FLUTTER_LIB_IO_DART_IO_H_

#include "lib/ftl/macros.h"

Expand All @@ -19,4 +19,4 @@ class DartIO {

} // namespace blink

#endif // FLUTTER_TONIC_DART_IO_H_
#endif // FLUTTER_LIB_IO_DART_IO_H_
9 changes: 7 additions & 2 deletions lib/snapshot/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import("//flutter/lib/ui/dart_ui.gni")
target_is_fuchsia = target_os == "fuchsia"

if (target_is_fuchsia) {
import("//apps/mozart/lib/flutter/sdk_ext/sdk_ext.gni")
import("//lib/fidl/dart/sdk_ext/sdk_ext.gni")
}

Expand Down Expand Up @@ -81,9 +82,13 @@ action("generate_snapshot_bin") {
]

if (target_is_fuchsia) {
inputs += fidl_dart_sdk_ext_files
inputs += fidl_dart_sdk_ext_files + mozart_dart_sdk_ext_files
fidl_internal_path = rebase_path(fidl_dart_sdk_ext_lib)
args += [ "--url_mapping=dart:fidl.internal,$fidl_internal_path" ]
mozart_internal_path = rebase_path(mozart_dart_sdk_ext_lib)
args += [
"--url_mapping=dart:fidl.internal,$fidl_internal_path",
"--url_mapping=dart:mozart.internal,$mozart_internal_path",
]
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/snapshot/snapshot_fuchsia.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ import 'dart:fidl.internal';
import 'dart:io';
import 'dart:isolate';
import 'dart:math';
import 'dart:mozart.internal';
import 'dart:typed_data';
import 'dart:ui';

0 comments on commit 5d13dc0

Please sign in to comment.