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
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ TypographerContextSkia::CollectNewGlyphs(
std::vector<Rect> glyph_sizes;
size_t generation_id = atlas->GetAtlasGeneration();
for (const auto& frame : text_frames) {
if (frame->IsFrameComplete() &&
if (atlas->IsValid() && frame->IsFrameComplete() &&
frame->GetAtlasGeneration() == generation_id &&
!frame->GetFrameBounds(0).is_placeholder) {
continue;
Expand Down
43 changes: 43 additions & 0 deletions impeller/typographer/typographer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,49 @@ TEST_P(TypographerTest, TextFrameAtlasGenerationTracksState) {
EXPECT_EQ(frame->GetAtlasGeneration(), 2u);
}

TEST_P(TypographerTest, InvalidAtlasForcesRepopulation) {
SkFont font = flutter::testing::CreateTestFontOfSize(12);
auto blob = SkTextBlob::MakeFromString(
"the quick brown fox jumped over the lazy dog.", font);
ASSERT_TRUE(blob);
auto frame = MakeTextFrameFromTextBlobSkia(blob);

EXPECT_FALSE(frame->IsFrameComplete());

auto context = TypographerContextSkia::Make();
auto atlas_context =
context->CreateGlyphAtlasContext(GlyphAtlas::Type::kAlphaBitmap);
auto host_buffer = HostBuffer::Create(GetContext()->GetResourceAllocator(),
GetContext()->GetIdleWaiter());

auto atlas = CreateGlyphAtlas(*GetContext(), context.get(), *host_buffer,
GlyphAtlas::Type::kAlphaBitmap, /*scale=*/1.0f,
atlas_context, frame);

// The glyph position in the atlas was not known when this value
// was recorded. It is marked as a placeholder.
EXPECT_TRUE(frame->IsFrameComplete());
EXPECT_TRUE(frame->GetFrameBounds(0).is_placeholder);
if (GetBackend() == PlaygroundBackend::kOpenGLES) {
// OpenGLES must always increase the atlas backend if the texture grows.
EXPECT_EQ(frame->GetAtlasGeneration(), 1u);
} else {
EXPECT_EQ(frame->GetAtlasGeneration(), 0u);
}

auto second_context = TypographerContextSkia::Make();
auto second_atlas_context =
second_context->CreateGlyphAtlasContext(GlyphAtlas::Type::kAlphaBitmap);

EXPECT_FALSE(second_atlas_context->GetGlyphAtlas()->IsValid());

atlas = CreateGlyphAtlas(*GetContext(), second_context.get(), *host_buffer,
GlyphAtlas::Type::kAlphaBitmap, /*scale=*/1.0f,
second_atlas_context, frame);

EXPECT_TRUE(second_atlas_context->GetGlyphAtlas()->IsValid());
}

} // namespace testing
} // namespace impeller

Expand Down