diff --git a/BUILD.gn b/BUILD.gn index 1ae4a19c64803..6e48015b1d769 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -4,6 +4,10 @@ import("$flutter_root/common/config.gni") +if (is_fuchsia) { + import("//build/fuchsia/sdk.gni") +} + # Whether to build the dartdevc sdk, libraries, and source files # required for the flutter web sdk. declare_args() { @@ -24,6 +28,10 @@ group("flutter") { public_deps += [ "$flutter_root/shell/testing" ] } + if (is_fuchsia && using_fuchsia_sdk) { + public_deps += [ "$flutter_root/shell/platform/fuchsia" ] + } + if (!is_fuchsia && !is_fuchsia_host) { if (current_toolchain == host_toolchain) { public_deps += [ diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index eca6c7ddc273a..101f997c3c33f 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -736,7 +736,6 @@ FILE: ../../../flutter/third_party/txt/src/txt/platform.h FILE: ../../../flutter/third_party/txt/src/txt/platform_android.cc FILE: ../../../flutter/third_party/txt/src/txt/platform_linux.cc FILE: ../../../flutter/third_party/txt/src/txt/platform_mac.mm -FILE: ../../../flutter/vulkan/skia_vulkan_header.h FILE: ../../../flutter/vulkan/vulkan_application.cc FILE: ../../../flutter/vulkan/vulkan_application.h FILE: ../../../flutter/vulkan/vulkan_backbuffer.cc diff --git a/common/config.gni b/common/config.gni index 315621ccf4a67..8d92c84037545 100644 --- a/common/config.gni +++ b/common/config.gni @@ -6,6 +6,10 @@ if (is_android) { import("//build/config/android/config.gni") } +if (is_fuchsia) { + import("//build/fuchsia/sdk.gni") +} + if (target_cpu == "arm" || target_cpu == "arm64") { import("//build/config/arm.gni") } @@ -38,3 +42,7 @@ if (flutter_runtime_mode == "debug") { } else { feature_defines_list += [ "FLUTTER_RUNTIME_MODE=0" ] } + +if (is_fuchsia && using_fuchsia_sdk) { + feature_defines_list += [ "FUCHSIA_SDK=1" ] +} diff --git a/flow/BUILD.gn b/flow/BUILD.gn index 42e431fe057c3..603682f3cc278 100644 --- a/flow/BUILD.gn +++ b/flow/BUILD.gn @@ -2,6 +2,10 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +if (is_fuchsia) { + import("//build/fuchsia/sdk.gni") +} + source_set("flow") { sources = [ "compositor_context.cc", @@ -80,13 +84,19 @@ source_set("flow") { "view_holder.h", ] - public_deps += [ - "//sdk/fidl/fuchsia.ui.scenic", - "//sdk/fidl/fuchsia.ui.views", - "//sdk/lib/ui/scenic/cpp", - "//topaz/public/dart-pkg/zircon", - "//zircon/public/lib/zx", - ] + if (using_fuchsia_sdk) { + public_deps += [ + "$fuchsia_sdk_root/fidl:fuchsia.ui.gfx", + "$fuchsia_sdk_root/pkg:scenic_cpp", + ] + } else { + public_deps += [ + "//garnet/public/lib/ui/scenic/cpp", + "//sdk/fidl/fuchsia.ui.scenic", + "//topaz/public/dart-pkg/zircon", + "//zircon/public/lib/zx", + ] + } } } @@ -98,7 +108,6 @@ executable("flow_unittests") { "flow_test_utils.cc", "flow_test_utils.h", "layers/performance_overlay_layer_unittests.cc", - "layers/physical_shape_layer_unittests.cc", "matrix_decomposition_unittests.cc", "raster_cache_unittests.cc", ] diff --git a/flow/scene_update_context.cc b/flow/scene_update_context.cc index 4e81ed4e668ba..896795df3b7af 100644 --- a/flow/scene_update_context.cc +++ b/flow/scene_update_context.cc @@ -7,7 +7,6 @@ #include "flutter/flow/layers/layer.h" #include "flutter/flow/matrix_decomposition.h" #include "flutter/fml/trace_event.h" -#include "flutter/lib/ui/window/viewport_metrics.h" namespace flutter { @@ -301,7 +300,7 @@ SceneUpdateContext::Frame::Frame(SceneUpdateContext& context, paint_bounds_(SkRect::MakeEmpty()), layer_(layer) { if (local_elevation != 0.0) { - if (depth > flutter::kUnsetDepth && world_elevation >= depth) { + if (depth > -1 && world_elevation >= depth) { // TODO(mklim): Deal with bounds overflow correctly. FML_LOG(ERROR) << "Elevation " << world_elevation << " is outside of " << depth; diff --git a/fml/BUILD.gn b/fml/BUILD.gn index cb53afa12da56..b70d5963ceab9 100644 --- a/fml/BUILD.gn +++ b/fml/BUILD.gn @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/fuchsia/sdk.gni") + source_set("fml") { sources = [ "arraysize.h", @@ -83,7 +85,10 @@ source_set("fml") { configs += [ "//third_party/icu:icu_config" ] - public_configs = [ "$flutter_root:config" ] + public_configs = [ + "$flutter_root:config", + "$flutter_root/common:flutter_config", + ] libs = [] @@ -153,7 +158,9 @@ source_set("fml") { if (is_fuchsia) { sources += [ "platform/fuchsia/paths_fuchsia.cc" ] - public_deps += [ "//zircon/public/lib/trace" ] + if (!using_fuchsia_sdk) { + public_deps += [ "//zircon/public/lib/trace" ] + } } if (is_win) { diff --git a/fml/trace_event.h b/fml/trace_event.h index a036292a01d9a..9f86bcfa04b0c 100644 --- a/fml/trace_event.h +++ b/fml/trace_event.h @@ -8,6 +8,7 @@ #include "flutter/fml/build_config.h" #if defined(OS_FUCHSIA) +#if !defined(FUCHSIA_SDK) // Forward to the system tracing mechanism on Fuchsia. @@ -27,7 +28,8 @@ #define TRACE_EVENT_ASYNC_END1(a, b, c, d, e) TRACE_ASYNC_END(a, b, c, d, e) #define TRACE_EVENT_INSTANT0(a, b) TRACE_INSTANT(a, b, TRACE_SCOPE_THREAD) -#endif // defined(OS_FUCHSIA) +#endif // !defined(FUCHSIA_SDK) +#endif // defined(OS_FUCHSIA) #include #include @@ -39,8 +41,7 @@ #include "flutter/fml/time/time_point.h" #include "third_party/dart/runtime/include/dart_tools_api.h" -#if !defined(OS_FUCHSIA) - +#if !defined(OS_FUCHSIA) || defined(FUCHSIA_SDK) #ifndef TRACE_EVENT_HIDE_MACROS #define __FML__TOKEN_CAT__(x, y) x##y @@ -103,8 +104,7 @@ ::fml::tracing::TraceEventFlowEnd0(category, name, id); #endif // TRACE_EVENT_HIDE_MACROS - -#endif // !defined(OS_FUCHSIA) +#endif // !defined(OS_FUCHSIA) || defined(FUCHSIA_SDK) namespace fml { namespace tracing { diff --git a/lib/snapshot/BUILD.gn b/lib/snapshot/BUILD.gn index 8ab94ab12751b..878fbf217d73d 100644 --- a/lib/snapshot/BUILD.gn +++ b/lib/snapshot/BUILD.gn @@ -3,6 +3,7 @@ # found in the LICENSE file. import("//build/compiled_action.gni") +import("//build/fuchsia/sdk.gni") import("//third_party/dart/utils/compile_platform.gni") import("$flutter_root/common/config.gni") import("$flutter_root/lib/ui/dart_ui.gni") @@ -10,6 +11,7 @@ import("$flutter_root/lib/ui/dart_ui.gni") bindings_output_dir = "$root_gen_dir/sky/bindings" copy("generate_dart_ui") { + visibility = [ ":*" ] sources = dart_ui_files outputs = [ @@ -20,7 +22,7 @@ copy("generate_dart_ui") { compiled_action("generate_snapshot_bin") { tool = "//third_party/dart/runtime/bin:gen_snapshot" - if (is_fuchsia || is_fuchsia_host) { + if ((is_fuchsia || is_fuchsia_host) && !using_fuchsia_sdk) { platform_kernel = "$root_out_dir/flutter_runner_patched_sdk/platform_strong.dill" } else { @@ -56,8 +58,7 @@ compiled_action("generate_snapshot_bin") { rebase_path(isolate_snapshot_instructions), ] - if (is_debug && flutter_runtime_mode != "profile" && - flutter_runtime_mode != "release") { + if (is_debug) { args += [ "--enable_asserts" ] } @@ -206,7 +207,7 @@ bin_to_linkable("platform_strong_dill_linkable") { deps = [ ":kernel_platform_files", ] - if (is_fuchsia || is_fuchsia_host) { + if ((is_fuchsia || is_fuchsia_host) && !using_fuchsia_sdk) { input = "$root_out_dir/flutter_runner_patched_sdk/platform_strong.dill" } else { input = "$root_out_dir/flutter_patched_sdk/platform_strong.dill" @@ -231,6 +232,23 @@ source_set("snapshot") { get_target_outputs(":platform_strong_dill_linkable") } +compile_platform("non_strong_platform") { + single_root_scheme = "org-dartlang-sdk" + single_root_base = rebase_path("../../../") + libraries_specification_uri = + "org-dartlang-sdk:///flutter/lib/snapshot/libraries.json" + + outputs = [ + "$root_out_dir/flutter_patched_sdk/platform.dill", + "$root_out_dir/flutter_patched_sdk/vm_outline.dill", + ] + + args = [ + "--target=flutter", + "dart:core", + ] +} + compile_platform("strong_platform") { single_root_scheme = "org-dartlang-sdk" single_root_base = rebase_path("../../../") @@ -254,7 +272,7 @@ compile_platform("strong_platform") { } # Fuchsia's snapshot requires a different platform with extra dart: libraries. -if (is_fuchsia || is_fuchsia_host) { +if ((is_fuchsia || is_fuchsia_host) && !using_fuchsia_sdk) { group("kernel_platform_files") { public_deps = [ "//topaz/runtime/flutter_runner/kernel:kernel_platform_files", diff --git a/lib/ui/BUILD.gn b/lib/ui/BUILD.gn index bef50753a4b9e..fb8526c06cdff 100644 --- a/lib/ui/BUILD.gn +++ b/lib/ui/BUILD.gn @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/fuchsia/sdk.gni") + source_set("ui") { sources = [ "compositing/scene.cc", @@ -121,6 +123,14 @@ source_set("ui") { "compositing/scene_host.h", ] - deps += [ "//topaz/public/dart-pkg/zircon" ] + if (using_fuchsia_sdk) { + deps += [ + "$flutter_root/shell/platform/fuchsia/dart-pkg/fuchsia", + "$flutter_root/shell/platform/fuchsia/dart-pkg/zircon", + "$fuchsia_sdk_root/pkg:async-cpp", + ] + } else { + deps += [ "//topaz/public/dart-pkg/zircon" ] + } } } diff --git a/lib/ui/compositing/scene_host.cc b/lib/ui/compositing/scene_host.cc index 56aea7a61afdb..b04eb64ecd97b 100644 --- a/lib/ui/compositing/scene_host.cc +++ b/lib/ui/compositing/scene_host.cc @@ -4,7 +4,6 @@ #include "flutter/lib/ui/compositing/scene_host.h" -#include #include #include #include @@ -75,6 +74,13 @@ void InvokeDartFunction(tonic::DartPersistentValue* function, T& arg) { } } +zx_koid_t GetKoid(zx_handle_t handle) { + zx_info_handle_basic_t info; + zx_status_t status = zx_object_get_info(handle, ZX_INFO_HANDLE_BASIC, &info, + sizeof(info), nullptr, nullptr); + return status == ZX_OK ? info.koid : ZX_KOID_INVALID; +} + } // namespace namespace flutter { @@ -113,7 +119,7 @@ fml::RefPtr SceneHost::CreateViewHolder( SceneHost::SceneHost(fml::RefPtr exportTokenHandle) : gpu_task_runner_( UIDartState::Current()->GetTaskRunners().GetGPUTaskRunner()), - id_(fsl::GetKoid(exportTokenHandle->handle())), + id_(GetKoid(exportTokenHandle->handle())), use_view_holder_(false) { gpu_task_runner_->PostTask( [id = id_, handle = std::move(exportTokenHandle)]() { @@ -128,7 +134,7 @@ SceneHost::SceneHost(fml::RefPtr viewHolderTokenHandle, Dart_Handle viewStateChangedCallback) : gpu_task_runner_( UIDartState::Current()->GetTaskRunners().GetGPUTaskRunner()), - id_(fsl::GetKoid(viewHolderTokenHandle->handle())), + id_(GetKoid(viewHolderTokenHandle->handle())), use_view_holder_(true) { if (Dart_IsClosure(viewConnectedCallback)) { view_connected_callback_ = std::make_unique( diff --git a/lib/ui/compositing/scene_host.h b/lib/ui/compositing/scene_host.h index 38c4503eb74a2..9db18e3069f29 100644 --- a/lib/ui/compositing/scene_host.h +++ b/lib/ui/compositing/scene_host.h @@ -5,12 +5,12 @@ #ifndef FLUTTER_LIB_UI_COMPOSITING_SCENE_HOST_H_ #define FLUTTER_LIB_UI_COMPOSITING_SCENE_HOST_H_ -#include #include #include #include #include #include +#include "dart-pkg/zircon/sdk_ext/handle.h" #include "flutter/fml/memory/ref_counted.h" #include "flutter/fml/task_runner.h" diff --git a/shell/common/skia_event_tracer_impl.cc b/shell/common/skia_event_tracer_impl.cc index a44a39b214e68..514e4e7f3d002 100644 --- a/shell/common/skia_event_tracer_impl.cc +++ b/shell/common/skia_event_tracer_impl.cc @@ -32,7 +32,7 @@ class FlutterEventTracer : public SkEventTracer { const uint8_t* p_arg_types, const uint64_t* p_arg_values, uint8_t flags) override { -#if defined(OS_FUCHSIA) +#if defined(OS_FUCHSIA) && !defined(FUCHSIA_SDK) // In a manner analogous to "fml/trace_event.h", use Fuchsia's system // tracing macros when running on Fuchsia. switch (phase) { @@ -85,7 +85,7 @@ class FlutterEventTracer : public SkEventTracer { SkEventTracer::Handle handle) override { // This is only ever called from a scoped trace event so we will just end // the section. -#if defined(OS_FUCHSIA) +#if defined(OS_FUCHSIA) && !defined(FUCHSIA_SDK) TRACE_DURATION_END(kSkiaTag, name); #else fml::tracing::TraceEventEnd(name); diff --git a/shell/testing/BUILD.gn b/shell/testing/BUILD.gn index f10d36b9808e8..c8bf964540181 100644 --- a/shell/testing/BUILD.gn +++ b/shell/testing/BUILD.gn @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/fuchsia/sdk.gni") + executable("testing") { testonly = true @@ -25,7 +27,7 @@ executable("testing") { "//third_party/tonic", ] - if (is_fuchsia) { + if (is_fuchsia && !is_fuchsia_sdk) { deps += [ "//garnet/public/lib/ui/scenic:client", "//zircon/public/lib/trace", diff --git a/sky/packages/sky_engine/BUILD.gn b/sky/packages/sky_engine/BUILD.gn index 707982b45ec12..a626459378998 100644 --- a/sky/packages/sky_engine/BUILD.gn +++ b/sky/packages/sky_engine/BUILD.gn @@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/fuchsia/sdk.gni") import("//third_party/dart/sdk/lib/_http/http_sources.gni") import("//third_party/dart/sdk/lib/async/async_sources.gni") import("//third_party/dart/sdk/lib/collection/collection_sources.gni") @@ -13,7 +14,6 @@ import("//third_party/dart/sdk/lib/io/io_sources.gni") import("//third_party/dart/sdk/lib/isolate/isolate_sources.gni") import("//third_party/dart/sdk/lib/math/math_sources.gni") import("//third_party/dart/sdk/lib/typed_data/typed_data_sources.gni") - import("$flutter_root/build/dart/rules.gni") import("$flutter_root/lib/ui/dart_ui.gni") @@ -170,7 +170,7 @@ dart_pkg("sky_engine") { ] } -if (is_fuchsia) { +if (is_fuchsia && !using_fuchsia_sdk) { import("//build/dart/dart_library.gni") dart_library("sky_engine_dart") { diff --git a/tools/gn b/tools/gn index ce9b7a6e8e5b1..ba88e7be2afa0 100755 --- a/tools/gn +++ b/tools/gn @@ -86,7 +86,7 @@ def to_gn_args(args): gn_args['skia_use_expat'] = args.target_os == 'android' gn_args['skia_use_fontconfig'] = False # Use the custom font manager instead. gn_args['is_official_build'] = True # Disable Skia test utilities. - + gn_args['dart_component_kind'] = 'static_library' # Always link Dart in statically. gn_args['is_debug'] = args.unoptimized gn_args['android_full_debug'] = args.target_os == 'android' and args.unoptimized gn_args['is_clang'] = not sys.platform.startswith(('cygwin', 'win')) @@ -256,12 +256,13 @@ def parse_args(args): parser.add_argument('--full-dart-debug', default=False, action='store_true', help='Implies --dart-debug ' + 'and also disables optimizations in the Dart VM making it easier to step through VM code in the debugger.') - parser.add_argument('--target-os', type=str, choices=['android', 'ios', 'linux']) + parser.add_argument('--target-os', type=str, choices=['android', 'ios', 'linux', 'fuchsia']) parser.add_argument('--android', dest='target_os', action='store_const', const='android') parser.add_argument('--android-cpu', type=str, choices=['arm', 'x64', 'x86', 'arm64'], default='arm') parser.add_argument('--ios', dest='target_os', action='store_const', const='ios') parser.add_argument('--ios-cpu', type=str, choices=['arm', 'arm64'], default='arm64') parser.add_argument('--simulator', action='store_true', default=False) + parser.add_argument('--fuchsia', dest='target_os', action='store_const', const='fuchsia') parser.add_argument('--linux-cpu', type=str, choices=['x64', 'x86', 'arm64', 'arm']) parser.add_argument('--arm-float-abi', type=str, choices=['hard', 'soft', 'softfp']) diff --git a/vulkan/BUILD.gn b/vulkan/BUILD.gn index 199dc9da7a90f..0ac6c00e3edc1 100644 --- a/vulkan/BUILD.gn +++ b/vulkan/BUILD.gn @@ -2,13 +2,21 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/fuchsia/sdk.gni") + config("vulkan_config") { - if (is_fuchsia) { + if (using_fuchsia_sdk) { + include_dirs = [ "$fuchsia_sdk_root/vulkan/include" ] + } else if (is_fuchsia) { include_dirs = [ "//third_party/vulkan_loader_and_validation_layers/include" ] } else { include_dirs = [ "//third_party/vulkan/src" ] } + + if (is_fuchsia) { + defines = [ "VK_USE_PLATFORM_FUCHSIA=1" ] + } } source_set("vulkan") { diff --git a/vulkan/skia_vulkan_header.h b/vulkan/skia_vulkan_header.h deleted file mode 100644 index 7af41d7b5ec29..0000000000000 --- a/vulkan/skia_vulkan_header.h +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifdef __ANDROID__ -#ifndef VK_USE_PLATFORM_ANDROID_KHR -#define VK_USE_PLATFORM_ANDROID_KHR 1 -#endif // VK_USE_PLATFORM_ANDROID_KHR -#endif // __ANDROID__ - -#include "third_party/vulkan/src/vulkan/vulkan.h" diff --git a/vulkan/vulkan_interface.h b/vulkan/vulkan_interface.h index 33b9c908b1da0..13f4ad9ffc44b 100644 --- a/vulkan/vulkan_interface.h +++ b/vulkan/vulkan_interface.h @@ -10,7 +10,9 @@ #include "flutter/fml/build_config.h" #include "flutter/fml/logging.h" +#if !defined(FUCHSIA_SDK) #define VULKAN_LINK_STATICALLY OS_FUCHSIA +#endif // !defined(FUCHSIA_SDK) #if OS_ANDROID #ifndef VK_USE_PLATFORM_ANDROID_KHR