From 8cfd887da79077b376774fcaa855e8e6b76c4918 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Wed, 10 Aug 2016 14:03:19 -0700 Subject: [PATCH] Get //flutter/flow building on Fuchsia (flutter/engine#2899) --- engine/src/flutter/BUILD.gn | 2 +- engine/src/flutter/flow/BUILD.gn | 12 ++++++-- .../flutter/flow/layers/child_scene_layer.cc | 30 +++++++++++++++++-- engine/src/flutter/flow/open_gl.h | 8 ++--- engine/src/flutter/skia/BUILD.gn | 12 ++++++++ 5 files changed, 54 insertions(+), 10 deletions(-) diff --git a/engine/src/flutter/BUILD.gn b/engine/src/flutter/BUILD.gn index 17fcaf2d33..06c4503fc6 100644 --- a/engine/src/flutter/BUILD.gn +++ b/engine/src/flutter/BUILD.gn @@ -2,11 +2,11 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# This target will be built if no target is specified when invoking ninja. group("flutter") { testonly = true deps = [ + "//flutter/flow", "//flutter/glue", ] diff --git a/engine/src/flutter/flow/BUILD.gn b/engine/src/flutter/flow/BUILD.gn index f993e6e0bd..73f69c02d1 100644 --- a/engine/src/flutter/flow/BUILD.gn +++ b/engine/src/flutter/flow/BUILD.gn @@ -47,9 +47,17 @@ source_set("flow") { deps = [ "//flutter/glue", + "//flutter/skia", "//lib/ftl", "//mojo/services/gfx/composition/interfaces", - "//mojo/skia", - "//flutter/skia", ] + + if (is_fuchsia) { + # TODO(abarth): In principle, we should add "//mojo/public/c/gpu" as a + # dependency, but that doesn't work currently because GPU support on Fuchsia + # is still a work in progress. + include_dirs = [ + "//mojo/public/c/gpu", + ] + } } diff --git a/engine/src/flutter/flow/layers/child_scene_layer.cc b/engine/src/flutter/flow/layers/child_scene_layer.cc index 84db5ab9b5..de9cb37070 100644 --- a/engine/src/flutter/flow/layers/child_scene_layer.cc +++ b/engine/src/flutter/flow/layers/child_scene_layer.cc @@ -4,13 +4,37 @@ #include "flutter/flow/layers/child_scene_layer.h" -#include "mojo/skia/type_converters.h" - namespace flow { +namespace { + +mojo::TransformPtr GetTransformFromSkMatrix(const SkMatrix& input) { + // Expand 3x3 to 4x4. + auto output = mojo::Transform::New(); + output->matrix.resize(16u); + output->matrix[0] = input[0]; + output->matrix[1] = input[1]; + output->matrix[2] = 0.f; + output->matrix[3] = input[2]; + output->matrix[4] = input[3]; + output->matrix[5] = input[4]; + output->matrix[6] = 0.f; + output->matrix[7] = input[5]; + output->matrix[8] = 0.f; + output->matrix[9] = 0.f; + output->matrix[10] = 1.f; + output->matrix[11] = 0.f; + output->matrix[12] = input[6]; + output->matrix[13] = input[7]; + output->matrix[14] = 0.f; + output->matrix[15] = input[8]; + return output.Pass(); +} // TODO(abarth): We need to figure out how to allocate these ids sensibly. static uint32_t next_id = 10; +} // namespace + ChildSceneLayer::ChildSceneLayer() : device_pixel_ratio_(1.0f) {} ChildSceneLayer::~ChildSceneLayer() {} @@ -42,7 +66,7 @@ void ChildSceneLayer::UpdateScene(mojo::gfx::composition::SceneUpdate* update, child_node->content_clip = mojo::RectF::New(); child_node->content_clip->width = physical_size_.width(); child_node->content_clip->height = physical_size_.height(); - child_node->content_transform = mojo::Transform::From(transform_); + child_node->content_transform = GetTransformFromSkMatrix(transform_); update->nodes.insert(id, child_node.Pass()); container->child_node_ids.push_back(id); } diff --git a/engine/src/flutter/flow/open_gl.h b/engine/src/flutter/flow/open_gl.h index b9beaad678..9058355d8a 100644 --- a/engine/src/flutter/flow/open_gl.h +++ b/engine/src/flutter/flow/open_gl.h @@ -7,19 +7,19 @@ #include "lib/ftl/build_config.h" -#if OS_IOS +#if defined(OS_IOS) #include -#elif OS_MACOSX +#elif defined(OS_MACOSX) #include -#elif OS_ANDROID +#elif defined(OS_ANDROID) || defined(OS_FUCHSIA) #include -#elif OS_LINUX +#elif defined(OS_LINUX) #include diff --git a/engine/src/flutter/skia/BUILD.gn b/engine/src/flutter/skia/BUILD.gn index c8b2ef3855..ea05bcbe09 100644 --- a/engine/src/flutter/skia/BUILD.gn +++ b/engine/src/flutter/skia/BUILD.gn @@ -2,6 +2,16 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +if (is_fuchsia) { + +group("skia") { + # TODO(abarth): Switch the non-Fuchsia build over to using Skia's BUILD.gn + # files as well. + public_deps = [ "//third_party/skia" ] +} + +} else { + import("//build/config/features.gni") import("//build/config/ui.gni") import("//testing/test.gni") @@ -553,3 +563,5 @@ source_set("skia_opts") { visibility = [ ":skia" ] } + +} # if (is_fuchsia)