3#include <unordered_map>
4#include <unordered_set>
122 void RecordResult(
bool hit) {
if (hit) m_frameHits++;
else m_frameMisses++; }
144 void CaptureScope(Scope& s,
ITextSystem* textSystem);
146 std::unordered_map<ID, Scope> m_scopes;
151 uint64_t m_frame = 0;
152 uint64_t m_themeEpoch = 0;
153 uint32_t m_frameHits = 0;
154 uint32_t m_frameMisses = 0;
155 uint32_t m_frameDrawReplays = 0;
156 uint32_t m_frameDrawCaptures = 0;
157 bool m_drawCacheEnabled =
true;
160 static constexpr uint64_t kEvictAfterFrames = 240;
164 static constexpr uint64_t kSettleFrames = 2;
The frame's element tree.
Definition gui_element_storage.h:100
Stage callbacks run in registration order (no priorities): if A must run before B,...
Definition gui_frame_pipeline.h:74
Owns the per-frame state objects and runs their BeginFrame / EndFrame in order.
Definition gui_state_manager.h:65
Text and icon registration, measurement, rendering and editing.
Definition gui_text_system.h:178
bool EvaluateHit(const Scope &s, uint64_t signature, const HitInput &input) const
True when scope s, built with data signature, can be served from cache this frame.
void SetDrawCacheEnabled(bool e)
When off, EvaluateHit always misses and every scope rebuilds (for A/B comparison).
Definition gui_ui_cache_subsystem.h:114
uint64_t ThemeEpoch() const
Global epoch that InvalidateAll() bumps.
Definition gui_ui_cache_subsystem.h:111
uint64_t CurrentFrame() const
Frame counter, advanced once per frame.
Definition gui_ui_cache_subsystem.h:109
void RecordDrawCapture()
a scope's draw (re)captured this frame
Definition gui_ui_cache_subsystem.h:124
void RecordDrawReplay()
a scope's draw blitted from cache
Definition gui_ui_cache_subsystem.h:123
Scope & GetOrCreate(ID id)
The scope with id, created on first use.
UICacheManager(FramePipeline &frame, ElementStorage &storage, GUIStateManager &stateManager)
size_t ScopeCount() const
Definition gui_ui_cache_subsystem.h:129
uint32_t FrameDrawReplays() const
Definition gui_ui_cache_subsystem.h:127
Scope * Find(ID id)
The scope with id, or nullptr.
uint32_t FrameMisses() const
Definition gui_ui_cache_subsystem.h:126
static ID MemberOrNull(const Scope &s, ID id)
id when scope s contains it, else Invalid.
Definition gui_ui_cache_subsystem.h:132
bool IsDrawCacheEnabled() const
Definition gui_ui_cache_subsystem.h:115
void RecordResult(bool hit)
Counts a scope served from cache (hit) or rebuilt.
Definition gui_ui_cache_subsystem.h:122
uint32_t FrameHits() const
Definition gui_ui_cache_subsystem.h:125
void InvalidateAll()
Bumps the global epoch so every scope rebuilds (theme reload, display scale change).
Definition gui_ui_cache_subsystem.h:106
uint32_t FrameDrawCaptures() const
Definition gui_ui_cache_subsystem.h:128
static constexpr float kDrawSettleSecs
Seconds for transitions to settle after a rebuild before capturing.
Definition gui_ui_cache_subsystem.h:117
void Invalidate(ID id)
Rebuilds scope id the next time it is reached, and its enclosing scopes (an outer hit skips inner con...
Definition gui_logging.h:24
An element's slot in ElementStorage: its depth and index within that depth.
Definition gui_element.h:127
static constexpr ElementRef Invalid()
Definition gui_element.h:135
Per-frame values plus references to long-lived managers, passed to every stage callback.
Definition gui_frame_pipeline.h:32
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
static constexpr ID Invalid()
The "no element" ID (all bits zero); also the default for optional ID parameters.
Definition gui_id.h:66
Definition gui_base_types.h:407
Only what's needed to decide whether a scope is still clean and to blit it; not the element tree.
Definition gui_ui_cache_subsystem.h:40
uint64_t firstCaptureFrame
frame of first capture (for the deferred-measurement settle)
Definition gui_ui_cache_subsystem.h:72
ID snapCapture
Definition gui_ui_cache_subsystem.h:58
ID parentScopeID
enclosing cached scope (for invalidation propagation)
Definition gui_ui_cache_subsystem.h:74
bool nonCacheable
the subtree has a window; always rebuilds
Definition gui_ui_cache_subsystem.h:69
uint64_t signature
data signature of the last build
Definition gui_ui_cache_subsystem.h:60
bool dirty
forced rebuild (Invalidate / size change / propagation)
Definition gui_ui_cache_subsystem.h:70
uint64_t lastUsedFrame
last frame BeginCached reached it, for eviction
Definition gui_ui_cache_subsystem.h:76
int2 drawCapturePos
Draw cache: the container's window-local position when its primitives were captured,...
Definition gui_ui_cache_subsystem.h:80
uint64_t themeEpoch
global epoch at capture; a newer one rebuilds
Definition gui_ui_cache_subsystem.h:75
std::unordered_set< ID > scopeIDs
every element id in the subtree (membership tests)
Definition gui_ui_cache_subsystem.h:41
int2 cachedSize
container inner size at capture
Definition gui_ui_cache_subsystem.h:62
bool usesPostLayout
The subtree uses AddPostLayout, so it needs the deferred-measurement settle.
Definition gui_ui_cache_subsystem.h:66
bool hasCachedSize
Definition gui_ui_cache_subsystem.h:64
std::vector< ID > claimedSwatches
Swatch color-style ids claimed while building the scope; kept alive on hit frames.
Definition gui_ui_cache_subsystem.h:51
bool missedThisFrame
rebuilt (not replayed) this frame
Definition gui_ui_cache_subsystem.h:71
bool captured
a snapshot exists
Definition gui_ui_cache_subsystem.h:68
ID snapActive
Definition gui_ui_cache_subsystem.h:56
std::unordered_set< ID > textEditorIds
Text-editor element ids in the scope (recorded at capture).
Definition gui_ui_cache_subsystem.h:49
ID snapHover
Hovered element at capture time when it is in the scope, else Invalid; the other snap* fields work th...
Definition gui_ui_cache_subsystem.h:55
IntRect cachedContentBounds
the built content's bounds, restored on clean frames
Definition gui_ui_cache_subsystem.h:63
std::vector< std::pair< ID, int2 > > scrollSnapshot
Scroll offsets of scroll containers in the scope at capture time.
Definition gui_ui_cache_subsystem.h:45
ID snapFocus
Definition gui_ui_cache_subsystem.h:57
ElementRef lastContainerRef
refreshed every frame in BeginCached
Definition gui_ui_cache_subsystem.h:61
Integer 2D vector.
Definition gui_base_types.h:19