Add benchmarking.
Change-Id: I92b8d1d27d5d6b79a831853446e83086fa56a133
This commit is contained in:
45
engine/src/flutter/benchmarks/BUILD.gn
Normal file
45
engine/src/flutter/benchmarks/BUILD.gn
Normal file
@@ -0,0 +1,45 @@
|
||||
# Copyright 2017 Google, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
executable("benchmarks") {
|
||||
output_name = "txt_benchmarks"
|
||||
|
||||
include_dirs = [
|
||||
"//lib/txt/src",
|
||||
"//lib/txt/include",
|
||||
"//third_party/icu/source",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"font_collection_benchmarks.cc",
|
||||
"paragraph_benchmarks.cc",
|
||||
"paragraph_builder_benchmarks.cc",
|
||||
"txt_run_all_benchmarks.cc",
|
||||
"utils.cc",
|
||||
"utils.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//dart/runtime:libdart_jit", # Logging
|
||||
"//flutter/fml",
|
||||
"//lib/txt/shims",
|
||||
"//lib/txt",
|
||||
"//build/secondary/testing/benchmark",
|
||||
"//third_party/skia",
|
||||
"//third_party/harfbuzz",
|
||||
"//lib/txt/libs/minikin",
|
||||
]
|
||||
|
||||
|
||||
}
|
||||
49
engine/src/flutter/benchmarks/font_collection_benchmarks.cc
Normal file
49
engine/src/flutter/benchmarks/font_collection_benchmarks.cc
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2017 Google, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "third_party/benchmark/include/benchmark/benchmark_api.h"
|
||||
|
||||
#include "lib/ftl/command_line.h"
|
||||
#include "lib/ftl/logging.h"
|
||||
#include "lib/txt/src/font_collection.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
// Include this fake bench first because the first benchmark produces
|
||||
// inconsistent times.
|
||||
static void BM_FAKE_BENCHMARK(benchmark::State& state) {
|
||||
while (state.KeepRunning()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_FAKE_BENCHMARK);
|
||||
|
||||
static void BM_FontCollectionInit(benchmark::State& state) {
|
||||
while (state.KeepRunning()) {
|
||||
FontCollection::GetFontCollection(txt::GetFontDir());
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_FontCollectionInit);
|
||||
|
||||
static void BM_FontCollectionGetMinikinFontCollectionForFamily(benchmark::State& state) {
|
||||
while (state.KeepRunning()) {
|
||||
FontCollection::GetFontCollection(txt::GetFontDir()).GetMinikinFontCollectionForFamily("Roboto");
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_FontCollectionGetMinikinFontCollectionForFamily);
|
||||
|
||||
} // namespace txt
|
||||
116
engine/src/flutter/benchmarks/paragraph_benchmarks.cc
Normal file
116
engine/src/flutter/benchmarks/paragraph_benchmarks.cc
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright 2017 Google, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "third_party/benchmark/include/benchmark/benchmark_api.h"
|
||||
|
||||
#include "lib/ftl/command_line.h"
|
||||
#include "lib/ftl/logging.h"
|
||||
#include "lib/txt/src/font_style.h"
|
||||
#include "lib/txt/src/font_weight.h"
|
||||
#include "lib/txt/src/paragraph.h"
|
||||
#include "lib/txt/src/paragraph_builder.h"
|
||||
#include "lib/txt/src/text_align.h"
|
||||
#include "third_party/icu/source/common/unicode/unistr.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
static void BM_ParagraphShortLayout(benchmark::State& state) {
|
||||
const char* text = "Hello World";
|
||||
auto icu_text = icu::UnicodeString::fromUTF8(text);
|
||||
std::u16string u16_text(icu_text.getBuffer(),
|
||||
icu_text.getBuffer() + icu_text.length());
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
txt::ParagraphBuilder builder(paragraph_style);
|
||||
|
||||
txt::TextStyle text_style;
|
||||
text_style.color = SK_ColorBLACK;
|
||||
|
||||
builder.PushStyle(text_style);
|
||||
builder.AddText(u16_text);
|
||||
builder.Pop();
|
||||
auto paragraph = builder.Build();
|
||||
paragraph->Layout(300, txt::GetFontDir(), true);
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_ParagraphShortLayout);
|
||||
|
||||
static void BM_ParagraphLongLayout(benchmark::State& state) {
|
||||
const char* text =
|
||||
"This is a very long sentence to test if the text will properly wrap "
|
||||
"around and go to the next line. Sometimes, short sentence. Longer "
|
||||
"sentences are okay too because they are necessary. Very short. "
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
|
||||
"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
|
||||
"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
|
||||
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate "
|
||||
"velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint "
|
||||
"occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
|
||||
"mollit anim id est laborum. "
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
|
||||
"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
|
||||
"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
|
||||
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate "
|
||||
"velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint "
|
||||
"occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
|
||||
"mollit anim id est laborum.";
|
||||
auto icu_text = icu::UnicodeString::fromUTF8(text);
|
||||
std::u16string u16_text(icu_text.getBuffer(),
|
||||
icu_text.getBuffer() + icu_text.length());
|
||||
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
txt::ParagraphBuilder builder(paragraph_style);
|
||||
|
||||
txt::TextStyle text_style;
|
||||
text_style.color = SK_ColorBLACK;
|
||||
|
||||
builder.PushStyle(text_style);
|
||||
builder.AddText(u16_text);
|
||||
builder.Pop();
|
||||
auto paragraph = builder.Build();
|
||||
while (state.KeepRunning()) {
|
||||
paragraph->Layout(300, txt::GetFontDir(), true);
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_ParagraphLongLayout);
|
||||
|
||||
static void BM_ParagraphManyStylesLayout(benchmark::State& state) {
|
||||
const char* text = "A short sentence. ";
|
||||
auto icu_text = icu::UnicodeString::fromUTF8(text);
|
||||
std::u16string u16_text(icu_text.getBuffer(),
|
||||
icu_text.getBuffer() + icu_text.length());
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
txt::ParagraphBuilder builder(paragraph_style);
|
||||
|
||||
txt::TextStyle text_style;
|
||||
text_style.color = SK_ColorBLACK;
|
||||
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
builder.PushStyle(text_style);
|
||||
builder.AddText(u16_text);
|
||||
}
|
||||
auto paragraph = builder.Build();
|
||||
paragraph->Layout(300, txt::GetFontDir(), true);
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_ParagraphManyStylesLayout);
|
||||
|
||||
} // namespace txt
|
||||
194
engine/src/flutter/benchmarks/paragraph_builder_benchmarks.cc
Normal file
194
engine/src/flutter/benchmarks/paragraph_builder_benchmarks.cc
Normal file
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Copyright 2017 Google, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "third_party/benchmark/include/benchmark/benchmark_api.h"
|
||||
|
||||
#include "lib/ftl/logging.h"
|
||||
#include "lib/txt/src/font_style.h"
|
||||
#include "lib/txt/src/font_weight.h"
|
||||
#include "lib/txt/src/paragraph.h"
|
||||
#include "lib/txt/src/paragraph_builder.h"
|
||||
#include "lib/txt/src/text_align.h"
|
||||
#include "third_party/icu/source/common/unicode/unistr.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
static void BM_ParagraphBuilderConstruction(benchmark::State& state) {
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
while (state.KeepRunning()) {
|
||||
txt::ParagraphBuilder builder(paragraph_style);
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_ParagraphBuilderConstruction);
|
||||
|
||||
static void BM_ParagraphBuilderPushStyle(benchmark::State& state) {
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
txt::ParagraphBuilder builder(paragraph_style);
|
||||
|
||||
txt::TextStyle text_style;
|
||||
text_style.color = SK_ColorBLACK;
|
||||
while (state.KeepRunning()) {
|
||||
builder.PushStyle(text_style);
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_ParagraphBuilderPushStyle);
|
||||
|
||||
static void BM_ParagraphBuilderPushPop(benchmark::State& state) {
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
txt::ParagraphBuilder builder(paragraph_style);
|
||||
|
||||
txt::TextStyle text_style;
|
||||
text_style.color = SK_ColorBLACK;
|
||||
while (state.KeepRunning()) {
|
||||
builder.PushStyle(text_style);
|
||||
builder.Pop();
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_ParagraphBuilderPushPop);
|
||||
|
||||
static void BM_ParagraphBuilderAddTextString(benchmark::State& state) {
|
||||
std::string text = "Hello World";
|
||||
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
txt::ParagraphBuilder builder(paragraph_style);
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
builder.AddText(text);
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_ParagraphBuilderAddTextString);
|
||||
|
||||
static void BM_ParagraphBuilderAddTextChar(benchmark::State& state) {
|
||||
const char* text = "Hello World";
|
||||
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
txt::ParagraphBuilder builder(paragraph_style);
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
builder.AddText(text);
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_ParagraphBuilderAddTextChar);
|
||||
|
||||
static void BM_ParagraphBuilderAddTextU16stringShort(benchmark::State& state) {
|
||||
const char* text = "H";
|
||||
auto icu_text = icu::UnicodeString::fromUTF8(text);
|
||||
std::u16string u16_text(icu_text.getBuffer(),
|
||||
icu_text.getBuffer() + icu_text.length());
|
||||
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
txt::ParagraphBuilder builder(paragraph_style);
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
builder.AddText(u16_text);
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_ParagraphBuilderAddTextU16stringShort);
|
||||
|
||||
static void BM_ParagraphBuilderAddTextU16stringLong(benchmark::State& state) {
|
||||
const char* text =
|
||||
"This is a very long sentence to test if the text will properly wrap "
|
||||
"around and go to the next line. Sometimes, short sentence. Longer "
|
||||
"sentences are okay too because they are necessary. Very short. "
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
|
||||
"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
|
||||
"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
|
||||
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate "
|
||||
"velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint "
|
||||
"occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
|
||||
"mollit anim id est laborum. "
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
|
||||
"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
|
||||
"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
|
||||
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate "
|
||||
"velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint "
|
||||
"occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
|
||||
"mollit anim id est laborum.";
|
||||
auto icu_text = icu::UnicodeString::fromUTF8(text);
|
||||
std::u16string u16_text(icu_text.getBuffer(),
|
||||
icu_text.getBuffer() + icu_text.length());
|
||||
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
txt::ParagraphBuilder builder(paragraph_style);
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
builder.AddText(u16_text);
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_ParagraphBuilderAddTextU16stringLong);
|
||||
|
||||
static void BM_ParagraphBuilderShortParagraphConstruct(
|
||||
benchmark::State& state) {
|
||||
const char* text = "Hello World";
|
||||
auto icu_text = icu::UnicodeString::fromUTF8(text);
|
||||
std::u16string u16_text(icu_text.getBuffer(),
|
||||
icu_text.getBuffer() + icu_text.length());
|
||||
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
txt::ParagraphBuilder builder(paragraph_style);
|
||||
|
||||
txt::TextStyle text_style;
|
||||
text_style.color = SK_ColorBLACK;
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
builder.PushStyle(text_style);
|
||||
builder.AddText(u16_text);
|
||||
builder.Pop();
|
||||
auto paragraph = builder.Build();
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_ParagraphBuilderShortParagraphConstruct);
|
||||
|
||||
static void BM_ParagraphBuilderLongParagraphConstruct(benchmark::State& state) {
|
||||
const char* text =
|
||||
"This is a very long sentence to test if the text will properly wrap "
|
||||
"around and go to the next line. Sometimes, short sentence. Longer "
|
||||
"sentences are okay too because they are necessary. Very short. "
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
|
||||
"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
|
||||
"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
|
||||
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate "
|
||||
"velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint "
|
||||
"occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
|
||||
"mollit anim id est laborum. "
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
|
||||
"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
|
||||
"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
|
||||
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate "
|
||||
"velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint "
|
||||
"occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
|
||||
"mollit anim id est laborum.";
|
||||
auto icu_text = icu::UnicodeString::fromUTF8(text);
|
||||
std::u16string u16_text(icu_text.getBuffer(),
|
||||
icu_text.getBuffer() + icu_text.length());
|
||||
|
||||
txt::ParagraphStyle paragraph_style;
|
||||
txt::ParagraphBuilder builder(paragraph_style);
|
||||
|
||||
txt::TextStyle text_style;
|
||||
text_style.color = SK_ColorBLACK;
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
builder.PushStyle(text_style);
|
||||
builder.AddText(u16_text);
|
||||
builder.Pop();
|
||||
auto paragraph = builder.Build();
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_ParagraphBuilderLongParagraphConstruct);
|
||||
|
||||
} // namespace txt
|
||||
41
engine/src/flutter/benchmarks/txt_run_all_benchmarks.cc
Normal file
41
engine/src/flutter/benchmarks/txt_run_all_benchmarks.cc
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2017 Google, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "third_party/benchmark/include/benchmark/benchmark_api.h"
|
||||
|
||||
#include "flutter/fml/icu_util.h"
|
||||
#include "lib/ftl/logging.h"
|
||||
#include "utils.h"
|
||||
|
||||
// We will use a custom main to allow custom font directories for consistency.
|
||||
int main(int argc, char** argv) {
|
||||
::benchmark::Initialize(&argc, argv);
|
||||
ftl::CommandLine cmd = ftl::CommandLineFromArgcArgv(argc, argv);
|
||||
txt::SetCommandLine(cmd);
|
||||
std::string dir = txt::GetCommandLineForProcess().GetOptionValueWithDefault(
|
||||
"font-directory", "");
|
||||
txt::SetFontDir(dir);
|
||||
if (txt::GetFontDir().length() <= 0) {
|
||||
FTL_LOG(ERROR) << "Font directory must be specified with "
|
||||
"--font-directoy=\"<directoy>\" to run this test.";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
FTL_DCHECK(txt::GetFontDir().length() > 0);
|
||||
|
||||
fml::icu::InitializeICU();
|
||||
|
||||
::benchmark::RunSpecifiedBenchmarks();
|
||||
}
|
||||
43
engine/src/flutter/benchmarks/utils.cc
Normal file
43
engine/src/flutter/benchmarks/utils.cc
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2017 Google, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "lib/ftl/command_line.h"
|
||||
#include "lib/txt/tests/txt/utils.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
static std::string gFontDir;
|
||||
static ftl::CommandLine gCommandLine;
|
||||
|
||||
const std::string GetFontDir() {
|
||||
return gFontDir;
|
||||
}
|
||||
|
||||
void SetFontDir(const std::string& dir) {
|
||||
gFontDir = dir;
|
||||
}
|
||||
|
||||
const ftl::CommandLine& GetCommandLineForProcess() {
|
||||
return gCommandLine;
|
||||
}
|
||||
|
||||
void SetCommandLine(ftl::CommandLine cmd) {
|
||||
gCommandLine = std::move(cmd);
|
||||
}
|
||||
|
||||
} // namespace txt
|
||||
31
engine/src/flutter/benchmarks/utils.h
Normal file
31
engine/src/flutter/benchmarks/utils.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2017 Google, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "lib/ftl/command_line.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
const std::string GetFontDir();
|
||||
|
||||
void SetFontDir(const std::string& dir);
|
||||
|
||||
const ftl::CommandLine& GetCommandLineForProcess();
|
||||
|
||||
void SetCommandLine(ftl::CommandLine cmd);
|
||||
|
||||
} // namespace txt
|
||||
@@ -140,10 +140,11 @@ void Paragraph::AddRunsToLineBreaker(const std::string& rootdir) {
|
||||
|
||||
void Paragraph::Layout(double width,
|
||||
const std::string& rootdir,
|
||||
bool force,
|
||||
const double x_offset,
|
||||
const double y_offset) {
|
||||
// Do not allow calling layout multiple times without changing anything.
|
||||
if (!needs_layout_)
|
||||
if (!needs_layout_ && !force)
|
||||
return;
|
||||
needs_layout_ = false;
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ class Paragraph {
|
||||
|
||||
void Layout(double width,
|
||||
const std::string& rootdir = "",
|
||||
bool force = false,
|
||||
const double x_offset = 0.0,
|
||||
const double y_offset = 0.0);
|
||||
|
||||
|
||||
@@ -21,15 +21,15 @@
|
||||
|
||||
namespace txt {
|
||||
|
||||
static std::string gFontdir;
|
||||
static std::string gFontDir;
|
||||
static ftl::CommandLine gCommandLine;
|
||||
|
||||
const std::string GetFontDir() {
|
||||
return gFontdir;
|
||||
return gFontDir;
|
||||
}
|
||||
|
||||
void SetFontDir(std::string& dir) {
|
||||
gFontdir = dir;
|
||||
void SetFontDir(const std::string& dir) {
|
||||
gFontDir = dir;
|
||||
}
|
||||
|
||||
const ftl::CommandLine& GetCommandLineForProcess() {
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace txt {
|
||||
|
||||
const std::string GetFontDir();
|
||||
|
||||
void SetFontDir(std::string& dir);
|
||||
void SetFontDir(const std::string& dir);
|
||||
|
||||
const ftl::CommandLine& GetCommandLineForProcess();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user