Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
2 changes: 2 additions & 0 deletions build/secondary/flutter/third_party/glfw/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ source_set("glfw") {
"$_checkout_dir/src/win32_window.c",
]

libs = [ "Gdi32.lib" ]

defines = [ "_GLFW_WIN32" ]
} else if (is_linux) {
sources += [
Expand Down
50 changes: 26 additions & 24 deletions display_list/testing/dl_rendering_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "flutter/display_list/skia/dl_sk_canvas.h"
#include "flutter/display_list/skia/dl_sk_conversions.h"
#include "flutter/display_list/skia/dl_sk_dispatcher.h"
#include "flutter/display_list/testing/dl_test_snippets.h"
#include "flutter/display_list/testing/dl_test_surface_provider.h"
#include "flutter/display_list/utils/dl_comparable.h"
#include "flutter/fml/file.h"
Expand Down Expand Up @@ -58,7 +59,7 @@ constexpr SkScalar kRenderRadius = std::min(kRenderWidth, kRenderHeight) / 2.0;
constexpr SkScalar kRenderCornerRadius = kRenderRadius / 5.0;

constexpr SkPoint kTestCenter = SkPoint::Make(kTestWidth / 2, kTestHeight / 2);
constexpr SkRect kTestBounds = SkRect::MakeWH(kTestWidth, kTestHeight);
constexpr SkRect kTestBounds2 = SkRect::MakeWH(kTestWidth, kTestHeight);
constexpr SkRect kRenderBounds =
SkRect::MakeLTRB(kRenderLeft, kRenderTop, kRenderRight, kRenderBottom);

Expand Down Expand Up @@ -486,7 +487,7 @@ struct SkJobRenderer : public MatrixClipJobRenderer {
sk_sp<SkPicture> MakePicture(const RenderJobInfo& info) {
SkPictureRecorder recorder;
SkRTreeFactory rtree_factory;
SkCanvas* cv = recorder.beginRecording(kTestBounds, &rtree_factory);
SkCanvas* cv = recorder.beginRecording(kTestBounds2, &rtree_factory);
Render(cv, info);
return recorder.finishRecordingAsPicture();
}
Expand Down Expand Up @@ -532,7 +533,7 @@ struct DlJobRenderer : public MatrixClipJobRenderer {
}

sk_sp<DisplayList> MakeDisplayList(const RenderJobInfo& info) {
DisplayListBuilder builder(kTestBounds);
DisplayListBuilder builder(kTestBounds2);
Render(&builder, info);
return builder.Build();
}
Expand Down Expand Up @@ -2750,9 +2751,10 @@ class CanvasCompareTester {

static sk_sp<SkTextBlob> MakeTextBlob(const std::string& string,
SkScalar font_height) {
SkFont font(txt::GetDefaultFontManager()->matchFamilyStyle(
"ahem", SkFontStyle::Normal()),
font_height);
SkFont font = CreateTestFontOfSize(font_height);
sk_sp<SkTypeface> face = font.refTypeface();
FML_CHECK(face);
FML_CHECK(face->countGlyphs() > 0) << "No glyphs in font";
return SkTextBlob::MakeFromText(string.c_str(), string.size(), font,
SkTextEncoding::kUTF8);
}
Expand Down Expand Up @@ -3801,7 +3803,7 @@ TEST_F(DisplayListRendering, SaveLayerClippedContentStillFilters) {
const SkRect draw_rect = SkRect::MakeLTRB( //
kRenderRight + 1, //
kRenderTop, //
kTestBounds.fRight, //
kTestBounds2.fRight, //
kRenderBottom //
);
TestParameters test_params(
Expand All @@ -3812,7 +3814,7 @@ TEST_F(DisplayListRendering, SaveLayerClippedContentStillFilters) {
layer_paint.setImageFilter(layer_filter);
ctx.canvas->save();
ctx.canvas->clipRect(kRenderBounds, SkClipOp::kIntersect, false);
ctx.canvas->saveLayer(&kTestBounds, &layer_paint);
ctx.canvas->saveLayer(&kTestBounds2, &layer_paint);
ctx.canvas->drawRect(draw_rect, ctx.paint);
ctx.canvas->restore();
ctx.canvas->restore();
Expand All @@ -3824,7 +3826,7 @@ TEST_F(DisplayListRendering, SaveLayerClippedContentStillFilters) {
layer_paint.setImageFilter(layer_filter);
ctx.canvas->Save();
ctx.canvas->ClipRect(kRenderBounds, ClipOp::kIntersect, false);
ctx.canvas->SaveLayer(&kTestBounds, &layer_paint);
ctx.canvas->SaveLayer(&kTestBounds2, &layer_paint);
ctx.canvas->DrawRect(draw_rect, ctx.paint);
ctx.canvas->Restore();
ctx.canvas->Restore();
Expand Down Expand Up @@ -3906,19 +3908,19 @@ TEST_F(DisplayListRendering, SaveLayerConsolidation) {
const std::string& desc1, const std::string& desc2,
const RenderEnvironment* env) {
DisplayListBuilder nested_builder;
nested_builder.SaveLayer(&kTestBounds, &paint1);
nested_builder.SaveLayer(&kTestBounds, &paint2);
nested_builder.SaveLayer(&kTestBounds2, &paint1);
nested_builder.SaveLayer(&kTestBounds2, &paint2);
render_content(nested_builder);
auto nested_results = env->getResult(nested_builder.Build());

DisplayListBuilder reverse_builder;
reverse_builder.SaveLayer(&kTestBounds, &paint2);
reverse_builder.SaveLayer(&kTestBounds, &paint1);
reverse_builder.SaveLayer(&kTestBounds2, &paint2);
reverse_builder.SaveLayer(&kTestBounds2, &paint1);
render_content(reverse_builder);
auto reverse_results = env->getResult(reverse_builder.Build());

DisplayListBuilder combined_builder;
combined_builder.SaveLayer(&kTestBounds, &paint_both);
combined_builder.SaveLayer(&kTestBounds2, &paint_both);
render_content(combined_builder);
auto combined_results = env->getResult(combined_builder.Build());

Expand Down Expand Up @@ -4056,7 +4058,7 @@ TEST_F(DisplayListRendering, MatrixColorFilterModifyTransparencyCheck) {
builder2.Translate(kTestCenter.fX, kTestCenter.fY);
builder2.Rotate(45);
builder2.Translate(-kTestCenter.fX, -kTestCenter.fY);
builder2.SaveLayer(&kTestBounds, &filter_save_paint);
builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
builder2.DrawRect(kRenderBounds, paint);
builder2.Restore();
auto display_list2 = builder2.Build();
Expand Down Expand Up @@ -4115,17 +4117,17 @@ TEST_F(DisplayListRendering, MatrixColorFilterOpacityCommuteCheck) {
DlPaint filter_save_paint = DlPaint().setColorFilter(filter);

DisplayListBuilder builder1;
builder1.SaveLayer(&kTestBounds, &opacity_save_paint);
builder1.SaveLayer(&kTestBounds, &filter_save_paint);
builder1.SaveLayer(&kTestBounds2, &opacity_save_paint);
builder1.SaveLayer(&kTestBounds2, &filter_save_paint);
// builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
builder1.DrawRect(kRenderBounds, paint);
builder1.Restore();
builder1.Restore();
auto display_list1 = builder1.Build();

DisplayListBuilder builder2;
builder2.SaveLayer(&kTestBounds, &filter_save_paint);
builder2.SaveLayer(&kTestBounds, &opacity_save_paint);
builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
builder2.SaveLayer(&kTestBounds2, &opacity_save_paint);
// builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
builder2.DrawRect(kRenderBounds, paint);
builder2.Restore();
Expand Down Expand Up @@ -4232,7 +4234,7 @@ TEST_F(DisplayListRendering, BlendColorFilterModifyTransparencyCheck) {
builder2.Translate(kTestCenter.fX, kTestCenter.fY);
builder2.Rotate(45);
builder2.Translate(-kTestCenter.fX, -kTestCenter.fY);
builder2.SaveLayer(&kTestBounds, &filter_save_paint);
builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
builder2.DrawRect(kRenderBounds, paint);
builder2.Restore();
auto display_list2 = builder2.Build();
Expand Down Expand Up @@ -4284,17 +4286,17 @@ TEST_F(DisplayListRendering, BlendColorFilterOpacityCommuteCheck) {
DlPaint filter_save_paint = DlPaint().setColorFilter(&filter);

DisplayListBuilder builder1;
builder1.SaveLayer(&kTestBounds, &opacity_save_paint);
builder1.SaveLayer(&kTestBounds, &filter_save_paint);
builder1.SaveLayer(&kTestBounds2, &opacity_save_paint);
builder1.SaveLayer(&kTestBounds2, &filter_save_paint);
// builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
builder1.DrawRect(kRenderBounds, paint);
builder1.Restore();
builder1.Restore();
auto display_list1 = builder1.Build();

DisplayListBuilder builder2;
builder2.SaveLayer(&kTestBounds, &filter_save_paint);
builder2.SaveLayer(&kTestBounds, &opacity_save_paint);
builder2.SaveLayer(&kTestBounds2, &filter_save_paint);
builder2.SaveLayer(&kTestBounds2, &opacity_save_paint);
// builder1.DrawRect(kRenderBounds.makeOffset(20, 20), DlPaint());
builder2.DrawRect(kRenderBounds, paint);
builder2.Restore();
Expand Down
9 changes: 5 additions & 4 deletions flow/layers/performance_overlay_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ sk_sp<SkTextBlob> PerformanceOverlayLayer::MakeStatisticsText(
const std::string& label_prefix,
const std::string& font_path) {
SkFont font;
if (font_path != "") {
sk_sp<SkFontMgr> font_mgr = txt::GetDefaultFontManager();
font = SkFont(font_mgr->makeFromFile(font_path.c_str()));
sk_sp<SkFontMgr> font_mgr = txt::GetDefaultFontManager();
if (font_path == "") {
font = SkFont(font_mgr->matchFamilyStyle(nullptr, {}), 15);
} else {
font = SkFont(font_mgr->makeFromFile(font_path.c_str()), 15);
}
font.setSize(15);

double max_ms_per_frame = stopwatch.MaxDelta().ToMillisecondsF();
double average_ms_per_frame = stopwatch.AverageDelta().ToMillisecondsF();
Expand Down
1 change: 1 addition & 0 deletions impeller/entity/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ impeller_component("entity_unittests") {
":entity_test_helpers",
"../geometry:geometry_asserts",
"../playground:playground_test",
"//flutter/display_list/testing:display_list_testing",
"//flutter/impeller/typographer/backends/skia:typographer_skia_backend",
]
}
4 changes: 2 additions & 2 deletions impeller/entity/entity_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <utility>
#include <vector>

#include "flutter/display_list/testing/dl_test_snippets.h"
#include "fml/logging.h"
#include "gtest/gtest.h"
#include "impeller/core/texture_descriptor.h"
Expand Down Expand Up @@ -2175,8 +2176,7 @@ TEST_P(EntityTest, InheritOpacityTest) {

// Text contents can accept opacity if the text frames do not
// overlap
SkFont font;
font.setSize(30);
SkFont font = flutter::testing::CreateTestFontOfSize(30);
auto blob = SkTextBlob::MakeFromString("A", font);
auto frame = MakeTextFrameFromTextBlobSkia(blob);
auto lazy_glyph_atlas =
Expand Down
1 change: 1 addition & 0 deletions impeller/typographer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impeller_component("typographer_unittests") {
"../playground:playground_test",
"backends/skia:typographer_skia_backend",
"backends/stb:typographer_stb_backend",
"//flutter/display_list/testing:display_list_testing",
"//flutter/third_party/txt",
]
}
18 changes: 10 additions & 8 deletions impeller/typographer/typographer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/display_list/testing/dl_test_snippets.h"
#include "flutter/testing/testing.h"
#include "impeller/playground/playground_test.h"
#include "impeller/typographer/backends/skia/text_frame_skia.h"
#include "impeller/typographer/backends/skia/typographer_context_skia.h"
#include "impeller/typographer/lazy_glyph_atlas.h"
#include "impeller/typographer/rectangle_packer.h"
#include "third_party/skia/include/core/SkData.h"
#include "third_party/skia/include/core/SkFont.h"
#include "third_party/skia/include/core/SkFontMgr.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkTextBlob.h"
Expand Down Expand Up @@ -38,7 +40,7 @@ static std::shared_ptr<GlyphAtlas> CreateGlyphAtlas(
}

TEST_P(TypographerTest, CanConvertTextBlob) {
SkFont font;
SkFont font = flutter::testing::CreateTestFontOfSize(12);
auto blob = SkTextBlob::MakeFromString(
"the quick brown fox jumped over the lazy dog.", font);
ASSERT_TRUE(blob);
Expand All @@ -59,7 +61,7 @@ TEST_P(TypographerTest, CanCreateGlyphAtlas) {
auto context = TypographerContextSkia::Make();
auto atlas_context = context->CreateGlyphAtlasContext();
ASSERT_TRUE(context && context->IsValid());
SkFont sk_font;
SkFont sk_font = flutter::testing::CreateTestFontOfSize(12);
auto blob = SkTextBlob::MakeFromString("hello", sk_font);
ASSERT_TRUE(blob);
auto atlas = CreateGlyphAtlas(
Expand Down Expand Up @@ -97,7 +99,7 @@ TEST_P(TypographerTest, LazyAtlasTracksColor) {
ASSERT_TRUE(mapping);
sk_sp<SkFontMgr> font_mgr = txt::GetDefaultFontManager();
SkFont emoji_font(font_mgr->makeFromData(mapping), 50.0);
SkFont sk_font;
SkFont sk_font = flutter::testing::CreateTestFontOfSize(12);

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

SkFont sk_font;
SkFont sk_font = flutter::testing::CreateTestFontOfSize(12);
auto blob = SkTextBlob::MakeFromString(test_string, sk_font);
ASSERT_TRUE(blob);

Expand Down Expand Up @@ -214,7 +216,7 @@ TEST_P(TypographerTest, GlyphAtlasTextureIsRecycledIfUnchanged) {
auto context = TypographerContextSkia::Make();
auto atlas_context = context->CreateGlyphAtlasContext();
ASSERT_TRUE(context && context->IsValid());
SkFont sk_font;
SkFont sk_font = flutter::testing::CreateTestFontOfSize(12);
auto blob = SkTextBlob::MakeFromString("spooky 1", sk_font);
ASSERT_TRUE(blob);
auto atlas = CreateGlyphAtlas(
Expand Down Expand Up @@ -247,7 +249,7 @@ TEST_P(TypographerTest, GlyphAtlasTextureIsRecreatedIfTypeChanges) {
auto context = TypographerContextSkia::Make();
auto atlas_context = context->CreateGlyphAtlasContext();
ASSERT_TRUE(context && context->IsValid());
SkFont sk_font;
SkFont sk_font = flutter::testing::CreateTestFontOfSize(12);
auto blob = SkTextBlob::MakeFromString("spooky 1", sk_font);
ASSERT_TRUE(blob);
auto atlas = CreateGlyphAtlas(
Expand Down
2 changes: 2 additions & 0 deletions shell/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ if (enable_unittests) {
fixtures = [
"fixtures/shelltest_screenshot.png",
"fixtures/hello_loop_2.gif",
"//flutter/third_party/txt/third_party/fonts/Roboto-Regular.ttf",
]
}

Expand Down Expand Up @@ -322,6 +323,7 @@ if (enable_unittests) {
":shell_unittests_fixtures",
"//flutter/assets",
"//flutter/common/graphics",
"//flutter/display_list/testing:display_list_testing",
"//flutter/shell/common:base64",
"//flutter/shell/profiling:profiling_unittests",
"//flutter/shell/version",
Expand Down
6 changes: 4 additions & 2 deletions shell/common/dl_op_spy_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

#include "flutter/display_list/display_list.h"
#include "flutter/display_list/dl_builder.h"
#include "flutter/display_list/testing/dl_test_snippets.h"
#include "flutter/shell/common/dl_op_spy.h"
#include "flutter/testing/testing.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkFont.h"
#include "third_party/skia/include/core/SkRSXform.h"

namespace flutter {
Expand Down Expand Up @@ -545,7 +547,7 @@ TEST(DlOpSpy, DrawTextBlob) {
DisplayListBuilder builder;
DlPaint paint(DlColor::kBlack());
std::string string = "xx";
SkFont font;
SkFont font = CreateTestFontOfSize(12);
auto text_blob = SkTextBlob::MakeFromString(string.c_str(), font);
builder.DrawTextBlob(text_blob, 1, 1, paint);
sk_sp<DisplayList> dl = builder.Build();
Expand All @@ -557,7 +559,7 @@ TEST(DlOpSpy, DrawTextBlob) {
DisplayListBuilder builder;
DlPaint paint(DlColor::kTransparent());
std::string string = "xx";
SkFont font;
SkFont font = CreateTestFontOfSize(12);
auto text_blob = SkTextBlob::MakeFromString(string.c_str(), font);
builder.DrawTextBlob(text_blob, 1, 1, paint);
sk_sp<DisplayList> dl = builder.Build();
Expand Down
5 changes: 5 additions & 0 deletions shell/platform/fuchsia/flutter/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,11 @@ if (enable_unittests) {
"$root_gen_dir/flutter/shell/common/assets/shelltest_screenshot.png"
dest = "assets/shelltest_screenshot.png"
},
{
path = rebase_path(
"//flutter/third_party/txt/third_party/fonts/Roboto-Regular.ttf")
dest = "assets/Roboto-Regular.ttf"
},
]

libraries = vulkan_validation_libs
Expand Down
Loading