From 18e43c93ede3aaf8fa5bd6b93e42c4c495ce8e65 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 (#2899) --- BUILD.gn | 2 +- flow/BUILD.gn | 12 ++++++++++-- flow/layers/child_scene_layer.cc | 30 +++++++++++++++++++++++++++--- flow/open_gl.h | 8 ++++---- skia/BUILD.gn | 12 ++++++++++++ 5 files changed, 54 insertions(+), 10 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 17fcaf2d3..06c4503fc 100644 --- a/BUILD.gn +++ b/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/flow/BUILD.gn b/flow/BUILD.gn index f993e6e0b..73f69c02d 100644 --- a/flow/BUILD.gn +++ b/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/flow/layers/child_scene_layer.cc b/flow/layers/child_scene_layer.cc index 84db5ab9b..de9cb3707 100644 --- a/flow/layers/child_scene_layer.cc +++ b/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/flow/open_gl.h b/flow/open_gl.h index b9beaad67..9058355d8 100644 --- a/flow/open_gl.h +++ b/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/skia/BUILD.gn b/skia/BUILD.gn index c8b2ef385..ea05bcbe0 100644 --- a/skia/BUILD.gn +++ b/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) -- GitLab