-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/engine
#41290Labels
c: performanceRelates to speed or footprint issues (see "perf:" labels)Relates to speed or footprint issues (see "perf:" labels)e: impellerImpeller rendering backend issues and features requestsImpeller rendering backend issues and features requests
Description
I profiled the wonderous app with impeller on c5cbb03b5e17d9f7fb91806f9072bd518ff48b6f and just scrolled through the main page.
The highest usage of cpu on the main thread was in the impeller::TextRendererContextSkia::CreateGlyphAtlas with respect to creating and destroying impeller::Font objects:
I propose the following changes to the data structure of the GlyphAtlas in order to eliminate all of this extra work:
proposal
We make FontGlyphPair's have a pointer to a Font so that copying and manipulating them does not require allocating new fonts. The old way of storing the data could have the same font copied thousands of times and each one has a shared_ptr.
before
namespace impeller {
struct FontGlyphPair {
Font font;
Glyph glyph;
};
class GlyphAtlas {
const Type type_;
std::shared_ptr<Texture> texture_;
std::unordered_map<FontGlyphPair,
Rect,
FontGlyphPair::Hash,
FontGlyphPair::Equal>
positions_;
};
static std::vector<FontGlyphPair> CollectUniqueFontGlyphPairs(
GlyphAtlas::Type type,
const TextRenderContext::FrameIterator& frame_iterator);
} //namespace impellerafter
namespace impeller {
struct FontGlyphPair {
const Font& font;
Glyph glyph;
};
struct FontGlyphPairs {
std::vector<Font> fonts;
std::vector<FontGlyphPairs> pairs;
}
class GlyphAtlas {
const Type type_;
std::shared_ptr<Texture> texture_;
std::vector<Font> fonts;
std::unordered_map<FontGlyphPair,
Rect,
FontGlyphPair::Hash,
FontGlyphPair::Equal>
positions_;
};
static FontGlyphPairs CollectUniqueFontGlyphPairs(
GlyphAtlas::Type type,
const TextRenderContext::FrameIterator& frame_iterator);
} //namespace impellerMetadata
Metadata
Assignees
Labels
c: performanceRelates to speed or footprint issues (see "perf:" labels)Relates to speed or footprint issues (see "perf:" labels)e: impellerImpeller rendering backend issues and features requestsImpeller rendering backend issues and features requests
