Skip to content

Commit 82de334

Browse files
Revert "Replace use of Fontmgr::RefDefault with explicit creation calls" (flutter#48755)
This reverts commit ab89510. The flutter/tests/skp_generator test (running in flutter_tester on Linux) was failing, along with some customer tests.
1 parent 4854128 commit 82de334

17 files changed

Lines changed: 140 additions & 132 deletions

File tree

build/secondary/flutter/third_party/glfw/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ source_set("glfw") {
5555
"$_checkout_dir/src/win32_window.c",
5656
]
5757

58-
libs = [ "Gdi32.lib" ]
59-
6058
defines = [ "_GLFW_WIN32" ]
6159
} else if (is_linux) {
6260
sources += [

display_list/testing/dl_rendering_unittests.cc

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "flutter/display_list/skia/dl_sk_canvas.h"
1212
#include "flutter/display_list/skia/dl_sk_conversions.h"
1313
#include "flutter/display_list/skia/dl_sk_dispatcher.h"
14-
#include "flutter/display_list/testing/dl_test_snippets.h"
1514
#include "flutter/display_list/testing/dl_test_surface_provider.h"
1615
#include "flutter/display_list/utils/dl_comparable.h"
1716
#include "flutter/fml/file.h"
@@ -59,7 +58,7 @@ constexpr SkScalar kRenderRadius = std::min(kRenderWidth, kRenderHeight) / 2.0;
5958
constexpr SkScalar kRenderCornerRadius = kRenderRadius / 5.0;
6059

6160
constexpr SkPoint kTestCenter = SkPoint::Make(kTestWidth / 2, kTestHeight / 2);
62-
constexpr SkRect kTestBounds2 = SkRect::MakeWH(kTestWidth, kTestHeight);
61+
constexpr SkRect kTestBounds = SkRect::MakeWH(kTestWidth, kTestHeight);
6362
constexpr SkRect kRenderBounds =
6463
SkRect::MakeLTRB(kRenderLeft, kRenderTop, kRenderRight, kRenderBottom);
6564

@@ -487,7 +486,7 @@ struct SkJobRenderer : public MatrixClipJobRenderer {
487486
sk_sp<SkPicture> MakePicture(const RenderJobInfo& info) {
488487
SkPictureRecorder recorder;
489488
SkRTreeFactory rtree_factory;
490-
SkCanvas* cv = recorder.beginRecording(kTestBounds2, &rtree_factory);
489+
SkCanvas* cv = recorder.beginRecording(kTestBounds, &rtree_factory);
491490
Render(cv, info);
492491
return recorder.finishRecordingAsPicture();
493492
}
@@ -533,7 +532,7 @@ struct DlJobRenderer : public MatrixClipJobRenderer {
533532
}
534533

535534
sk_sp<DisplayList> MakeDisplayList(const RenderJobInfo& info) {
536-
DisplayListBuilder builder(kTestBounds2);
535+
DisplayListBuilder builder(kTestBounds);
537536
Render(&builder, info);
538537
return builder.Build();
539538
}
@@ -2751,10 +2750,9 @@ class CanvasCompareTester {
27512750

27522751
static sk_sp<SkTextBlob> MakeTextBlob(const std::string& string,
27532752
SkScalar font_height) {
2754-
SkFont font = CreateTestFontOfSize(font_height);
2755-
sk_sp<SkTypeface> face = font.refTypeface();
2756-
FML_CHECK(face);
2757-
FML_CHECK(face->countGlyphs() > 0) << "No glyphs in font";
2753+
SkFont font(txt::GetDefaultFontManager()->matchFamilyStyle(
2754+
"ahem", SkFontStyle::Normal()),
2755+
font_height);
27582756
return SkTextBlob::MakeFromText(string.c_str(), string.size(), font,
27592757
SkTextEncoding::kUTF8);
27602758
}
@@ -3803,7 +3801,7 @@ TEST_F(DisplayListRendering, SaveLayerClippedContentStillFilters) {
38033801
const SkRect draw_rect = SkRect::MakeLTRB( //
38043802
kRenderRight + 1, //
38053803
kRenderTop, //
3806-
kTestBounds2.fRight, //
3804+
kTestBounds.fRight, //
38073805
kRenderBottom //
38083806
);
38093807
TestParameters test_params(
@@ -3814,7 +3812,7 @@ TEST_F(DisplayListRendering, SaveLayerClippedContentStillFilters) {
38143812
layer_paint.setImageFilter(layer_filter);
38153813
ctx.canvas->save();
38163814
ctx.canvas->clipRect(kRenderBounds, SkClipOp::kIntersect, false);
3817-
ctx.canvas->saveLayer(&kTestBounds2, &layer_paint);
3815+
ctx.canvas->saveLayer(&kTestBounds, &layer_paint);
38183816
ctx.canvas->drawRect(draw_rect, ctx.paint);
38193817
ctx.canvas->restore();
38203818
ctx.canvas->restore();
@@ -3826,7 +3824,7 @@ TEST_F(DisplayListRendering, SaveLayerClippedContentStillFilters) {
38263824
layer_paint.setImageFilter(layer_filter);
38273825
ctx.canvas->Save();
38283826
ctx.canvas->ClipRect(kRenderBounds, ClipOp::kIntersect, false);
3829-
ctx.canvas->SaveLayer(&kTestBounds2, &layer_paint);
3827+
ctx.canvas->SaveLayer(&kTestBounds, &layer_paint);
38303828
ctx.canvas->DrawRect(draw_rect, ctx.paint);
38313829
ctx.canvas->Restore();
38323830
ctx.canvas->Restore();
@@ -3908,19 +3906,19 @@ TEST_F(DisplayListRendering, SaveLayerConsolidation) {
39083906
const std::string& desc1, const std::string& desc2,
39093907
const RenderEnvironment* env) {
39103908
DisplayListBuilder nested_builder;
3911-
nested_builder.SaveLayer(&kTestBounds2, &paint1);
3912-
nested_builder.SaveLayer(&kTestBounds2, &paint2);
3909+
nested_builder.SaveLayer(&kTestBounds, &paint1);
3910+
nested_builder.SaveLayer(&kTestBounds, &paint2);
39133911
render_content(nested_builder);
39143912
auto nested_results = env->getResult(nested_builder.Build());
39153913

39163914
DisplayListBuilder reverse_builder;
3917-
reverse_builder.SaveLayer(&kTestBounds2, &paint2);
3918-
reverse_builder.SaveLayer(&kTestBounds2, &paint1);
3915+
reverse_builder.SaveLayer(&kTestBounds, &paint2);
3916+
reverse_builder.SaveLayer(&kTestBounds, &paint1);
39193917
render_content(reverse_builder);
39203918
auto reverse_results = env->getResult(reverse_builder.Build());
39213919

39223920
DisplayListBuilder combined_builder;
3923-
combined_builder.SaveLayer(&kTestBounds2, &paint_both);
3921+
combined_builder.SaveLayer(&kTestBounds, &paint_both);
39243922
render_content(combined_builder);
39253923
auto combined_results = env->getResult(combined_builder.Build());
39263924

@@ -4058,7 +4056,7 @@ TEST_F(DisplayListRendering, MatrixColorFilterModifyTransparencyCheck) {
40584056
builder2.Translate(kTestCenter.fX, kTestCenter.fY);
40594057
builder2.Rotate(45);
40604058
builder2.Translate(-kTestCenter.fX, -kTestCenter.fY);
4061-
builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
4059+
builder2.SaveLayer(&kTestBounds, &filter_save_paint);
40624060
builder2.DrawRect(kRenderBounds, paint);
40634061
builder2.Restore();
40644062
auto display_list2 = builder2.Build();
@@ -4117,17 +4115,17 @@ TEST_F(DisplayListRendering, MatrixColorFilterOpacityCommuteCheck) {
41174115
DlPaint filter_save_paint = DlPaint().setColorFilter(filter);
41184116

41194117
DisplayListBuilder builder1;
4120-
builder1.SaveLayer(&kTestBounds2, &opacity_save_paint);
4121-
builder1.SaveLayer(&kTestBounds2, &filter_save_paint);
4118+
builder1.SaveLayer(&kTestBounds, &opacity_save_paint);
4119+
builder1.SaveLayer(&kTestBounds, &filter_save_paint);
41224120
// builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
41234121
builder1.DrawRect(kRenderBounds, paint);
41244122
builder1.Restore();
41254123
builder1.Restore();
41264124
auto display_list1 = builder1.Build();
41274125

41284126
DisplayListBuilder builder2;
4129-
builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
4130-
builder2.SaveLayer(&kTestBounds2, &opacity_save_paint);
4127+
builder2.SaveLayer(&kTestBounds, &filter_save_paint);
4128+
builder2.SaveLayer(&kTestBounds, &opacity_save_paint);
41314129
// builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
41324130
builder2.DrawRect(kRenderBounds, paint);
41334131
builder2.Restore();
@@ -4234,7 +4232,7 @@ TEST_F(DisplayListRendering, BlendColorFilterModifyTransparencyCheck) {
42344232
builder2.Translate(kTestCenter.fX, kTestCenter.fY);
42354233
builder2.Rotate(45);
42364234
builder2.Translate(-kTestCenter.fX, -kTestCenter.fY);
4237-
builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
4235+
builder2.SaveLayer(&kTestBounds, &filter_save_paint);
42384236
builder2.DrawRect(kRenderBounds, paint);
42394237
builder2.Restore();
42404238
auto display_list2 = builder2.Build();
@@ -4286,17 +4284,17 @@ TEST_F(DisplayListRendering, BlendColorFilterOpacityCommuteCheck) {
42864284
DlPaint filter_save_paint = DlPaint().setColorFilter(&filter);
42874285

42884286
DisplayListBuilder builder1;
4289-
builder1.SaveLayer(&kTestBounds2, &opacity_save_paint);
4290-
builder1.SaveLayer(&kTestBounds2, &filter_save_paint);
4287+
builder1.SaveLayer(&kTestBounds, &opacity_save_paint);
4288+
builder1.SaveLayer(&kTestBounds, &filter_save_paint);
42914289
// builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
42924290
builder1.DrawRect(kRenderBounds, paint);
42934291
builder1.Restore();
42944292
builder1.Restore();
42954293
auto display_list1 = builder1.Build();
42964294

42974295
DisplayListBuilder builder2;
4298-
builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
4299-
builder2.SaveLayer(&kTestBounds2, &opacity_save_paint);
4296+
builder2.SaveLayer(&kTestBounds, &filter_save_paint);
4297+
builder2.SaveLayer(&kTestBounds, &opacity_save_paint);
43004298
// builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
43014299
builder2.DrawRect(kRenderBounds, paint);
43024300
builder2.Restore();

flow/layers/performance_overlay_layer.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,11 @@ sk_sp<SkTextBlob> PerformanceOverlayLayer::MakeStatisticsText(
7474
const std::string& label_prefix,
7575
const std::string& font_path) {
7676
SkFont font;
77-
sk_sp<SkFontMgr> font_mgr = txt::GetDefaultFontManager();
78-
if (font_path == "") {
79-
font = SkFont(font_mgr->matchFamilyStyle(nullptr, {}), 15);
80-
} else {
81-
font = SkFont(font_mgr->makeFromFile(font_path.c_str()), 15);
77+
if (font_path != "") {
78+
sk_sp<SkFontMgr> font_mgr = txt::GetDefaultFontManager();
79+
font = SkFont(font_mgr->makeFromFile(font_path.c_str()));
8280
}
81+
font.setSize(15);
8382

8483
double max_ms_per_frame = stopwatch.MaxDelta().ToMillisecondsF();
8584
double average_ms_per_frame = stopwatch.AverageDelta().ToMillisecondsF();

impeller/entity/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ impeller_component("entity_unittests") {
277277
":entity_test_helpers",
278278
"../geometry:geometry_asserts",
279279
"../playground:playground_test",
280-
"//flutter/display_list/testing:display_list_testing",
281280
"//flutter/impeller/typographer/backends/skia:typographer_skia_backend",
282281
]
283282
}

impeller/entity/entity_unittests.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <utility>
99
#include <vector>
1010

11-
#include "flutter/display_list/testing/dl_test_snippets.h"
1211
#include "fml/logging.h"
1312
#include "gtest/gtest.h"
1413
#include "impeller/core/formats.h"
@@ -2193,7 +2192,8 @@ TEST_P(EntityTest, InheritOpacityTest) {
21932192

21942193
// Text contents can accept opacity if the text frames do not
21952194
// overlap
2196-
SkFont font = flutter::testing::CreateTestFontOfSize(30);
2195+
SkFont font;
2196+
font.setSize(30);
21972197
auto blob = SkTextBlob::MakeFromString("A", font);
21982198
auto frame = MakeTextFrameFromTextBlobSkia(blob);
21992199
auto lazy_glyph_atlas =

impeller/typographer/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ impeller_component("typographer_unittests") {
4646
"../playground:playground_test",
4747
"backends/skia:typographer_skia_backend",
4848
"backends/stb:typographer_stb_backend",
49-
"//flutter/display_list/testing:display_list_testing",
5049
"//flutter/third_party/txt",
5150
]
5251
}

impeller/typographer/typographer_unittests.cc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#include "flutter/display_list/testing/dl_test_snippets.h"
65
#include "flutter/testing/testing.h"
76
#include "impeller/playground/playground_test.h"
87
#include "impeller/typographer/backends/skia/text_frame_skia.h"
98
#include "impeller/typographer/backends/skia/typographer_context_skia.h"
109
#include "impeller/typographer/lazy_glyph_atlas.h"
1110
#include "impeller/typographer/rectangle_packer.h"
1211
#include "third_party/skia/include/core/SkData.h"
13-
#include "third_party/skia/include/core/SkFont.h"
1412
#include "third_party/skia/include/core/SkFontMgr.h"
1513
#include "third_party/skia/include/core/SkRect.h"
1614
#include "third_party/skia/include/core/SkTextBlob.h"
@@ -40,7 +38,7 @@ static std::shared_ptr<GlyphAtlas> CreateGlyphAtlas(
4038
}
4139

4240
TEST_P(TypographerTest, CanConvertTextBlob) {
43-
SkFont font = flutter::testing::CreateTestFontOfSize(12);
41+
SkFont font;
4442
auto blob = SkTextBlob::MakeFromString(
4543
"the quick brown fox jumped over the lazy dog.", font);
4644
ASSERT_TRUE(blob);
@@ -61,7 +59,7 @@ TEST_P(TypographerTest, CanCreateGlyphAtlas) {
6159
auto context = TypographerContextSkia::Make();
6260
auto atlas_context = context->CreateGlyphAtlasContext();
6361
ASSERT_TRUE(context && context->IsValid());
64-
SkFont sk_font = flutter::testing::CreateTestFontOfSize(12);
62+
SkFont sk_font;
6563
auto blob = SkTextBlob::MakeFromString("hello", sk_font);
6664
ASSERT_TRUE(blob);
6765
auto atlas = CreateGlyphAtlas(
@@ -99,7 +97,7 @@ TEST_P(TypographerTest, LazyAtlasTracksColor) {
9997
ASSERT_TRUE(mapping);
10098
sk_sp<SkFontMgr> font_mgr = txt::GetDefaultFontManager();
10199
SkFont emoji_font(font_mgr->makeFromData(mapping), 50.0);
102-
SkFont sk_font = flutter::testing::CreateTestFontOfSize(12);
100+
SkFont sk_font;
103101

104102
auto blob = SkTextBlob::MakeFromString("hello", sk_font);
105103
ASSERT_TRUE(blob);
@@ -132,7 +130,7 @@ TEST_P(TypographerTest, GlyphAtlasWithOddUniqueGlyphSize) {
132130
auto context = TypographerContextSkia::Make();
133131
auto atlas_context = context->CreateGlyphAtlasContext();
134132
ASSERT_TRUE(context && context->IsValid());
135-
SkFont sk_font = flutter::testing::CreateTestFontOfSize(12);
133+
SkFont sk_font;
136134
auto blob = SkTextBlob::MakeFromString("AGH", sk_font);
137135
ASSERT_TRUE(blob);
138136
auto atlas = CreateGlyphAtlas(
@@ -149,7 +147,7 @@ TEST_P(TypographerTest, GlyphAtlasIsRecycledIfUnchanged) {
149147
auto context = TypographerContextSkia::Make();
150148
auto atlas_context = context->CreateGlyphAtlasContext();
151149
ASSERT_TRUE(context && context->IsValid());
152-
SkFont sk_font = flutter::testing::CreateTestFontOfSize(12);
150+
SkFont sk_font;
153151
auto blob = SkTextBlob::MakeFromString("spooky skellingtons", sk_font);
154152
ASSERT_TRUE(blob);
155153
auto atlas = CreateGlyphAtlas(
@@ -179,7 +177,7 @@ TEST_P(TypographerTest, GlyphAtlasWithLotsOfdUniqueGlyphSize) {
179177
"œ∑´®†¥¨ˆøπ““‘‘åß∂ƒ©˙∆˚¬…æ≈ç√∫˜µ≤≥≥≥≥÷¡™£¢∞§¶•ªº–≠⁄€‹›fifl‡°·‚—±Œ„´‰Á¨Ø∏”’/"
180178
"* Í˝ */¸˛Ç◊ı˜Â¯˘¿";
181179

182-
SkFont sk_font = flutter::testing::CreateTestFontOfSize(12);
180+
SkFont sk_font;
183181
auto blob = SkTextBlob::MakeFromString(test_string, sk_font);
184182
ASSERT_TRUE(blob);
185183

@@ -216,7 +214,7 @@ TEST_P(TypographerTest, GlyphAtlasTextureIsRecycledIfUnchanged) {
216214
auto context = TypographerContextSkia::Make();
217215
auto atlas_context = context->CreateGlyphAtlasContext();
218216
ASSERT_TRUE(context && context->IsValid());
219-
SkFont sk_font = flutter::testing::CreateTestFontOfSize(12);
217+
SkFont sk_font;
220218
auto blob = SkTextBlob::MakeFromString("spooky 1", sk_font);
221219
ASSERT_TRUE(blob);
222220
auto atlas = CreateGlyphAtlas(
@@ -249,7 +247,7 @@ TEST_P(TypographerTest, GlyphAtlasTextureIsRecreatedIfTypeChanges) {
249247
auto context = TypographerContextSkia::Make();
250248
auto atlas_context = context->CreateGlyphAtlasContext();
251249
ASSERT_TRUE(context && context->IsValid());
252-
SkFont sk_font = flutter::testing::CreateTestFontOfSize(12);
250+
SkFont sk_font;
253251
auto blob = SkTextBlob::MakeFromString("spooky 1", sk_font);
254252
ASSERT_TRUE(blob);
255253
auto atlas = CreateGlyphAtlas(

shell/common/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ if (enable_unittests) {
202202
fixtures = [
203203
"fixtures/shelltest_screenshot.png",
204204
"fixtures/hello_loop_2.gif",
205-
"//flutter/third_party/txt/third_party/fonts/Roboto-Regular.ttf",
206205
]
207206
}
208207

@@ -323,7 +322,6 @@ if (enable_unittests) {
323322
":shell_unittests_fixtures",
324323
"//flutter/assets",
325324
"//flutter/common/graphics",
326-
"//flutter/display_list/testing:display_list_testing",
327325
"//flutter/shell/common:base64",
328326
"//flutter/shell/profiling:profiling_unittests",
329327
"//flutter/shell/version",

shell/common/dl_op_spy_unittests.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
#include "flutter/display_list/display_list.h"
66
#include "flutter/display_list/dl_builder.h"
7-
#include "flutter/display_list/testing/dl_test_snippets.h"
87
#include "flutter/shell/common/dl_op_spy.h"
98
#include "flutter/testing/testing.h"
109
#include "third_party/skia/include/core/SkBitmap.h"
11-
#include "third_party/skia/include/core/SkFont.h"
1210
#include "third_party/skia/include/core/SkRSXform.h"
1311

1412
namespace flutter {
@@ -547,7 +545,7 @@ TEST(DlOpSpy, DrawTextBlob) {
547545
DisplayListBuilder builder;
548546
DlPaint paint(DlColor::kBlack());
549547
std::string string = "xx";
550-
SkFont font = CreateTestFontOfSize(12);
548+
SkFont font;
551549
auto text_blob = SkTextBlob::MakeFromString(string.c_str(), font);
552550
builder.DrawTextBlob(text_blob, 1, 1, paint);
553551
sk_sp<DisplayList> dl = builder.Build();
@@ -559,7 +557,7 @@ TEST(DlOpSpy, DrawTextBlob) {
559557
DisplayListBuilder builder;
560558
DlPaint paint(DlColor::kTransparent());
561559
std::string string = "xx";
562-
SkFont font = CreateTestFontOfSize(12);
560+
SkFont font;
563561
auto text_blob = SkTextBlob::MakeFromString(string.c_str(), font);
564562
builder.DrawTextBlob(text_blob, 1, 1, paint);
565563
sk_sp<DisplayList> dl = builder.Build();

shell/platform/fuchsia/flutter/BUILD.gn

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -750,11 +750,6 @@ if (enable_unittests) {
750750
"$root_gen_dir/flutter/shell/common/assets/shelltest_screenshot.png"
751751
dest = "assets/shelltest_screenshot.png"
752752
},
753-
{
754-
path = rebase_path(
755-
"//flutter/third_party/txt/third_party/fonts/Roboto-Regular.ttf")
756-
dest = "assets/Roboto-Regular.ttf"
757-
},
758753
]
759754

760755
libraries = vulkan_validation_libs

0 commit comments

Comments
 (0)