A cache for blurred text that re-uses these across frames. More...
#include <text_shadow_cache.h>
Classes | |
struct | TextShadowCacheKey |
A key to look up cached glyph textures. More... | |
Public Member Functions | |
TextShadowCache ()=default | |
~TextShadowCache ()=default | |
void | MarkFrameStart () |
Mark all glyph textures as unused this frame. More... | |
void | MarkFrameEnd () |
Remove all glyph textures that were not referenced at least once. More... | |
std::optional< Entity > | Lookup (const ContentContext &renderer, const Entity &entity, const std::shared_ptr< FilterContents > &contents, const TextShadowCacheKey &) |
Lookup the entity in the cache with the given filter/text contents, returning the new entity to render. More... | |
size_t | GetCacheSizeForTesting () const |
A cache for blurred text that re-uses these across frames.
Text shadows are generally stable, but expensive to compute as we use a full gaussian blur. This class caches these shadows by text blob identifier and holds them for at least one frame.
Additionally, there is an optimization for a single glyph (generally an Icon) that uses the content itself as a key.
If there was a cheaper method of text frame identity, or a per-glyph caching system this could be more efficient. As it exists, this mostly ameliorate severe performance degradation for glyph shadows but does not provide substantially better performance than Skia.
Definition at line 31 of file text_shadow_cache.h.
|
default |
|
default |
|
inline |
Definition at line 87 of file text_shadow_cache.h.
Referenced by impeller::testing::TEST_P().
std::optional< Entity > impeller::TextShadowCache::Lookup | ( | const ContentContext & | renderer, |
const Entity & | entity, | ||
const std::shared_ptr< FilterContents > & | contents, | ||
const TextShadowCacheKey & | text_key | ||
) |
Lookup the entity in the cache with the given filter/text contents, returning the new entity to render.
If the entity is not present, render and place in the cache.
Definition at line 41 of file text_shadow_cache.cc.
References impeller::Entity::Clone(), impeller::Entity::GetClipDepth(), impeller::Entity::GetCoverage(), impeller::ContentContext::GetRenderTargetCache(), impeller::Entity::GetTransform(), impeller::Matrix::Invert(), impeller::Entity::SetClipDepth(), and impeller::Entity::SetTransform().
void impeller::TextShadowCache::MarkFrameEnd | ( | ) |
Remove all glyph textures that were not referenced at least once.
Definition at line 36 of file text_shadow_cache.cc.
void impeller::TextShadowCache::MarkFrameStart | ( | ) |
Mark all glyph textures as unused this frame.
Definition at line 30 of file text_shadow_cache.cc.
Referenced by impeller::DisplayListToTexture(), and impeller::RenderToTarget().