-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Impeller] Respect max supported texture size when allocating glyph atlas texture. #45992
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,10 +117,10 @@ static ISize OptimumAtlasSizeForFontGlyphPairs( | |
const std::vector<FontGlyphPair>& pairs, | ||
std::vector<Rect>& glyph_positions, | ||
const std::shared_ptr<GlyphAtlasContext>& atlas_context, | ||
GlyphAtlas::Type type) { | ||
GlyphAtlas::Type type, | ||
const ISize& max_texture_size) { | ||
static constexpr auto kMinAtlasSize = 8u; | ||
static constexpr auto kMinAlphaBitmapSize = 1024u; | ||
static constexpr auto kMaxAtlasSize = 4096u; | ||
|
||
TRACE_EVENT0("impeller", __FUNCTION__); | ||
|
||
|
@@ -147,8 +147,8 @@ static ISize OptimumAtlasSizeForFontGlyphPairs( | |
Allocation::NextPowerOfTwoSize(current_size.width + 1), | ||
Allocation::NextPowerOfTwoSize(current_size.height + 1)); | ||
} | ||
} while (current_size.width <= kMaxAtlasSize && | ||
current_size.height <= kMaxAtlasSize); | ||
} while (current_size.width <= max_texture_size.width && | ||
current_size.height <= max_texture_size.height); | ||
return ISize{0, 0}; | ||
} | ||
|
||
|
@@ -366,7 +366,7 @@ std::shared_ptr<GlyphAtlas> TypographerContextSkia::CreateGlyphAtlas( | |
|
||
// --------------------------------------------------------------------------- | ||
// Step 3a: Record the positions in the glyph atlas of the newly added | ||
// glyphs. | ||
// glyphs. | ||
// --------------------------------------------------------------------------- | ||
for (size_t i = 0, count = glyph_positions.size(); i < count; i++) { | ||
last_atlas->AddTypefaceGlyphPosition(new_glyphs[i], glyph_positions[i]); | ||
|
@@ -405,7 +405,12 @@ std::shared_ptr<GlyphAtlas> TypographerContextSkia::CreateGlyphAtlas( | |
} | ||
auto glyph_atlas = std::make_shared<GlyphAtlas>(type); | ||
auto atlas_size = OptimumAtlasSizeForFontGlyphPairs( | ||
font_glyph_pairs, glyph_positions, atlas_context, type); | ||
font_glyph_pairs, // | ||
glyph_positions, // | ||
atlas_context, // | ||
type, // | ||
context.GetResourceAllocator()->GetMaxTextureSizeSupported() // | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh nice, I didn't realize we had this yet. |
||
); | ||
|
||
atlas_context->UpdateGlyphAtlas(glyph_atlas, atlas_size); | ||
if (atlas_size.IsEmpty()) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add this change to the STB backend? It's similarly pinned to an arbitrary texture size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, my bad. Didn't notice this call to action. Filing a followup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #46010