Delete unused/test only code from FML (flutter/engine#48327)
This is more-or-less a revert of https://github.com/flutter/engine/pull/14011 This code never ended up being used outside of tests, and it's not how we handle asset loading at this point anyway. I was hopeful we could kill off all runtime dependencies on Dart in `FML` when looking at this, but it looks like trace_event.h still wants to import dart_api_tools.h for some Dart enum types. This may or may not matter if we ever want to build FML for web/wasm. /cc @eyebrowsoffire. If we really need to do that, we can refactor the trace event stuff so that it has a web and Dart implementation that's selected at build time.
This commit is contained in:
@@ -4697,8 +4697,6 @@ ORIGIN: ../../../flutter/fml/concurrent_message_loop_factory.cc + ../../../flutt
|
||||
ORIGIN: ../../../flutter/fml/container.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/cpu_affinity.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/cpu_affinity.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/dart/dart_converter.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/dart/dart_converter.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/delayed_task.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/delayed_task.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/fml/eintr_wrapper.h + ../../../flutter/LICENSE
|
||||
@@ -7471,8 +7469,6 @@ FILE: ../../../flutter/fml/concurrent_message_loop_factory.cc
|
||||
FILE: ../../../flutter/fml/container.h
|
||||
FILE: ../../../flutter/fml/cpu_affinity.cc
|
||||
FILE: ../../../flutter/fml/cpu_affinity.h
|
||||
FILE: ../../../flutter/fml/dart/dart_converter.cc
|
||||
FILE: ../../../flutter/fml/dart/dart_converter.h
|
||||
FILE: ../../../flutter/fml/delayed_task.cc
|
||||
FILE: ../../../flutter/fml/delayed_task.h
|
||||
FILE: ../../../flutter/fml/eintr_wrapper.h
|
||||
|
||||
@@ -387,7 +387,6 @@ if (enable_unittests) {
|
||||
deps = [
|
||||
":fml_fixtures",
|
||||
"//flutter/fml",
|
||||
"//flutter/fml/dart",
|
||||
"//flutter/runtime",
|
||||
"//flutter/runtime:libdart",
|
||||
"//flutter/testing",
|
||||
|
||||
@@ -1,19 +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.
|
||||
|
||||
# Utilities for working with FML types with the Dart API. Targets that use FML
|
||||
# as well as Dart must explicitly include this target as FML itself cannot
|
||||
# depend on Dart.
|
||||
source_set("dart") {
|
||||
sources = [
|
||||
"dart_converter.cc",
|
||||
"dart_converter.h",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
"//flutter/fml",
|
||||
"//flutter/runtime:libdart",
|
||||
"//flutter/third_party/tonic",
|
||||
]
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
#include "flutter/fml/dart/dart_converter.h"
|
||||
|
||||
namespace fml {
|
||||
|
||||
//
|
||||
|
||||
} // namespace fml
|
||||
@@ -1,127 +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_FML_DART_DART_CONVERTER_H_
|
||||
#define FLUTTER_FML_DART_DART_CONVERTER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/fml/mapping.h"
|
||||
#include "third_party/dart/runtime/include/dart_api.h"
|
||||
#include "third_party/tonic/converter/dart_converter.h"
|
||||
|
||||
namespace tonic {
|
||||
|
||||
using DartConverterMapping = std::unique_ptr<fml::Mapping>;
|
||||
|
||||
template <>
|
||||
struct DartConverter<DartConverterMapping> {
|
||||
static Dart_Handle ToDart(const DartConverterMapping& val) {
|
||||
if (!val) {
|
||||
return Dart_Null();
|
||||
}
|
||||
|
||||
auto dart_list_handle = Dart_NewListOfTypeFilled(
|
||||
ToDartTypeHandle<size_t>(), // type
|
||||
CreateZeroInitializedDartObject<size_t>(), // sentinel
|
||||
val->GetSize() // size
|
||||
);
|
||||
|
||||
if (Dart_IsError(dart_list_handle)) {
|
||||
FML_LOG(ERROR) << "Error while attempting to allocate a list: "
|
||||
<< Dart_GetError(dart_list_handle);
|
||||
return dart_list_handle;
|
||||
}
|
||||
|
||||
if (val->GetSize() == 0) {
|
||||
// Nothing to copy. Just return the zero sized list.
|
||||
return dart_list_handle;
|
||||
}
|
||||
|
||||
auto result = Dart_ListSetAsBytes(dart_list_handle, // list
|
||||
0, // offset
|
||||
val->GetMapping(), // native array,
|
||||
val->GetSize() // length
|
||||
);
|
||||
|
||||
if (Dart_IsError(result)) {
|
||||
FML_LOG(ERROR) << "Error while attempting to create a Dart list: "
|
||||
<< Dart_GetError(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
return dart_list_handle;
|
||||
}
|
||||
|
||||
static void SetReturnValue(Dart_NativeArguments args,
|
||||
const DartConverterMapping& val) {
|
||||
Dart_SetReturnValue(args, ToDart(val));
|
||||
}
|
||||
|
||||
static DartConverterMapping FromDart(Dart_Handle dart_list) {
|
||||
if (Dart_IsNull(dart_list)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (Dart_IsError(dart_list)) {
|
||||
FML_LOG(ERROR) << "Cannot convert an error handle to a list: "
|
||||
<< Dart_GetError(dart_list);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!Dart_IsList(dart_list)) {
|
||||
FML_LOG(ERROR) << "Dart handle was not a list.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
intptr_t length = 0;
|
||||
auto handle = Dart_ListLength(dart_list, &length);
|
||||
|
||||
if (Dart_IsError(handle)) {
|
||||
FML_LOG(ERROR) << "Could not get the length of the Dart list: "
|
||||
<< Dart_GetError(handle);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (length == 0) {
|
||||
// Return a valid zero sized mapping.
|
||||
return std::make_unique<fml::NonOwnedMapping>(nullptr, 0);
|
||||
}
|
||||
|
||||
auto mapping_buffer = ::malloc(length);
|
||||
|
||||
if (!mapping_buffer) {
|
||||
FML_LOG(ERROR)
|
||||
<< "Out of memory while attempting to allocate a mapping of size: "
|
||||
<< length;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto mapping = std::make_unique<fml::NonOwnedMapping>(
|
||||
static_cast<const uint8_t*>(mapping_buffer), length,
|
||||
[](const uint8_t* data, size_t size) {
|
||||
::free(const_cast<uint8_t*>(data));
|
||||
});
|
||||
|
||||
handle = Dart_ListGetAsBytes(
|
||||
dart_list, // list
|
||||
0, // offset
|
||||
static_cast<uint8_t*>(mapping_buffer), // native array
|
||||
length // length
|
||||
);
|
||||
|
||||
if (Dart_IsError(handle)) {
|
||||
FML_LOG(ERROR) << "Could not copy Dart list to native buffer: "
|
||||
<< Dart_GetError(handle);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return mapping;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace tonic
|
||||
|
||||
#endif // FLUTTER_FML_DART_DART_CONVERTER_H_
|
||||
@@ -245,7 +245,6 @@ if (enable_unittests) {
|
||||
public_deps = [
|
||||
"//flutter/common/graphics",
|
||||
"//flutter/flow",
|
||||
"//flutter/fml/dart",
|
||||
"//flutter/runtime",
|
||||
"//flutter/shell/common",
|
||||
"//flutter/testing",
|
||||
|
||||
@@ -220,29 +220,6 @@ void callNotifyDestroyed() {
|
||||
@pragma('vm:external-name', 'NotifyMessage')
|
||||
external void notifyMessage(String string);
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void canConvertMappings() {
|
||||
sendFixtureMapping(getFixtureMapping());
|
||||
}
|
||||
|
||||
@pragma('vm:external-name', 'GetFixtureMapping')
|
||||
external List<int> getFixtureMapping();
|
||||
@pragma('vm:external-name', 'SendFixtureMapping')
|
||||
external void sendFixtureMapping(List<int> list);
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void canDecompressImageFromAsset() {
|
||||
decodeImageFromList(
|
||||
Uint8List.fromList(getFixtureImage()),
|
||||
(Image result) {
|
||||
notifyWidthHeight(result.width, result.height);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@pragma('vm:external-name', 'GetFixtureImage')
|
||||
external List<int> getFixtureImage();
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void canRegisterImageDecoders() {
|
||||
decodeImageFromList(
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <fuchsia/settings/cpp/fidl.h>
|
||||
#include <lib/sys/cpp/component_context.h>
|
||||
|
||||
#include "flutter/fml/dart/dart_converter.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/synchronization/count_down_latch.h"
|
||||
#include "flutter/runtime/dart_vm.h"
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "flutter/flow/layers/transform_layer.h"
|
||||
#include "flutter/fml/backtrace.h"
|
||||
#include "flutter/fml/command_line.h"
|
||||
#include "flutter/fml/dart/dart_converter.h"
|
||||
#include "flutter/fml/make_copyable.h"
|
||||
#include "flutter/fml/message_loop.h"
|
||||
#include "flutter/fml/synchronization/count_down_latch.h"
|
||||
@@ -2207,52 +2206,6 @@ TEST_F(ShellTest, Screenshot) {
|
||||
DestroyShell(std::move(shell));
|
||||
}
|
||||
|
||||
TEST_F(ShellTest, CanConvertToAndFromMappings) {
|
||||
const size_t buffer_size = 2 << 20;
|
||||
|
||||
uint8_t* buffer = static_cast<uint8_t*>(::malloc(buffer_size));
|
||||
// NOLINTNEXTLINE(clang-analyzer-unix.Malloc)
|
||||
ASSERT_TRUE(buffer != nullptr);
|
||||
ASSERT_TRUE(MemsetPatternSetOrCheck(
|
||||
buffer, buffer_size, MemsetPatternOp::kMemsetPatternOpSetBuffer));
|
||||
|
||||
std::unique_ptr<fml::Mapping> mapping =
|
||||
std::make_unique<fml::MallocMapping>(buffer, buffer_size);
|
||||
|
||||
ASSERT_EQ(mapping->GetSize(), buffer_size);
|
||||
|
||||
fml::AutoResetWaitableEvent latch;
|
||||
AddNativeCallback(
|
||||
"SendFixtureMapping", CREATE_NATIVE_ENTRY([&](auto args) {
|
||||
auto mapping_from_dart =
|
||||
tonic::DartConverter<std::unique_ptr<fml::Mapping>>::FromDart(
|
||||
Dart_GetNativeArgument(args, 0));
|
||||
ASSERT_NE(mapping_from_dart, nullptr);
|
||||
ASSERT_EQ(mapping_from_dart->GetSize(), buffer_size);
|
||||
ASSERT_TRUE(MemsetPatternSetOrCheck(
|
||||
const_cast<uint8_t*>(mapping_from_dart->GetMapping()), // buffer
|
||||
mapping_from_dart->GetSize(), // size
|
||||
MemsetPatternOp::kMemsetPatternOpCheckBuffer // op
|
||||
));
|
||||
latch.Signal();
|
||||
}));
|
||||
|
||||
AddNativeCallback(
|
||||
"GetFixtureMapping", CREATE_NATIVE_ENTRY([&](auto args) {
|
||||
tonic::DartConverter<tonic::DartConverterMapping>::SetReturnValue(
|
||||
args, mapping);
|
||||
}));
|
||||
|
||||
auto settings = CreateSettingsForFixture();
|
||||
auto configuration = RunConfiguration::InferFromSettings(settings);
|
||||
configuration.SetEntrypoint("canConvertMappings");
|
||||
std::unique_ptr<Shell> shell = CreateShell(settings);
|
||||
ASSERT_NE(shell.get(), nullptr);
|
||||
RunEngine(shell.get(), std::move(configuration));
|
||||
latch.Wait();
|
||||
DestroyShell(std::move(shell));
|
||||
}
|
||||
|
||||
// Compares local times as seen by the dart isolate and as seen by this test
|
||||
// fixture, to a resolution of 1 hour.
|
||||
//
|
||||
@@ -2301,35 +2254,6 @@ TEST_F(ShellTest, LocaltimesMatch) {
|
||||
DestroyShell(std::move(shell));
|
||||
}
|
||||
|
||||
TEST_F(ShellTest, CanDecompressImageFromAsset) {
|
||||
fml::AutoResetWaitableEvent latch;
|
||||
AddNativeCallback("NotifyWidthHeight", CREATE_NATIVE_ENTRY([&](auto args) {
|
||||
auto width = tonic::DartConverter<int>::FromDart(
|
||||
Dart_GetNativeArgument(args, 0));
|
||||
auto height = tonic::DartConverter<int>::FromDart(
|
||||
Dart_GetNativeArgument(args, 1));
|
||||
ASSERT_EQ(width, 100);
|
||||
ASSERT_EQ(height, 100);
|
||||
latch.Signal();
|
||||
}));
|
||||
|
||||
AddNativeCallback(
|
||||
"GetFixtureImage", CREATE_NATIVE_ENTRY([](auto args) {
|
||||
auto fixture = OpenFixtureAsMapping("shelltest_screenshot.png");
|
||||
tonic::DartConverter<tonic::DartConverterMapping>::SetReturnValue(
|
||||
args, fixture);
|
||||
}));
|
||||
|
||||
auto settings = CreateSettingsForFixture();
|
||||
auto configuration = RunConfiguration::InferFromSettings(settings);
|
||||
configuration.SetEntrypoint("canDecompressImageFromAsset");
|
||||
std::unique_ptr<Shell> shell = CreateShell(settings);
|
||||
ASSERT_NE(shell.get(), nullptr);
|
||||
RunEngine(shell.get(), std::move(configuration));
|
||||
latch.Wait();
|
||||
DestroyShell(std::move(shell));
|
||||
}
|
||||
|
||||
/// An image generator that always creates a 1x1 single-frame green image.
|
||||
class SinglePixelImageGenerator : public ImageGenerator {
|
||||
public:
|
||||
|
||||
@@ -105,7 +105,6 @@ if (is_mac) {
|
||||
":gpu_surface_metal",
|
||||
"//flutter/impeller/fixtures",
|
||||
"//flutter/fml",
|
||||
"//flutter/fml/dart",
|
||||
"//flutter/runtime",
|
||||
"//flutter/runtime:libdart",
|
||||
"//flutter/testing",
|
||||
|
||||
Reference in New Issue
Block a user