From 5ffa09d4f1162811f9914bdd4b332cd0501106d8 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Sun, 30 Apr 2023 14:11:04 -0700 Subject: [PATCH 1/6] Add dart:gpu --- BUILD.gn | 5 +- impeller/fixtures/dart_tests.dart | 1 + lib/gpu/BUILD.gn | 53 ++++++++ lib/gpu/dart_gpu.cc | 73 ++++++++++ lib/gpu/dart_gpu.gni | 7 + lib/gpu/dart_gpu.h | 23 ++++ lib/gpu/gpu.dart | 166 +++++++++++++++++++++++ lib/snapshot/libraries.json | 3 + lib/snapshot/libraries.yaml | 2 + lib/snapshot/libraries_experimental.json | 3 + runtime/BUILD.gn | 1 + runtime/dart_isolate.cc | 3 + sky/packages/sky_engine/BUILD.gn | 12 ++ 13 files changed, 351 insertions(+), 1 deletion(-) create mode 100644 lib/gpu/BUILD.gn create mode 100644 lib/gpu/dart_gpu.cc create mode 100644 lib/gpu/dart_gpu.gni create mode 100644 lib/gpu/dart_gpu.h create mode 100644 lib/gpu/gpu.dart diff --git a/BUILD.gn b/BUILD.gn index d00ac7c9e234e..33053946e3f53 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -177,7 +177,10 @@ group("unittests") { } if (is_mac || is_linux || is_win) { - public_deps += [ "//flutter/impeller:impeller_unittests" ] + public_deps += [ + "//flutter/impeller:impeller_dart_unittests", + "//flutter/impeller:impeller_unittests", + ] } if (is_mac) { diff --git a/impeller/fixtures/dart_tests.dart b/impeller/fixtures/dart_tests.dart index 91240dd6c151c..b48e70bf813aa 100644 --- a/impeller/fixtures/dart_tests.dart +++ b/impeller/fixtures/dart_tests.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:ui'; +import 'dart:gpu'; void main() {} diff --git a/lib/gpu/BUILD.gn b/lib/gpu/BUILD.gn new file mode 100644 index 0000000000000..f5345542799b0 --- /dev/null +++ b/lib/gpu/BUILD.gn @@ -0,0 +1,53 @@ +# 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. + +import("//build/fuchsia/sdk.gni") +import("//flutter/common/config.gni") +import("//flutter/impeller/tools/impeller.gni") +import("//flutter/shell/config.gni") +import("//flutter/testing/testing.gni") + +source_set("gpu") { + cflags = [ + # Dart gives us doubles. Skia and Impeller work in floats. + # If Dart gives us a double > FLT_MAX or < -FLT_MAX, implicit conversion + # will convert it to either inf/-inf or FLT_MAX/-FLT_MAX (undefined + # behavior). This can result in surprising and difficult to debug behavior + # for Flutter application developers, so it should be explicitly handled + # via SafeNarrow. + "-Wimplicit-float-conversion", + ] + + if (is_win) { + # This causes build failures in third_party dependencies on Windows. + cflags += [ "-Wno-implicit-int-float-conversion" ] + } + + sources = [ + "dart_gpu.cc", + "dart_gpu.h", + ] + + public_configs = [ "//flutter:config" ] + + public_deps = [ + "//flutter/flow", + "//flutter/shell/common:platform_message_handler", + "//flutter/third_party/txt", + ] + + deps = [ + "//flutter/assets", + "//flutter/common", + "//flutter/common/graphics", + "//flutter/display_list", + "//flutter/fml", + "//flutter/impeller", + "//flutter/impeller/runtime_stage", + "//flutter/runtime:dart_plugin_registrant", + "//flutter/runtime:test_font", + "//flutter/third_party/tonic", + "//third_party/dart/runtime/bin:dart_io_api", + ] +} diff --git a/lib/gpu/dart_gpu.cc b/lib/gpu/dart_gpu.cc new file mode 100644 index 0000000000000..806425c14664a --- /dev/null +++ b/lib/gpu/dart_gpu.cc @@ -0,0 +1,73 @@ +// 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. + +#include "flutter/lib/gpu/dart_gpu.h" + +#include +#include + +#include "flutter/common/settings.h" +#include "flutter/fml/build_config.h" +#include "third_party/tonic/converter/dart_converter.h" +#include "third_party/tonic/dart_args.h" +#include "third_party/tonic/logging/dart_error.h" + +using tonic::ToDart; + +namespace flutter { + +#define FFI_FUNCTION_LIST(V) /* Constructors */ + +#define FFI_METHOD_LIST(V) /* Methods */ + +#define FFI_FUNCTION_INSERT(FUNCTION, ARGS) \ + g_function_dispatchers.insert(std::make_pair( \ + std::string_view(#FUNCTION), \ + reinterpret_cast( \ + tonic::FfiDispatcher::Call))); + +#define FFI_METHOD_INSERT(CLASS, METHOD, ARGS) \ + g_function_dispatchers.insert( \ + std::make_pair(std::string_view(#CLASS "::" #METHOD), \ + reinterpret_cast( \ + tonic::FfiDispatcher::Call))); + +namespace { + +std::once_flag g_dispatchers_init_flag; +std::unordered_map g_function_dispatchers; + +void* ResolveFfiNativeFunction(const char* name, uintptr_t args) { + auto it = g_function_dispatchers.find(name); + return (it != g_function_dispatchers.end()) ? it->second : nullptr; +} + +void InitDispatcherMap() { + FFI_FUNCTION_LIST(FFI_FUNCTION_INSERT) + FFI_METHOD_LIST(FFI_METHOD_INSERT) +} + +} // anonymous namespace + +void DartGPU::InitForIsolate(const Settings& settings) { + if (!settings.enable_impeller) { + return; + } + std::call_once(g_dispatchers_init_flag, InitDispatcherMap); + + auto dart_gpu = Dart_LookupLibrary(ToDart("dart:gpu")); + if (Dart_IsError(dart_gpu)) { + Dart_PropagateError(dart_gpu); + } + + // Set up FFI Native resolver for dart:ui. + Dart_Handle result = + Dart_SetFfiNativeResolver(dart_gpu, ResolveFfiNativeFunction); + if (Dart_IsError(result)) { + Dart_PropagateError(result); + } +} + +} // namespace flutter diff --git a/lib/gpu/dart_gpu.gni b/lib/gpu/dart_gpu.gni new file mode 100644 index 0000000000000..f196f0a057223 --- /dev/null +++ b/lib/gpu/dart_gpu.gni @@ -0,0 +1,7 @@ +# 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. + +dart_gpu_files = [ + "//flutter/lib/gpu/gpu.dart", +] diff --git a/lib/gpu/dart_gpu.h b/lib/gpu/dart_gpu.h new file mode 100644 index 0000000000000..7084774d7bd53 --- /dev/null +++ b/lib/gpu/dart_gpu.h @@ -0,0 +1,23 @@ +// 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. + +#ifndef FLUTTER_LIB_GPU_DART_GPU_H_ +#define FLUTTER_LIB_GPU_DART_GPU_H_ + +#include "flutter/common/settings.h" +#include "flutter/fml/macros.h" + +namespace flutter { + +class DartGPU { + public: + static void InitForIsolate(const Settings& settings); + + private: + FML_DISALLOW_IMPLICIT_CONSTRUCTORS(DartGPU); +}; + +} // namespace flutter + +#endif // FLUTTER_LIB_GPU_DART_UI_H_ diff --git a/lib/gpu/gpu.dart b/lib/gpu/gpu.dart new file mode 100644 index 0000000000000..1d875c46c93d7 --- /dev/null +++ b/lib/gpu/gpu.dart @@ -0,0 +1,166 @@ +// 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. + +// ignore_for_file: public_member_api_docs + +library dart.gpu; + +import 'dart:nativewrappers'; + +enum BlendOperation { add, subtract, reverseSubtract } + +enum BlendFactor { + zero, + one, + sourceColor, + oneMinusSourceColor, + sourceAlpha, + oneMinusSourceAlpha, + destinationColor, + oneMinusDestinationColor, + destinationAlpha, + oneMinusDestinationAlpha, + sourceAlphaSaturated, + blendColor, + oneMinusBlendColor, + blendAlpha, + oneMinusBlendAlpha, +} + +class BlendOptions { + const BlendOptions({ + this.colorOperation = BlendOperation.add, + this.sourceColorFactor = BlendFactor.one, + this.destinationColorFactor = BlendFactor.oneMinusSourceAlpha, + this.alphaOperation = BlendOperation.add, + this.sourceAlphaFactor = BlendFactor.one, + this.destinationAlphaFactor = BlendFactor.oneMinusSourceAlpha, + }); + + final BlendOperation colorOperation; + final BlendFactor sourceColorFactor; + final BlendFactor destinationColorFactor; + final BlendOperation alphaOperation; + final BlendFactor sourceAlphaFactor; + final BlendFactor destinationAlphaFactor; +} + +enum StencilOperation { + keep, + zero, + setToReferenceValue, + incrementClamp, + decrementClamp, + invert, + incrementWrap, + decrementWrap, +} + +enum CompareFunction { + never, + always, + less, + equal, + lessEqual, + greater, + notEqual, + greaterEqual, +} + +class StencilOptions { + const StencilOptions({ + this.operation = StencilOperation.incrementClamp, + this.compare = CompareFunction.always, + }); + + final StencilOperation operation; + final CompareFunction compare; +} + +enum ShaderType { + unknown, + voidType, + booleanType, + signedByteType, + unsignedByteType, + signedShortType, + unsignedShortType, + signedIntType, + unsignedIntType, + signedInt64Type, + unsignedInt64Type, + atomicCounterType, + halfFloatType, + floatType, + doubleType, + structType, + imageType, + sampledImageType, + samplerType, +} + +class VertexAttribute { + const VertexAttribute({ + this.name = '', + this.location = 0, + this.set = 0, + this.binding = 0, + this.type = ShaderType.floatType, + this.elements = 2, + }); + + final String name; + final int location; + final int set; + final int binding; + final ShaderType type; + final int elements; +} + +class UniformSlot { + const UniformSlot({ + this.name = '', + this.set = 0, + this.extRes0 = 0, + this.binding = 0, + }); + + final String name; + final int set; + final int extRes0; + final int binding; +} + +class Shader {} + +class RasterPipeline {} + +/// A handle to a graphics context. +/// +/// This class is created by the engine, and should not be instantiated +/// or extended directly. +/// +/// To obtain the default graphics context, use [getContext]. +@pragma('vm:entry-point') +class Context extends NativeFieldWrapperClass1 { + @pragma('vm:entry-point') + Context._(); + + //registerShaderLibrary() async + + Future createRasterPipeline({ + required Shader vertex, + required Shader fragment, + BlendOptions blendOptions = const BlendOptions(), + StencilOptions stencilOptions = const StencilOptions(), + List vertexLayout = const [], + List uniformLayout = const [], + }) async { + return RasterPipeline(); + } +} + +Context getContext() { + return Context._(); +} diff --git a/lib/snapshot/libraries.json b/lib/snapshot/libraries.json index 5e1ab2ffdf184..bdec8fed66834 100644 --- a/lib/snapshot/libraries.json +++ b/lib/snapshot/libraries.json @@ -11,6 +11,9 @@ "libraries": { "ui": { "uri": "../../lib/ui/ui.dart" + }, + "gpu": { + "uri": "../../lib/gpu/gpu.dart" } } } diff --git a/lib/snapshot/libraries.yaml b/lib/snapshot/libraries.yaml index 9d7c4275f0c49..e4e73393a5e78 100644 --- a/lib/snapshot/libraries.yaml +++ b/lib/snapshot/libraries.yaml @@ -17,5 +17,7 @@ flutter: libraries: ui: uri: "../../lib/ui/ui.dart" + gpu: + uri: "../../lib/gpu/gpu.dart" diff --git a/lib/snapshot/libraries_experimental.json b/lib/snapshot/libraries_experimental.json index 08577acb38ace..c8522395f74c1 100644 --- a/lib/snapshot/libraries_experimental.json +++ b/lib/snapshot/libraries_experimental.json @@ -11,6 +11,9 @@ "libraries": { "ui": { "uri": "../../lib/ui/experiments/ui.dart" + }, + "gpu": { + "uri": "../../lib/gpu/gpu.dart" } } } diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index 70e9172d51dd3..8d07eb8e1dfde 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -90,6 +90,7 @@ source_set("runtime") { } public_deps = [ + "//flutter/lib/gpu", "//flutter/lib/ui", "//third_party/rapidjson", ] diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index 791ac03dbbf95..9be3e35dbc55e 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -11,6 +11,7 @@ #include "flutter/fml/logging.h" #include "flutter/fml/posix_wrappers.h" #include "flutter/fml/trace_event.h" +#include "flutter/lib/gpu/dart_gpu.h" #include "flutter/lib/io/dart_io.h" #include "flutter/lib/ui/dart_runtime_hooks.h" #include "flutter/lib/ui/dart_ui.h" @@ -462,6 +463,8 @@ bool DartIsolate::LoadLibraries() { DartUI::InitForIsolate(GetIsolateGroupData().GetSettings()); + DartGPU::InitForIsolate(GetIsolateGroupData().GetSettings()); + const bool is_service_isolate = Dart_IsServiceIsolate(isolate()); DartRuntimeHooks::Install(IsRootIsolate() && !is_service_isolate, diff --git a/sky/packages/sky_engine/BUILD.gn b/sky/packages/sky_engine/BUILD.gn index 916c2b10788ca..0c9caba11487f 100644 --- a/sky/packages/sky_engine/BUILD.gn +++ b/sky/packages/sky_engine/BUILD.gn @@ -4,6 +4,8 @@ import("//build/fuchsia/sdk.gni") import("//flutter/build/dart/rules.gni") +import("//flutter/impeller/tools/impeller.gni") +import("//flutter/lib/gpu/dart_gpu.gni") import("//flutter/lib/ui/dart_ui.gni") import("//flutter/web_sdk/web_sdk.gni") import("//third_party/dart/sdk/lib/_http/http_sources.gni") @@ -188,6 +190,12 @@ web_ui_ui_web_with_output("copy_dart_ui_web") { output_dir = "$root_gen_dir/dart-pkg/sky_engine/lib/ui_web/" } +copy("copy_dart_gpu") { + sources = dart_gpu_files + + outputs = [ "$root_gen_dir/dart-pkg/sky_engine/lib/gpu/{{source_file_part}}" ] +} + copy("copy_allowed_experiments") { sources = [ "//third_party/dart/sdk/lib/_internal/allowed_experiments.json" ] @@ -276,6 +284,10 @@ dart_pkg("sky_engine") { ":copy_dart_ui_web", ] + if (impeller_enable_3d) { + deps += [ ":copy_dart_gpu" ] + } + if (!is_fuchsia) { deps += [ ":copy_sky_engine_authors" ] } From 54f1f76e1ee48d8f442e11e8b7e0164b51a044f2 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Mon, 1 May 2023 02:30:15 -0700 Subject: [PATCH 2/6] Fix dart_unittests --- impeller/fixtures/dart_tests.dart | 4 ++-- impeller/renderer/renderer_dart_unittests.cc | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/impeller/fixtures/dart_tests.dart b/impeller/fixtures/dart_tests.dart index b48e70bf813aa..a025ba660632c 100644 --- a/impeller/fixtures/dart_tests.dart +++ b/impeller/fixtures/dart_tests.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:ui'; -import 'dart:gpu'; +import 'dart:ui' as ui; +//import 'dart:gpu'; void main() {} diff --git a/impeller/renderer/renderer_dart_unittests.cc b/impeller/renderer/renderer_dart_unittests.cc index 2700fa4c23b41..d4c621b1aeae2 100644 --- a/impeller/renderer/renderer_dart_unittests.cc +++ b/impeller/renderer/renderer_dart_unittests.cc @@ -6,6 +6,8 @@ #include "flutter/common/settings.h" #include "flutter/common/task_runners.h" +#include "flutter/fml/backtrace.h" +#include "flutter/fml/command_line.h" #include "flutter/lib/ui/ui_dart_state.h" #include "flutter/runtime/dart_isolate.h" #include "flutter/runtime/dart_vm_lifecycle.h" @@ -21,6 +23,7 @@ #include "impeller/renderer/render_pass.h" #include "impeller/renderer/sampler_library.h" +#include "gtest/gtest.h" #include "third_party/imgui/imgui.h" namespace impeller { @@ -33,7 +36,12 @@ class RendererDartTest : public PlaygroundTest, : settings_(CreateSettingsForFixture()), vm_ref_(flutter::DartVMRef::Create(settings_)) { fml::MessageLoop::EnsureInitializedForCurrentThread(); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" current_task_runner_ = fml::MessageLoop::GetCurrent().GetTaskRunner(); +#pragma clang diagnostic pop + isolate_ = CreateDartIsolate(); assert(isolate_); assert(isolate_->get()->GetPhase() == flutter::DartIsolate::Phase::Running); @@ -85,3 +93,10 @@ TEST_P(RendererDartTest, CanRunDartInPlaygroundFrame) { } // namespace testing } // namespace impeller + +int main(int argc, char** argv) { + fml::InstallCrashHandler(); + testing::InitGoogleTest(&argc, argv); + fml::CommandLine cmd = fml::CommandLineFromPlatformOrArgcArgv(argc, argv); + return RUN_ALL_TESTS(); +} From ed60b5a81416c28c88da30c4ac0eff0a1ec491b7 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Sat, 6 May 2023 00:13:52 -0700 Subject: [PATCH 3/6] Move Dart GPU into ui/experiments --- lib/gpu/BUILD.gn | 53 ----------------- lib/gpu/dart_gpu.cc | 73 ------------------------ lib/gpu/dart_gpu.gni | 7 --- lib/gpu/dart_gpu.h | 23 -------- lib/snapshot/libraries.json | 3 - lib/snapshot/libraries.yaml | 2 - lib/snapshot/libraries_experimental.json | 3 - lib/{gpu => ui/experiments}/gpu.dart | 0 runtime/BUILD.gn | 1 - runtime/dart_isolate.cc | 3 - sky/packages/sky_engine/BUILD.gn | 12 ---- 11 files changed, 180 deletions(-) delete mode 100644 lib/gpu/BUILD.gn delete mode 100644 lib/gpu/dart_gpu.cc delete mode 100644 lib/gpu/dart_gpu.gni delete mode 100644 lib/gpu/dart_gpu.h rename lib/{gpu => ui/experiments}/gpu.dart (100%) diff --git a/lib/gpu/BUILD.gn b/lib/gpu/BUILD.gn deleted file mode 100644 index f5345542799b0..0000000000000 --- a/lib/gpu/BUILD.gn +++ /dev/null @@ -1,53 +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. - -import("//build/fuchsia/sdk.gni") -import("//flutter/common/config.gni") -import("//flutter/impeller/tools/impeller.gni") -import("//flutter/shell/config.gni") -import("//flutter/testing/testing.gni") - -source_set("gpu") { - cflags = [ - # Dart gives us doubles. Skia and Impeller work in floats. - # If Dart gives us a double > FLT_MAX or < -FLT_MAX, implicit conversion - # will convert it to either inf/-inf or FLT_MAX/-FLT_MAX (undefined - # behavior). This can result in surprising and difficult to debug behavior - # for Flutter application developers, so it should be explicitly handled - # via SafeNarrow. - "-Wimplicit-float-conversion", - ] - - if (is_win) { - # This causes build failures in third_party dependencies on Windows. - cflags += [ "-Wno-implicit-int-float-conversion" ] - } - - sources = [ - "dart_gpu.cc", - "dart_gpu.h", - ] - - public_configs = [ "//flutter:config" ] - - public_deps = [ - "//flutter/flow", - "//flutter/shell/common:platform_message_handler", - "//flutter/third_party/txt", - ] - - deps = [ - "//flutter/assets", - "//flutter/common", - "//flutter/common/graphics", - "//flutter/display_list", - "//flutter/fml", - "//flutter/impeller", - "//flutter/impeller/runtime_stage", - "//flutter/runtime:dart_plugin_registrant", - "//flutter/runtime:test_font", - "//flutter/third_party/tonic", - "//third_party/dart/runtime/bin:dart_io_api", - ] -} diff --git a/lib/gpu/dart_gpu.cc b/lib/gpu/dart_gpu.cc deleted file mode 100644 index 806425c14664a..0000000000000 --- a/lib/gpu/dart_gpu.cc +++ /dev/null @@ -1,73 +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. - -#include "flutter/lib/gpu/dart_gpu.h" - -#include -#include - -#include "flutter/common/settings.h" -#include "flutter/fml/build_config.h" -#include "third_party/tonic/converter/dart_converter.h" -#include "third_party/tonic/dart_args.h" -#include "third_party/tonic/logging/dart_error.h" - -using tonic::ToDart; - -namespace flutter { - -#define FFI_FUNCTION_LIST(V) /* Constructors */ - -#define FFI_METHOD_LIST(V) /* Methods */ - -#define FFI_FUNCTION_INSERT(FUNCTION, ARGS) \ - g_function_dispatchers.insert(std::make_pair( \ - std::string_view(#FUNCTION), \ - reinterpret_cast( \ - tonic::FfiDispatcher::Call))); - -#define FFI_METHOD_INSERT(CLASS, METHOD, ARGS) \ - g_function_dispatchers.insert( \ - std::make_pair(std::string_view(#CLASS "::" #METHOD), \ - reinterpret_cast( \ - tonic::FfiDispatcher::Call))); - -namespace { - -std::once_flag g_dispatchers_init_flag; -std::unordered_map g_function_dispatchers; - -void* ResolveFfiNativeFunction(const char* name, uintptr_t args) { - auto it = g_function_dispatchers.find(name); - return (it != g_function_dispatchers.end()) ? it->second : nullptr; -} - -void InitDispatcherMap() { - FFI_FUNCTION_LIST(FFI_FUNCTION_INSERT) - FFI_METHOD_LIST(FFI_METHOD_INSERT) -} - -} // anonymous namespace - -void DartGPU::InitForIsolate(const Settings& settings) { - if (!settings.enable_impeller) { - return; - } - std::call_once(g_dispatchers_init_flag, InitDispatcherMap); - - auto dart_gpu = Dart_LookupLibrary(ToDart("dart:gpu")); - if (Dart_IsError(dart_gpu)) { - Dart_PropagateError(dart_gpu); - } - - // Set up FFI Native resolver for dart:ui. - Dart_Handle result = - Dart_SetFfiNativeResolver(dart_gpu, ResolveFfiNativeFunction); - if (Dart_IsError(result)) { - Dart_PropagateError(result); - } -} - -} // namespace flutter diff --git a/lib/gpu/dart_gpu.gni b/lib/gpu/dart_gpu.gni deleted file mode 100644 index f196f0a057223..0000000000000 --- a/lib/gpu/dart_gpu.gni +++ /dev/null @@ -1,7 +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. - -dart_gpu_files = [ - "//flutter/lib/gpu/gpu.dart", -] diff --git a/lib/gpu/dart_gpu.h b/lib/gpu/dart_gpu.h deleted file mode 100644 index 7084774d7bd53..0000000000000 --- a/lib/gpu/dart_gpu.h +++ /dev/null @@ -1,23 +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. - -#ifndef FLUTTER_LIB_GPU_DART_GPU_H_ -#define FLUTTER_LIB_GPU_DART_GPU_H_ - -#include "flutter/common/settings.h" -#include "flutter/fml/macros.h" - -namespace flutter { - -class DartGPU { - public: - static void InitForIsolate(const Settings& settings); - - private: - FML_DISALLOW_IMPLICIT_CONSTRUCTORS(DartGPU); -}; - -} // namespace flutter - -#endif // FLUTTER_LIB_GPU_DART_UI_H_ diff --git a/lib/snapshot/libraries.json b/lib/snapshot/libraries.json index bdec8fed66834..5e1ab2ffdf184 100644 --- a/lib/snapshot/libraries.json +++ b/lib/snapshot/libraries.json @@ -11,9 +11,6 @@ "libraries": { "ui": { "uri": "../../lib/ui/ui.dart" - }, - "gpu": { - "uri": "../../lib/gpu/gpu.dart" } } } diff --git a/lib/snapshot/libraries.yaml b/lib/snapshot/libraries.yaml index e4e73393a5e78..9d7c4275f0c49 100644 --- a/lib/snapshot/libraries.yaml +++ b/lib/snapshot/libraries.yaml @@ -17,7 +17,5 @@ flutter: libraries: ui: uri: "../../lib/ui/ui.dart" - gpu: - uri: "../../lib/gpu/gpu.dart" diff --git a/lib/snapshot/libraries_experimental.json b/lib/snapshot/libraries_experimental.json index c8522395f74c1..08577acb38ace 100644 --- a/lib/snapshot/libraries_experimental.json +++ b/lib/snapshot/libraries_experimental.json @@ -11,9 +11,6 @@ "libraries": { "ui": { "uri": "../../lib/ui/experiments/ui.dart" - }, - "gpu": { - "uri": "../../lib/gpu/gpu.dart" } } } diff --git a/lib/gpu/gpu.dart b/lib/ui/experiments/gpu.dart similarity index 100% rename from lib/gpu/gpu.dart rename to lib/ui/experiments/gpu.dart diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index 8d07eb8e1dfde..70e9172d51dd3 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -90,7 +90,6 @@ source_set("runtime") { } public_deps = [ - "//flutter/lib/gpu", "//flutter/lib/ui", "//third_party/rapidjson", ] diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index 9be3e35dbc55e..791ac03dbbf95 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -11,7 +11,6 @@ #include "flutter/fml/logging.h" #include "flutter/fml/posix_wrappers.h" #include "flutter/fml/trace_event.h" -#include "flutter/lib/gpu/dart_gpu.h" #include "flutter/lib/io/dart_io.h" #include "flutter/lib/ui/dart_runtime_hooks.h" #include "flutter/lib/ui/dart_ui.h" @@ -463,8 +462,6 @@ bool DartIsolate::LoadLibraries() { DartUI::InitForIsolate(GetIsolateGroupData().GetSettings()); - DartGPU::InitForIsolate(GetIsolateGroupData().GetSettings()); - const bool is_service_isolate = Dart_IsServiceIsolate(isolate()); DartRuntimeHooks::Install(IsRootIsolate() && !is_service_isolate, diff --git a/sky/packages/sky_engine/BUILD.gn b/sky/packages/sky_engine/BUILD.gn index 0c9caba11487f..916c2b10788ca 100644 --- a/sky/packages/sky_engine/BUILD.gn +++ b/sky/packages/sky_engine/BUILD.gn @@ -4,8 +4,6 @@ import("//build/fuchsia/sdk.gni") import("//flutter/build/dart/rules.gni") -import("//flutter/impeller/tools/impeller.gni") -import("//flutter/lib/gpu/dart_gpu.gni") import("//flutter/lib/ui/dart_ui.gni") import("//flutter/web_sdk/web_sdk.gni") import("//third_party/dart/sdk/lib/_http/http_sources.gni") @@ -190,12 +188,6 @@ web_ui_ui_web_with_output("copy_dart_ui_web") { output_dir = "$root_gen_dir/dart-pkg/sky_engine/lib/ui_web/" } -copy("copy_dart_gpu") { - sources = dart_gpu_files - - outputs = [ "$root_gen_dir/dart-pkg/sky_engine/lib/gpu/{{source_file_part}}" ] -} - copy("copy_allowed_experiments") { sources = [ "//third_party/dart/sdk/lib/_internal/allowed_experiments.json" ] @@ -284,10 +276,6 @@ dart_pkg("sky_engine") { ":copy_dart_ui_web", ] - if (impeller_enable_3d) { - deps += [ ":copy_dart_gpu" ] - } - if (!is_fuchsia) { deps += [ ":copy_sky_engine_authors" ] } From a36abcef0faf2698f4e53d05b04e363182d93322 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Sat, 6 May 2023 00:14:28 -0700 Subject: [PATCH 4/6] Context scaffolding --- ci/licenses_golden/licenses_flutter | 2 ++ lib/ui/dart_ui.cc | 5 ++++ lib/ui/experiments/gpu.dart | 39 ++++++++++++++++------------ lib/ui/experiments/ui.dart | 4 ++- lib/ui/gpu/context.cc | 23 +++++++++++++++++ lib/ui/gpu/context.h | 40 +++++++++++++++++++++++++++++ 6 files changed, 95 insertions(+), 18 deletions(-) create mode 100644 lib/ui/gpu/context.cc create mode 100644 lib/ui/gpu/context.h diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index ef64f9d55a748..07e9a3503e2e1 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -1699,6 +1699,7 @@ ORIGIN: ../../../flutter/lib/ui/dart_runtime_hooks.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/ui/dart_ui.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/ui/dart_ui.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/ui/dart_wrapper.h + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/lib/ui/experiments/gpu.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/ui/experiments/scene.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/ui/experiments/setup_hooks.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/ui/experiments/ui.dart + ../../../flutter/LICENSE @@ -4342,6 +4343,7 @@ FILE: ../../../flutter/lib/ui/dart_runtime_hooks.h FILE: ../../../flutter/lib/ui/dart_ui.cc FILE: ../../../flutter/lib/ui/dart_ui.h FILE: ../../../flutter/lib/ui/dart_wrapper.h +FILE: ../../../flutter/lib/ui/experiments/gpu.dart FILE: ../../../flutter/lib/ui/experiments/scene.dart FILE: ../../../flutter/lib/ui/experiments/setup_hooks.dart FILE: ../../../flutter/lib/ui/experiments/ui.dart diff --git a/lib/ui/dart_ui.cc b/lib/ui/dart_ui.cc index c32420065eaf7..05baac52f1b71 100644 --- a/lib/ui/dart_ui.cc +++ b/lib/ui/dart_ui.cc @@ -315,6 +315,11 @@ typedef CanvasPath Path; V(SceneShader, SetCameraTransform, 2) \ V(SceneShader, Dispose, 1) +#define FFI_FUNCTION_LIST_GPU(V) \ + V(GpuContext::InitializeDefault, 1) + +#define FFI_METHOD_LIST_GPU(V) + #endif // IMPELLER_ENABLE_3D #define FFI_FUNCTION_INSERT(FUNCTION, ARGS) \ diff --git a/lib/ui/experiments/gpu.dart b/lib/ui/experiments/gpu.dart index 1d875c46c93d7..8ff96df40b608 100644 --- a/lib/ui/experiments/gpu.dart +++ b/lib/ui/experiments/gpu.dart @@ -4,9 +4,7 @@ // ignore_for_file: public_member_api_docs -library dart.gpu; - -import 'dart:nativewrappers'; +part of dart.ui; enum BlendOperation { add, subtract, reverseSubtract } @@ -132,26 +130,25 @@ class UniformSlot { final int binding; } -class Shader {} +class GpuShader {} class RasterPipeline {} -/// A handle to a graphics context. -/// -/// This class is created by the engine, and should not be instantiated -/// or extended directly. +/// A handle to a graphics context. Used to create and manage GPU resources. /// -/// To obtain the default graphics context, use [getContext]. -@pragma('vm:entry-point') -class Context extends NativeFieldWrapperClass1 { - @pragma('vm:entry-point') - Context._(); +/// To obtain the default graphics context, use [getGpuContext]. +class GpuContext extends NativeFieldWrapperClass1 { + /// Creates a new graphics context that corresponds to the default Impeller + /// context. + GpuContext._createDefault() { + _initializeDefault(); + } //registerShaderLibrary() async Future createRasterPipeline({ - required Shader vertex, - required Shader fragment, + required GpuShader vertex, + required GpuShader fragment, BlendOptions blendOptions = const BlendOptions(), StencilOptions stencilOptions = const StencilOptions(), List vertexLayout = const [], @@ -159,8 +156,16 @@ class Context extends NativeFieldWrapperClass1 { }) async { return RasterPipeline(); } + + /// Links this GpuContext to the default Impeller context. + @Native(symbol: 'GpuContext::InitializeDefault') + external void _initializeDefault(); } -Context getContext() { - return Context._(); +GpuContext? _defaultGpuContext; + +/// Returns the default graphics context. +GpuContext getGpuContext() { + _defaultGpuContext ??= GpuContext._createDefault(); + return _defaultGpuContext!; } diff --git a/lib/ui/experiments/ui.dart b/lib/ui/experiments/ui.dart index 41d3fcfece6c4..70a9ad2faccf9 100644 --- a/lib/ui/experiments/ui.dart +++ b/lib/ui/experiments/ui.dart @@ -37,8 +37,10 @@ part '../painting.dart'; part '../platform_dispatcher.dart'; part '../plugins.dart'; part '../pointer.dart'; -part 'scene.dart'; part '../semantics.dart'; part 'setup_hooks.dart'; part '../text.dart'; part '../window.dart'; + +part 'gpu.dart'; +part 'scene.dart'; diff --git a/lib/ui/gpu/context.cc b/lib/ui/gpu/context.cc new file mode 100644 index 0000000000000..a2b9b72432118 --- /dev/null +++ b/lib/ui/gpu/context.cc @@ -0,0 +1,23 @@ +// 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. + +#include "flutter/lib/ui/gpu/context.h" + +#include +#include + +namespace flutter { + +IMPLEMENT_WRAPPERTYPEINFO(ui, GpuContext); + +void GpuContext::InitializeDefault(Dart_Handle wrapper) { + auto res = fml::MakeRefCounted(); + res->AssociateWithDartWrapper(wrapper); +} + +GpuContext::GpuContext() = default; + +GpuContext::~GpuContext() = default; + +} // namespace flutter diff --git a/lib/ui/gpu/context.h b/lib/ui/gpu/context.h new file mode 100644 index 0000000000000..7de1491de75b3 --- /dev/null +++ b/lib/ui/gpu/context.h @@ -0,0 +1,40 @@ +// 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. + +#ifndef FLUTTER_LIB_UI_GPU_H_ +#define FLUTTER_LIB_UI_GPU_H_ + +#include + +#include "impeller/context.h" + +#include "third_party/tonic/dart_library_natives.h" + +namespace flutter { + +/// @brief A scene node, which may be a deserialized ipscene asset. This node +/// can be safely added as a child to multiple scene nodes, whether +/// they're in the same scene or a different scene. The deserialized +/// node itself is treated as immutable on the IO thread. +/// +/// Internally, nodes may have an animation player, which is controlled +/// via the mutation log in the `DlSceneColorSource`, which is built by +/// `SceneShader`. +class GpuContext : public RefCountedDartWrappable { + DEFINE_WRAPPERTYPEINFO(); + FML_FRIEND_MAKE_REF_COUNTED(GpuContext); + + public: + GpuContext(std::shared_ptr context); + ~GpuContext() override; + + static void InitializeDefault(Dart_Handle wrapper); + + private: + std::shared_ptr context_; +}; + +} // namespace flutter + +#endif // FLUTTER_LIB_UI_GPU_H_ From cb0c0e50ba0d0fa3e9defbfea58e3341b8eb66ca Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Tue, 9 May 2023 12:16:57 -0700 Subject: [PATCH 5/6] Add Impeller context --- ci/licenses_golden/licenses_flutter | 4 ++++ lib/ui/BUILD.gn | 6 +++++ lib/ui/dart_ui.cc | 8 +++++-- lib/ui/experiments/gpu.dart | 21 ++++++++++++---- lib/ui/gpu/context.cc | 37 ++++++++++++++++++++++++++--- lib/ui/gpu/context.h | 18 +++++--------- 6 files changed, 73 insertions(+), 21 deletions(-) diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 07e9a3503e2e1..856c60ae1ff39 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -1705,6 +1705,8 @@ ORIGIN: ../../../flutter/lib/ui/experiments/setup_hooks.dart + ../../../flutter/ ORIGIN: ../../../flutter/lib/ui/experiments/ui.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/ui/floating_point.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/ui/geometry.dart + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/lib/ui/gpu/context.cc + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/lib/ui/gpu/context.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/ui/hash_codes.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/ui/hooks.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/ui/io_manager.cc + ../../../flutter/LICENSE @@ -4349,6 +4351,8 @@ FILE: ../../../flutter/lib/ui/experiments/setup_hooks.dart FILE: ../../../flutter/lib/ui/experiments/ui.dart FILE: ../../../flutter/lib/ui/floating_point.h FILE: ../../../flutter/lib/ui/geometry.dart +FILE: ../../../flutter/lib/ui/gpu/context.cc +FILE: ../../../flutter/lib/ui/gpu/context.h FILE: ../../../flutter/lib/ui/hash_codes.dart FILE: ../../../flutter/lib/ui/hooks.dart FILE: ../../../flutter/lib/ui/io_manager.cc diff --git a/lib/ui/BUILD.gn b/lib/ui/BUILD.gn index 596dac782b3d4..aae6a6e94a898 100644 --- a/lib/ui/BUILD.gn +++ b/lib/ui/BUILD.gn @@ -216,6 +216,12 @@ source_set("ui") { "painting/scene/scene_shader.h", ] + # Experimental "Impeller Dart" API. + sources += [ + "gpu/context.cc", + "gpu/context.h", + ] + deps += [ "//flutter/impeller/scene" ] } } diff --git a/lib/ui/dart_ui.cc b/lib/ui/dart_ui.cc index 05baac52f1b71..77b126d797346 100644 --- a/lib/ui/dart_ui.cc +++ b/lib/ui/dart_ui.cc @@ -12,6 +12,7 @@ #include "flutter/lib/ui/compositing/scene.h" #include "flutter/lib/ui/compositing/scene_builder.h" #include "flutter/lib/ui/dart_runtime_hooks.h" +#include "flutter/lib/ui/gpu/context.h" #include "flutter/lib/ui/isolate_name_server/isolate_name_server_natives.h" #include "flutter/lib/ui/painting/canvas.h" #include "flutter/lib/ui/painting/codec.h" @@ -315,8 +316,7 @@ typedef CanvasPath Path; V(SceneShader, SetCameraTransform, 2) \ V(SceneShader, Dispose, 1) -#define FFI_FUNCTION_LIST_GPU(V) \ - V(GpuContext::InitializeDefault, 1) +#define FFI_FUNCTION_LIST_GPU(V) V(GpuContext::InitializeDefault, 1) #define FFI_METHOD_LIST_GPU(V) @@ -348,9 +348,13 @@ void* ResolveFfiNativeFunction(const char* name, uintptr_t args) { void InitDispatcherMap() { FFI_FUNCTION_LIST(FFI_FUNCTION_INSERT) FFI_METHOD_LIST(FFI_METHOD_INSERT) + #ifdef IMPELLER_ENABLE_3D FFI_FUNCTION_LIST_3D(FFI_FUNCTION_INSERT) FFI_METHOD_LIST_3D(FFI_METHOD_INSERT) + + FFI_FUNCTION_LIST_GPU(FFI_FUNCTION_INSERT) + FFI_METHOD_LIST_GPU(FFI_METHOD_INSERT) #endif // IMPELLER_ENABLE_3D } diff --git a/lib/ui/experiments/gpu.dart b/lib/ui/experiments/gpu.dart index 8ff96df40b608..282f955e6658e 100644 --- a/lib/ui/experiments/gpu.dart +++ b/lib/ui/experiments/gpu.dart @@ -6,6 +6,16 @@ part of dart.ui; +class GpuContextException implements Exception { + GpuContextException(this.message); + String message; + + @override + String toString() { + return 'GpuContextException: $message'; + } +} + enum BlendOperation { add, subtract, reverseSubtract } enum BlendFactor { @@ -141,7 +151,10 @@ class GpuContext extends NativeFieldWrapperClass1 { /// Creates a new graphics context that corresponds to the default Impeller /// context. GpuContext._createDefault() { - _initializeDefault(); + final String error = _initializeDefault(); + if (error.isNotEmpty) { + throw GpuContextException(error); + } } //registerShaderLibrary() async @@ -157,9 +170,9 @@ class GpuContext extends NativeFieldWrapperClass1 { return RasterPipeline(); } - /// Links this GpuContext to the default Impeller context. - @Native(symbol: 'GpuContext::InitializeDefault') - external void _initializeDefault(); + /// Associates the default Impeller context with this GpuContext. + @Native(symbol: 'GpuContext::InitializeDefault') + external String _initializeDefault(); } GpuContext? _defaultGpuContext; diff --git a/lib/ui/gpu/context.cc b/lib/ui/gpu/context.cc index a2b9b72432118..c61b4d2e6c8a2 100644 --- a/lib/ui/gpu/context.cc +++ b/lib/ui/gpu/context.cc @@ -7,16 +7,47 @@ #include #include +#include "flutter/fml/log_level.h" +#include "flutter/fml/logging.h" +#include "flutter/fml/make_copyable.h" +#include "flutter/fml/memory/ref_ptr.h" +#include "flutter/lib/ui/ui_dart_state.h" +#include "third_party/tonic/dart_wrappable.h" + namespace flutter { IMPLEMENT_WRAPPERTYPEINFO(ui, GpuContext); -void GpuContext::InitializeDefault(Dart_Handle wrapper) { - auto res = fml::MakeRefCounted(); +std::string GpuContext::InitializeDefault(Dart_Handle wrapper) { + auto dart_state = UIDartState::Current(); + if (!dart_state->IsImpellerEnabled()) { + return "The GpuContext API requires the Impeller rendering backend to be " + "enabled."; + } + + // Grab the Impeller context from the IO manager. + + std::promise> context_promise; + auto impeller_context_future = context_promise.get_future(); + dart_state->GetTaskRunners().GetIOTaskRunner()->PostTask( + fml::MakeCopyable([promise = std::move(context_promise), + io_manager = dart_state->GetIOManager()]() mutable { + promise.set_value(io_manager ? io_manager->GetImpellerContext() + : nullptr); + })); + + auto impeller_context = impeller_context_future.get(); + if (!impeller_context) { + return "Unable to retrieve the Impeller context."; + } + auto res = fml::MakeRefCounted(impeller_context); res->AssociateWithDartWrapper(wrapper); + + return ""; } -GpuContext::GpuContext() = default; +GpuContext::GpuContext(std::shared_ptr context) + : context_(std::move(context)) {} GpuContext::~GpuContext() = default; diff --git a/lib/ui/gpu/context.h b/lib/ui/gpu/context.h index 7de1491de75b3..0de1c192b6a21 100644 --- a/lib/ui/gpu/context.h +++ b/lib/ui/gpu/context.h @@ -7,29 +7,23 @@ #include -#include "impeller/context.h" - +#include "flutter/fml/memory/ref_counted.h" +#include "flutter/lib/ui/dart_wrapper.h" +#include "impeller/renderer/context.h" #include "third_party/tonic/dart_library_natives.h" +#include "third_party/tonic/dart_wrappable.h" namespace flutter { -/// @brief A scene node, which may be a deserialized ipscene asset. This node -/// can be safely added as a child to multiple scene nodes, whether -/// they're in the same scene or a different scene. The deserialized -/// node itself is treated as immutable on the IO thread. -/// -/// Internally, nodes may have an animation player, which is controlled -/// via the mutation log in the `DlSceneColorSource`, which is built by -/// `SceneShader`. class GpuContext : public RefCountedDartWrappable { DEFINE_WRAPPERTYPEINFO(); FML_FRIEND_MAKE_REF_COUNTED(GpuContext); public: - GpuContext(std::shared_ptr context); + explicit GpuContext(std::shared_ptr context); ~GpuContext() override; - static void InitializeDefault(Dart_Handle wrapper); + static std::string InitializeDefault(Dart_Handle wrapper); private: std::shared_ptr context_; From b8f70b3786d0a5662d1e200c3c8f94a35855b34b Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Tue, 23 May 2023 20:04:16 -0700 Subject: [PATCH 6/6] Address comments --- impeller/renderer/BUILD.gn | 2 +- impeller/renderer/renderer_dart_unittests.cc | 12 ++---------- lib/ui/gpu/context.h | 3 +++ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/impeller/renderer/BUILD.gn b/impeller/renderer/BUILD.gn index 67bf32d03da3f..ec516cd56829c 100644 --- a/impeller/renderer/BUILD.gn +++ b/impeller/renderer/BUILD.gn @@ -160,6 +160,6 @@ impeller_component("renderer_dart_unittests") { "../playground:playground_test", "//flutter/runtime:runtime", "//flutter/testing:fixture_test", - "//flutter/testing:testing_lib", + "//flutter/testing:testing", ] } diff --git a/impeller/renderer/renderer_dart_unittests.cc b/impeller/renderer/renderer_dart_unittests.cc index d4c621b1aeae2..defec38eab2e2 100644 --- a/impeller/renderer/renderer_dart_unittests.cc +++ b/impeller/renderer/renderer_dart_unittests.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#define FML_USED_ON_EMBEDDER + #include #include "flutter/common/settings.h" @@ -37,10 +39,7 @@ class RendererDartTest : public PlaygroundTest, vm_ref_(flutter::DartVMRef::Create(settings_)) { fml::MessageLoop::EnsureInitializedForCurrentThread(); -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" current_task_runner_ = fml::MessageLoop::GetCurrent().GetTaskRunner(); -#pragma clang diagnostic pop isolate_ = CreateDartIsolate(); assert(isolate_); @@ -93,10 +92,3 @@ TEST_P(RendererDartTest, CanRunDartInPlaygroundFrame) { } // namespace testing } // namespace impeller - -int main(int argc, char** argv) { - fml::InstallCrashHandler(); - testing::InitGoogleTest(&argc, argv); - fml::CommandLine cmd = fml::CommandLineFromPlatformOrArgcArgv(argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/lib/ui/gpu/context.h b/lib/ui/gpu/context.h index 0de1c192b6a21..5d9056bdb3c72 100644 --- a/lib/ui/gpu/context.h +++ b/lib/ui/gpu/context.h @@ -7,6 +7,7 @@ #include +#include "flutter/fml/macros.h" #include "flutter/fml/memory/ref_counted.h" #include "flutter/lib/ui/dart_wrapper.h" #include "impeller/renderer/context.h" @@ -27,6 +28,8 @@ class GpuContext : public RefCountedDartWrappable { private: std::shared_ptr context_; + + FML_DISALLOW_COPY_AND_ASSIGN(GpuContext); }; } // namespace flutter