From a2fe41a7637279c7bfa0137eca7408957b7803b3 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Tue, 17 Sep 2024 15:24:07 -0700 Subject: [PATCH] [Flutter GPU] Remove the redundant smoketest. (flutter/engine#55267) This is placeholder stuff that I added before the rest of the API to prove that we can call the engine symbols. Today this is totally redundant as Flutter GPU has a bunch of automated tests which exercise every FFI call. --- .../ci/licenses_golden/licenses_flutter | 6 -- engine/src/flutter/lib/gpu/BUILD.gn | 2 - engine/src/flutter/lib/gpu/lib/gpu.dart | 2 - .../flutter/lib/gpu/lib/src/smoketest.dart | 40 ------------- engine/src/flutter/lib/gpu/smoketest.cc | 58 ------------------- engine/src/flutter/lib/gpu/smoketest.h | 56 ------------------ engine/src/flutter/testing/dart/gpu_test.dart | 14 ----- 7 files changed, 178 deletions(-) delete mode 100644 engine/src/flutter/lib/gpu/lib/src/smoketest.dart delete mode 100644 engine/src/flutter/lib/gpu/smoketest.cc delete mode 100644 engine/src/flutter/lib/gpu/smoketest.h diff --git a/engine/src/flutter/ci/licenses_golden/licenses_flutter b/engine/src/flutter/ci/licenses_golden/licenses_flutter index 08e12d8f5e..fdd08c0639 100644 --- a/engine/src/flutter/ci/licenses_golden/licenses_flutter +++ b/engine/src/flutter/ci/licenses_golden/licenses_flutter @@ -43340,7 +43340,6 @@ ORIGIN: ../../../flutter/lib/gpu/lib/src/render_pass.dart + ../../../flutter/LIC ORIGIN: ../../../flutter/lib/gpu/lib/src/render_pipeline.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/gpu/lib/src/shader.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/gpu/lib/src/shader_library.dart + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/lib/gpu/lib/src/smoketest.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/gpu/lib/src/texture.dart + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/gpu/render_pass.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/gpu/render_pass.h + ../../../flutter/LICENSE @@ -43350,8 +43349,6 @@ ORIGIN: ../../../flutter/lib/gpu/shader.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/gpu/shader.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/gpu/shader_library.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/gpu/shader_library.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/lib/gpu/smoketest.cc + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/lib/gpu/smoketest.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/gpu/texture.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/gpu/texture.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/lib/io/dart_io.cc + ../../../flutter/LICENSE @@ -46188,7 +46185,6 @@ FILE: ../../../flutter/lib/gpu/lib/src/render_pass.dart FILE: ../../../flutter/lib/gpu/lib/src/render_pipeline.dart FILE: ../../../flutter/lib/gpu/lib/src/shader.dart FILE: ../../../flutter/lib/gpu/lib/src/shader_library.dart -FILE: ../../../flutter/lib/gpu/lib/src/smoketest.dart FILE: ../../../flutter/lib/gpu/lib/src/texture.dart FILE: ../../../flutter/lib/gpu/render_pass.cc FILE: ../../../flutter/lib/gpu/render_pass.h @@ -46198,8 +46194,6 @@ FILE: ../../../flutter/lib/gpu/shader.cc FILE: ../../../flutter/lib/gpu/shader.h FILE: ../../../flutter/lib/gpu/shader_library.cc FILE: ../../../flutter/lib/gpu/shader_library.h -FILE: ../../../flutter/lib/gpu/smoketest.cc -FILE: ../../../flutter/lib/gpu/smoketest.h FILE: ../../../flutter/lib/gpu/texture.cc FILE: ../../../flutter/lib/gpu/texture.h FILE: ../../../flutter/lib/io/dart_io.cc diff --git a/engine/src/flutter/lib/gpu/BUILD.gn b/engine/src/flutter/lib/gpu/BUILD.gn index abaad37932..9ad5edd994 100644 --- a/engine/src/flutter/lib/gpu/BUILD.gn +++ b/engine/src/flutter/lib/gpu/BUILD.gn @@ -54,8 +54,6 @@ source_set("gpu") { "shader.h", "shader_library.cc", "shader_library.h", - "smoketest.cc", - "smoketest.h", "texture.cc", "texture.h", ] diff --git a/engine/src/flutter/lib/gpu/lib/gpu.dart b/engine/src/flutter/lib/gpu/lib/gpu.dart index ac41440e90..368585eb28 100644 --- a/engine/src/flutter/lib/gpu/lib/gpu.dart +++ b/engine/src/flutter/lib/gpu/lib/gpu.dart @@ -26,8 +26,6 @@ import 'dart:typed_data'; // ignore: uri_does_not_exist import 'dart:ui' as ui; -export 'src/smoketest.dart'; - part 'src/buffer.dart'; part 'src/command_buffer.dart'; part 'src/context.dart'; diff --git a/engine/src/flutter/lib/gpu/lib/src/smoketest.dart b/engine/src/flutter/lib/gpu/lib/src/smoketest.dart deleted file mode 100644 index b7cebffc7d..0000000000 --- a/engine/src/flutter/lib/gpu/lib/src/smoketest.dart +++ /dev/null @@ -1,40 +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 'dart:ffi'; -import 'dart:nativewrappers'; - -/// This is a simple test fuction. -@Native(symbol: 'InternalFlutterGpuTestProc') -external int testProc(); - -/// A single parameter callback. -typedef Callback = void Function(T result); - -/// This is a test callback that follows the same pattern as much of dart:ui -- -/// immediately returning an error string and supplying an asynchronous result -/// via callback later. -@Native( - symbol: 'InternalFlutterGpuTestProcWithCallback') -external String? testProcWithCallback(Callback callback); - -/// This is a test of NativeFieldWrapperClass1, which is commonly used in -/// dart:ui to enable Dart to dictate the lifetime of a C counterpart. -base class FlutterGpuTestClass extends NativeFieldWrapperClass1 { - /// Default constructor for the test class - FlutterGpuTestClass() { - _constructor(); - } - - /// This "constructor" is used to instantiate and wrap the C counterpart. - /// This is a common pattern in dart:ui. - @Native(symbol: 'InternalFlutterGpuTestClass_Create') - external void _constructor(); - - /// This is a method that will supply a pointer to the C data counterpart when - /// calling the function - @Native, Int)>( - symbol: 'InternalFlutterGpuTestClass_Method') - external void coolMethod(int something); -} diff --git a/engine/src/flutter/lib/gpu/smoketest.cc b/engine/src/flutter/lib/gpu/smoketest.cc deleted file mode 100644 index e7524cd10e..0000000000 --- a/engine/src/flutter/lib/gpu/smoketest.cc +++ /dev/null @@ -1,58 +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/smoketest.h" -#include "flutter/fml/memory/ref_ptr.h" -#include "flutter/lib/ui/dart_wrapper.h" -#include "flutter/lib/ui/ui_dart_state.h" -#include "third_party/dart/runtime/include/dart_api.h" -#include "third_party/tonic/converter/dart_converter.h" -#include "third_party/tonic/dart_state.h" -#include "third_party/tonic/dart_wrappable.h" -#include "third_party/tonic/dart_wrapper_info.h" -#include "third_party/tonic/logging/dart_invoke.h" - -namespace flutter { - -// TODO(131346): Remove this once we migrate the Dart GPU API into this space. -IMPLEMENT_WRAPPERTYPEINFO(flutter_gpu, FlutterGpuTestClass); - -// TODO(131346): Remove this once we migrate the Dart GPU API into this space. -FlutterGpuTestClass::~FlutterGpuTestClass() = default; - -} // namespace flutter - -//---------------------------------------------------------------------------- -/// Exports -/// - -// TODO(131346): Remove this once we migrate the Dart GPU API into this space. -uint32_t InternalFlutterGpuTestProc() { - return 1; -} - -// TODO(131346): Remove this once we migrate the Dart GPU API into this space. -Dart_Handle InternalFlutterGpuTestProcWithCallback(Dart_Handle callback) { - flutter::UIDartState::ThrowIfUIOperationsProhibited(); - if (!Dart_IsClosure(callback)) { - return tonic::ToDart("Callback must be a function"); - } - - tonic::DartInvoke(callback, {tonic::ToDart(1234)}); - - return Dart_Null(); -} - -// TODO(131346): Remove this once we migrate the Dart GPU API into this space. -void InternalFlutterGpuTestClass_Create(Dart_Handle wrapper) { - auto res = fml::MakeRefCounted(); - res->AssociateWithDartWrapper(wrapper); - FML_LOG(INFO) << "FlutterGpuTestClass Wrapped."; -} - -// TODO(131346): Remove this once we migrate the Dart GPU API into this space. -void InternalFlutterGpuTestClass_Method(flutter::FlutterGpuTestClass* self, - int something) { - FML_LOG(INFO) << "Something: " << something; -} diff --git a/engine/src/flutter/lib/gpu/smoketest.h b/engine/src/flutter/lib/gpu/smoketest.h deleted file mode 100644 index 895b3dd16a..0000000000 --- a/engine/src/flutter/lib/gpu/smoketest.h +++ /dev/null @@ -1,56 +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_SMOKETEST_H_ -#define FLUTTER_LIB_GPU_SMOKETEST_H_ - -#include - -#include "flutter/lib/gpu/export.h" -#include "flutter/lib/ui/dart_wrapper.h" -#include "third_party/dart/runtime/include/dart_api.h" -#include "third_party/tonic/dart_state.h" -#include "third_party/tonic/dart_wrapper_info.h" - -namespace flutter { - -// TODO(131346): Remove this once we migrate the Dart GPU API into this space. -class FlutterGpuTestClass - : public RefCountedDartWrappable { - DEFINE_WRAPPERTYPEINFO(); - FML_FRIEND_MAKE_REF_COUNTED(FlutterGpuTestClass); - - public: - ~FlutterGpuTestClass() override; -}; - -} // namespace flutter - -//---------------------------------------------------------------------------- -/// Exports -/// - -extern "C" { - -// TODO(131346): Remove this once we migrate the Dart GPU API into this space. -FLUTTER_GPU_EXPORT -extern uint32_t InternalFlutterGpuTestProc(); - -// TODO(131346): Remove this once we migrate the Dart GPU API into this space. -FLUTTER_GPU_EXPORT -extern Dart_Handle InternalFlutterGpuTestProcWithCallback(Dart_Handle callback); - -// TODO(131346): Remove this once we migrate the Dart GPU API into this space. -FLUTTER_GPU_EXPORT -extern void InternalFlutterGpuTestClass_Create(Dart_Handle wrapper); - -// TODO(131346): Remove this once we migrate the Dart GPU API into this space. -FLUTTER_GPU_EXPORT -extern void InternalFlutterGpuTestClass_Method( - flutter::FlutterGpuTestClass* self, - int something); - -} // extern "C" - -#endif // FLUTTER_LIB_GPU_SMOKETEST_H_ diff --git a/engine/src/flutter/testing/dart/gpu_test.dart b/engine/src/flutter/testing/dart/gpu_test.dart index 87dcbc8794..c35b554378 100644 --- a/engine/src/flutter/testing/dart/gpu_test.dart +++ b/engine/src/flutter/testing/dart/gpu_test.dart @@ -35,20 +35,6 @@ gpu.RenderPipeline createUnlitRenderPipeline() { void main() async { final ImageComparer comparer = await ImageComparer.create(); - // TODO(131346): Remove this once we migrate the Dart GPU API into this space. - test('smoketest', () async { - final int result = gpu.testProc(); - expect(result, 1); - - final String? message = gpu.testProcWithCallback((int result) { - expect(result, 1234); - }); - expect(message, null); - - final gpu.FlutterGpuTestClass a = gpu.FlutterGpuTestClass(); - a.coolMethod(9847); - }); - test('gpu.context throws exception for incompatible embedders', () async { try { // ignore: unnecessary_statements