Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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
16 changes: 7 additions & 9 deletions display_list/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ source_set("display_list") {
}
}

if (enable_unittests) {
test_fixtures("display_list_fixtures") {
fixtures = []
}
test_fixtures("display_list_fixtures") {
fixtures =
[ "//flutter/third_party/txt/third_party/fonts/Roboto-Regular.ttf" ]
}

if (enable_unittests) {
executable("display_list_unittests") {
testonly = true

Expand Down Expand Up @@ -201,10 +202,6 @@ if (enable_unittests) {
}
}

fixtures_location("display_list_benchmarks_fixtures") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really unused?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not see any references to fixtures in the DL benchmarks. The benchmarks appear to be running as expected with this change.

assets_dir = "$target_gen_dir/"
}

source_set("display_list_benchmarks_source") {
testonly = true

Expand All @@ -215,10 +212,11 @@ source_set("display_list_benchmarks_source") {

deps = [
":display_list",
":display_list_benchmarks_fixtures",
":display_list_fixtures",
"//flutter/benchmarking",
"//flutter/common/graphics",
"//flutter/display_list/testing:display_list_surface_provider",
"//flutter/display_list/testing:display_list_testing",
"//flutter/fml",
"//flutter/testing:skia",
"//flutter/testing:testing_lib",
Expand Down
3 changes: 2 additions & 1 deletion display_list/benchmarking/dl_benchmarks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "flutter/display_list/dl_builder.h"
#include "flutter/display_list/dl_op_flags.h"
#include "flutter/display_list/skia/dl_sk_canvas.h"
#include "flutter/display_list/testing/dl_test_snippets.h"

#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkImage.h"
Expand Down Expand Up @@ -1203,7 +1204,7 @@ void BM_DrawTextBlob(benchmark::State& state,

for (size_t i = 0; i < draw_calls; i++) {
character[0] = 'A' + (i % 26);
auto blob = SkTextBlob::MakeFromString(character, SkFont());
auto blob = SkTextBlob::MakeFromString(character, CreateTestFontOfSize(20));
builder.DrawTextBlob(blob, 50.0f, 50.0f, paint);
}

Expand Down
2 changes: 1 addition & 1 deletion display_list/benchmarking/dl_complexity_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ TEST(DisplayListComplexity, DrawVertices) {

TEST(DisplayListComplexity, DrawTextBlob) {
auto text_blob = SkTextBlob::MakeFromString(
"The quick brown fox jumps over the lazy dog.", SkFont());
"The quick brown fox jumps over the lazy dog.", CreateTestFontOfSize(20));

DisplayListBuilder builder;
builder.DrawTextBlob(text_blob, 0.0f, 0.0f, DlPaint());
Expand Down
4 changes: 2 additions & 2 deletions display_list/display_list_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ TEST_F(DisplayListTest, SingleOpsMightSupportGroupOpacityBlendMode) {
static auto display_list = builder.Build();
RUN_TESTS2(receiver.drawDisplayList(display_list);, false);
}
RUN_TESTS2(receiver.drawTextBlob(TestBlob1, 0, 0);, false);
RUN_TESTS2(receiver.drawTextBlob(GetTestTextBlob(1), 0, 0);, false);
RUN_TESTS2(
receiver.drawShadow(kTestPath1, DlColor(SK_ColorBLACK), 1.0, false, 1.0);
, false);
Expand Down Expand Up @@ -3145,7 +3145,7 @@ TEST_F(DisplayListTest, NopOperationsOmittedFromRecords) {
builder.DrawAtlas(TestImage1, xforms, rects, nullptr, 2,
DlBlendMode::kSrcOver, DlImageSampling::kLinear,
nullptr, &paint);
builder.DrawTextBlob(TestBlob1, 10, 10, paint);
builder.DrawTextBlob(GetTestTextBlob(1), 10, 10, paint);

// Dst mode eliminates most rendering ops except for
// the following two, so we'll prune those manually...
Expand Down
37 changes: 33 additions & 4 deletions display_list/testing/dl_test_snippets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -901,13 +901,21 @@ std::vector<DisplayListInvocationGroup> CreateAllRenderingOps() {
{"DrawTextBlob",
{
{1, 24, 1, 24,
[](DlOpReceiver& r) { r.drawTextBlob(TestBlob1, 10, 10); }},
[](DlOpReceiver& r) {
r.drawTextBlob(GetTestTextBlob(1), 10, 10);
}},
{1, 24, 1, 24,
[](DlOpReceiver& r) { r.drawTextBlob(TestBlob1, 20, 10); }},
[](DlOpReceiver& r) {
r.drawTextBlob(GetTestTextBlob(1), 20, 10);
}},
{1, 24, 1, 24,
[](DlOpReceiver& r) { r.drawTextBlob(TestBlob1, 10, 20); }},
[](DlOpReceiver& r) {
r.drawTextBlob(GetTestTextBlob(1), 10, 20);
}},
{1, 24, 1, 24,
[](DlOpReceiver& r) { r.drawTextBlob(TestBlob2, 10, 10); }},
[](DlOpReceiver& r) {
r.drawTextBlob(GetTestTextBlob(2), 10, 10);
}},
}},
// The -1 op counts below are to indicate to the framework not to test
// SkCanvas conversion of these ops as it converts the operation into a
Expand Down Expand Up @@ -966,5 +974,26 @@ std::vector<DisplayListInvocationGroup> CreateAllGroups() {
return result;
}

SkFont CreateTestFontOfSize(SkScalar scalar) {
static constexpr const char* kTestFontFixture = "Roboto-Regular.ttf";
auto mapping = flutter::testing::OpenFixtureAsSkData(kTestFontFixture);
FML_CHECK(mapping);
return SkFont{SkTypeface::MakeFromData(mapping), scalar};
}

sk_sp<SkTextBlob> GetTestTextBlob(int index) {
static std::map<int, sk_sp<SkTextBlob>> text_blobs;
auto it = text_blobs.find(index);
if (it != text_blobs.end()) {
return it->second;
}
std::string text = "TestBlob" + std::to_string(index);
sk_sp<SkTextBlob> blob =
SkTextBlob::MakeFromText(text.c_str(), text.size(),
CreateTestFontOfSize(20), SkTextEncoding::kUTF8);
text_blobs.insert(std::make_pair(index, blob));
return blob;
}

} // namespace testing
} // namespace flutter
10 changes: 4 additions & 6 deletions display_list/testing/dl_test_snippets.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "flutter/display_list/display_list.h"
#include "flutter/display_list/dl_builder.h"
#include "flutter/testing/testing.h"

#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkSurface.h"
Expand Down Expand Up @@ -222,12 +223,9 @@ static sk_sp<DisplayList> TestDisplayList1 =
static sk_sp<DisplayList> TestDisplayList2 =
MakeTestDisplayList(25, 25, SK_ColorBLUE);

static sk_sp<SkTextBlob> MakeTextBlob(std::string string) {
return SkTextBlob::MakeFromText(string.c_str(), string.size(), SkFont(),
SkTextEncoding::kUTF8);
}
static sk_sp<SkTextBlob> TestBlob1 = MakeTextBlob("TestBlob1");
static sk_sp<SkTextBlob> TestBlob2 = MakeTextBlob("TestBlob2");
SkFont CreateTestFontOfSize(SkScalar scalar);

sk_sp<SkTextBlob> GetTestTextBlob(int index);

struct DisplayListInvocation {
unsigned int op_count_;
Expand Down
3 changes: 2 additions & 1 deletion flow/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ source_set("flow") {

if (enable_unittests) {
test_fixtures("flow_fixtures") {
fixtures = []
fixtures =
[ "//flutter/third_party/txt/third_party/fonts/Roboto-Regular.ttf" ]
}

source_set("flow_testing") {
Expand Down
21 changes: 21 additions & 0 deletions shell/platform/fuchsia/flutter/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -657,12 +657,28 @@ if (enable_unittests) {
deps = [ "//flutter/display_list:display_list_unittests" ]

binary = "display_list_unittests"

resources = [
{
path = rebase_path(
"//flutter/third_party/txt/third_party/fonts/Roboto-Regular.ttf")
dest = "assets/Roboto-Regular.ttf"
},
]
}

fuchsia_test_archive("display_list_render_tests") {
deps = [ "//flutter/display_list:display_list_rendertests" ]

binary = "display_list_rendertests"

resources = [
{
path = rebase_path(
"//flutter/third_party/txt/third_party/fonts/Roboto-Regular.ttf")
dest = "assets/Roboto-Regular.ttf"
},
]
}

fuchsia_test_archive("flow_tests") {
Expand All @@ -686,6 +702,11 @@ if (enable_unittests) {
"//flutter/testing/resources/performance_overlay_gold_120fps.png")
dest = "flutter/testing/resources/performance_overlay_gold_120fps.png"
},
{
path = rebase_path(
"//flutter/third_party/txt/third_party/fonts/Roboto-Regular.ttf")
dest = "assets/Roboto-Regular.ttf"
},
]
}

Expand Down