Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Libtxt and Minikin #39499

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ci/licenses_golden/excluded_files
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@
../../../flutter/third_party/txt/.clang-format
../../../flutter/third_party/txt/.gitattributes
../../../flutter/third_party/txt/.gitignore
../../../flutter/third_party/txt/PATENTS
../../../flutter/third_party/txt/tests
../../../flutter/third_party/txt/third_party/fonts
../../../flutter/third_party/web_locale_keymap/CHANGELOG.md
Expand Down
116 changes: 0 additions & 116 deletions ci/licenses_golden/licenses_flutter

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions common/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ declare_args() {
# The runtime mode ("debug", "profile", "release", or "jit_release")
flutter_runtime_mode = "debug"

# Whether to link the Skia text shaper module into the engine
flutter_enable_skshaper = false

# Whether to use the Skia text shaper module for all text rendering
flutter_always_use_skshaper = false

# Whether to use a prebuilt Dart SDK instead of building one.
flutter_prebuilt_dart_sdk = false

Expand Down
3 changes: 0 additions & 3 deletions common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,6 @@ struct Settings {
// manager before creating the engine.
bool prefetched_default_font_manager = false;

// Selects the SkParagraph implementation of the text layout engine.
bool enable_skparagraph = false;

// Enable the rendering of colors outside of the sRGB gamut.
bool enable_wide_gamut = false;

Expand Down
6 changes: 0 additions & 6 deletions lib/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,6 @@ source_set("ui") {
if (!defined(defines)) {
defines = []
}
if (flutter_enable_skshaper) {
defines += [ "FLUTTER_ENABLE_SKSHAPER" ]
}
if (flutter_always_use_skshaper) {
defines += [ "FLUTTER_ALWAYS_USE_SKSHAPER" ]
}
if (is_win) {
# Required for M_PI and others.
defines += [ "_USE_MATH_DEFINES" ]
Expand Down
9 changes: 2 additions & 7 deletions lib/ui/text/paragraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,8 @@ void Paragraph::paint(Canvas* canvas, double x, double y) {
}

DisplayListBuilder* builder = canvas->builder();
if (builder && m_paragraph->Paint(builder, x, y)) {
return;
}
// Fall back to SkCanvas if painting to DisplayListBuilder is not supported.
SkCanvas* sk_canvas = canvas->canvas();
if (sk_canvas) {
m_paragraph->Paint(sk_canvas, x, y);
if (builder) {
m_paragraph->Paint(builder, x, y);
}
}

Expand Down
19 changes: 2 additions & 17 deletions lib/ui/text/paragraph_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -297,23 +297,8 @@ ParagraphBuilder::ParagraphBuilder(
->client()
->GetFontCollection();

typedef std::unique_ptr<txt::ParagraphBuilder> (*ParagraphBuilderFactory)(
const txt::ParagraphStyle& style,
std::shared_ptr<txt::FontCollection> font_collection);
ParagraphBuilderFactory factory = txt::ParagraphBuilder::CreateTxtBuilder;

#if FLUTTER_ENABLE_SKSHAPER
#if FLUTTER_ALWAYS_USE_SKSHAPER
bool enable_skparagraph = true;
#else
bool enable_skparagraph = UIDartState::Current()->enable_skparagraph();
#endif
if (enable_skparagraph) {
factory = txt::ParagraphBuilder::CreateSkiaBuilder;
}
#endif // FLUTTER_ENABLE_SKSHAPER

m_paragraphBuilder = factory(style, font_collection.GetFontCollection());
m_paragraphBuilder = txt::ParagraphBuilder::CreateSkiaBuilder(
style, font_collection.GetFontCollection());
}

ParagraphBuilder::~ParagraphBuilder() = default;
Expand Down
6 changes: 0 additions & 6 deletions lib/ui/ui_dart_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ UIDartState::UIDartState(
LogMessageCallback log_message_callback,
std::shared_ptr<IsolateNameServer> isolate_name_server,
bool is_root_isolate,
bool enable_skparagraph,
const UIDartState::Context& context)
: add_callback_(std::move(add_callback)),
remove_callback_(std::move(remove_callback)),
Expand All @@ -69,7 +68,6 @@ UIDartState::UIDartState(
unhandled_exception_callback_(std::move(unhandled_exception_callback)),
log_message_callback_(std::move(log_message_callback)),
isolate_name_server_(std::move(isolate_name_server)),
enable_skparagraph_(enable_skparagraph),
context_(context) {
AddOrRemoveTaskObserver(true /* add */);
}
Expand Down Expand Up @@ -234,10 +232,6 @@ void UIDartState::LogMessage(const std::string& tag,
}
}

bool UIDartState::enable_skparagraph() const {
return enable_skparagraph_;
}

Dart_Handle UIDartState::HandlePlatformMessage(
std::unique_ptr<PlatformMessage> message) {
if (platform_configuration_) {
Expand Down
4 changes: 0 additions & 4 deletions lib/ui/ui_dart_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ class UIDartState : public tonic::DartState {
// @param[in] message The message to be logged.
void LogMessage(const std::string& tag, const std::string& message) const;

bool enable_skparagraph() const;

template <class T>
static flutter::SkiaGPUObject<T> CreateGPUObject(sk_sp<T> object) {
if (!object) {
Expand Down Expand Up @@ -185,7 +183,6 @@ class UIDartState : public tonic::DartState {
LogMessageCallback log_message_callback,
std::shared_ptr<IsolateNameServer> isolate_name_server,
bool is_root_isolate_,
bool enable_skparagraph,
const UIDartState::Context& context);

~UIDartState() override;
Expand All @@ -210,7 +207,6 @@ class UIDartState : public tonic::DartState {
UnhandledExceptionCallback unhandled_exception_callback_;
LogMessageCallback log_message_callback_;
const std::shared_ptr<IsolateNameServer> isolate_name_server_;
const bool enable_skparagraph_;
UIDartState::Context context_;

void AddOrRemoveTaskObserver(bool add);
Expand Down
1 change: 0 additions & 1 deletion runtime/dart_isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ DartIsolate::DartIsolate(const Settings& settings,
settings.log_message_callback,
DartVMRef::GetIsolateNameServer(),
is_root_isolate,
settings.enable_skparagraph,
context),
may_insecurely_connect_to_all_domains_(
settings.may_insecurely_connect_to_all_domains),
Expand Down
30 changes: 0 additions & 30 deletions shell/common/shell_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1425,36 +1425,6 @@ TEST_F(ShellTest, ReportTimingsIsCalledImmediatelyAfterTheFirstFrame) {
ASSERT_EQ(timestamps.size(), FrameTiming::kCount);
}

TEST_F(ShellTest, ReloadSystemFonts) {
auto settings = CreateSettingsForFixture();

fml::MessageLoop::EnsureInitializedForCurrentThread();
auto task_runner = fml::MessageLoop::GetCurrent().GetTaskRunner();
TaskRunners task_runners("test", task_runner, task_runner, task_runner,
task_runner);
auto shell = CreateShell(settings, task_runners);

auto fontCollection = GetFontCollection(shell.get());
std::vector<std::string> families(1, "Robotofake");
auto font =
fontCollection->GetMinikinFontCollectionForFamilies(families, "en");
if (font == nullptr) {
// The system does not have default font. Aborts this test.
return;
}
unsigned int id = font->getId();
// The result should be cached.
font = fontCollection->GetMinikinFontCollectionForFamilies(families, "en");
ASSERT_EQ(font->getId(), id);
bool result = shell->ReloadSystemFonts();

// The cache is cleared, and FontCollection will be assigned a new id.
font = fontCollection->GetMinikinFontCollectionForFamilies(families, "en");
ASSERT_NE(font->getId(), id);
ASSERT_TRUE(result);
shell.reset();
}

TEST_F(ShellTest, WaitForFirstFrame) {
auto settings = CreateSettingsForFixture();
std::unique_ptr<Shell> shell = CreateShell(settings);
Expand Down
4 changes: 0 additions & 4 deletions shell/common/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,6 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
settings.use_asset_fonts =
!command_line.HasOption(FlagForSwitch(Switch::DisableAssetFonts));

std::string enable_skparagraph = command_line.GetOptionValueWithDefault(
FlagForSwitch(Switch::EnableSkParagraph), "");
settings.enable_skparagraph = enable_skparagraph != "false";

settings.enable_impeller =
command_line.HasOption(FlagForSwitch(Switch::EnableImpeller));

Expand Down
3 changes: 0 additions & 3 deletions shell/common/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,6 @@ DEF_SWITCH(OldGenHeapSize,
DEF_SWITCH(ResourceCacheMaxBytesThreshold,
"resource-cache-max-bytes-threshold",
"The max bytes threshold of resource cache, or 0 for unlimited.")
DEF_SWITCH(EnableSkParagraph,
"enable-skparagraph",
"Selects the SkParagraph implementation of the text layout engine.")
DEF_SWITCH(EnableImpeller,
"enable-impeller",
"Enable the Impeller renderer on supported platforms. Ignored if "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public class FlutterLoader {

private static final String OLD_GEN_HEAP_SIZE_META_DATA_KEY =
"io.flutter.embedding.android.OldGenHeapSize";
private static final String ENABLE_SKPARAGRAPH_META_DATA_KEY =
"io.flutter.embedding.android.EnableSkParagraph";
private static final String ENABLE_IMPELLER_META_DATA_KEY =
"io.flutter.embedding.android.EnableImpeller";

Expand Down Expand Up @@ -318,10 +316,6 @@ public void ensureInitializationComplete(

shellArgs.add("--prefetched-default-font-manager");

boolean enableSkParagraph =
metaData == null || metaData.getBoolean(ENABLE_SKPARAGRAPH_META_DATA_KEY, true);
shellArgs.add("--enable-skparagraph=" + enableSkParagraph);

if (metaData != null && metaData.getBoolean(ENABLE_IMPELLER_META_DATA_KEY, false)) {
shellArgs.add("--enable-impeller");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,44 +197,6 @@ public void itSetsEnableImpellerFromMetaData() {
assertTrue(arguments.contains(enableImpellerArg));
}

@Test
public void itSetsEnableSkParagraphByDefault() {
// SkParagraph is enabled by default
FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
FlutterLoader.Settings settings = new FlutterLoader.Settings();
flutterLoader.startInitialization(ctx, settings);
flutterLoader.ensureInitializationComplete(ctx, null);
shadowOf(getMainLooper()).idle();

ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
verify(mockFlutterJNI, times(1))
.init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());
List<String> arguments = Arrays.asList(shellArgsCaptor.getValue());
assertTrue(arguments.contains("--enable-skparagraph=true"));
}

@Test
public void itSetsEnableSkParagraphFromMetaData() {
// SkParagraph can be disabled using metadata.
FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
FlutterLoader flutterLoader = new FlutterLoader(mockFlutterJNI);
Bundle metaData = new Bundle();
metaData.putBoolean("io.flutter.embedding.android.EnableSkParagraph", false);
ctx.getApplicationInfo().metaData = metaData;

FlutterLoader.Settings settings = new FlutterLoader.Settings();
flutterLoader.startInitialization(ctx, settings);
flutterLoader.ensureInitializationComplete(ctx, null);
shadowOf(getMainLooper()).idle();

ArgumentCaptor<String[]> shellArgsCaptor = ArgumentCaptor.forClass(String[].class);
verify(mockFlutterJNI, times(1))
.init(eq(ctx), shellArgsCaptor.capture(), anyString(), anyString(), anyString(), anyLong());
List<String> arguments = Arrays.asList(shellArgsCaptor.getValue());
assertTrue(arguments.contains("--enable-skparagraph=false"));
}

@Test
@TargetApi(23)
@Config(sdk = 23)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@
settings.may_insecurely_connect_to_all_domains = true;
settings.domain_network_policy = "";

// SkParagraph text layout library
NSNumber* enableSkParagraph = [mainBundle objectForInfoDictionaryKey:@"FLTEnableSkParagraph"];
settings.enable_skparagraph = (enableSkParagraph != nil) ? enableSkParagraph.boolValue : true;

// Whether to enable Impeller.
NSNumber* nsEnableWideGamut = [mainBundle objectForInfoDictionaryKey:@"FLTEnableWideGamut"];
// TODO(gaaclarke): Make this value `on` by default (pending memory audit).
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/fuchsia/flutter/platform_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ bool PlatformView::HandleFuchsiaShaderWarmupChannelPlatformMessage(
}

auto completion_callback = [response =
message->response()](uint num_successes) {
message->response()](uint32_t num_successes) {
std::ostringstream result_stream;
result_stream << "[" << num_successes << "]";

Expand Down
Loading