4#include <unordered_map>
124 void RecordResult(
bool hit) {
if (hit) m_frameHits++;
else m_frameMisses++; }
151 void CaptureScope(Scope& s,
ITextSystem* textSystem);
153 std::unordered_map<ID, Scope> m_scopes;
158 uint64_t m_frame = 0;
159 uint64_t m_themeEpoch = 0;
160 uint32_t m_frameHits = 0;
161 uint32_t m_frameMisses = 0;
162 uint32_t m_frameDrawReplays = 0;
163 uint32_t m_frameDrawCaptures = 0;
164 bool m_drawCacheEnabled =
true;
167 static constexpr uint64_t kEvictAfterFrames = 240;
171 static constexpr uint64_t kSettleFrames = 2;
The frame's element tree.
Definition gui_element_storage.h:96
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:189
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:116
uint64_t ThemeEpoch() const
Global epoch that InvalidateAll() bumps.
Definition gui_ui_cache_subsystem.h:113
uint64_t CurrentFrame() const
Frame counter, advanced once per frame.
Definition gui_ui_cache_subsystem.h:111
void RecordDrawCapture()
a scope's draw (re)captured this frame
Definition gui_ui_cache_subsystem.h:126
void RecordDrawReplay()
a scope's draw blitted from cache
Definition gui_ui_cache_subsystem.h:125
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:131
uint32_t FrameDrawReplays() const
Definition gui_ui_cache_subsystem.h:129
Scope * Find(ID id)
The scope with id, or nullptr.
uint32_t FrameMisses() const
Definition gui_ui_cache_subsystem.h:128
static ID MemberOrNull(const Scope &s, ID id)
id when scope s contains it, else Invalid.
Definition gui_ui_cache_subsystem.h:134
bool IsDrawCacheEnabled() const
Definition gui_ui_cache_subsystem.h:117
void RecordResult(bool hit)
Counts a scope served from cache (hit) or rebuilt.
Definition gui_ui_cache_subsystem.h:124
uint32_t FrameHits() const
Definition gui_ui_cache_subsystem.h:127
void InvalidateAll()
Bumps the global epoch so every scope rebuilds (theme reload, display scale change).
Definition gui_ui_cache_subsystem.h:108
static bool IsMember(const Scope &s, ID id)
True when scope s contains id.
Definition gui_ui_cache_subsystem.h:139
uint32_t FrameDrawCaptures() const
Definition gui_ui_cache_subsystem.h:130
static constexpr float kDrawSettleSecs
Seconds for transitions to settle after a rebuild before capturing.
Definition gui_ui_cache_subsystem.h:119
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:126
static constexpr ElementRef Invalid()
Definition gui_element.h:134
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:406
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:74
ID snapCapture
Definition gui_ui_cache_subsystem.h:60
ID parentScopeID
enclosing cached scope (for invalidation propagation)
Definition gui_ui_cache_subsystem.h:76
bool nonCacheable
the subtree has a window; always rebuilds
Definition gui_ui_cache_subsystem.h:71
uint64_t signature
data signature of the last build
Definition gui_ui_cache_subsystem.h:62
std::vector< ID > textEditorIds
Text-editor element ids in the scope (recorded at capture).
Definition gui_ui_cache_subsystem.h:51
std::vector< ID > scopeIDs
Every element id in the subtree, sorted (membership tests by binary search).
Definition gui_ui_cache_subsystem.h:43
bool dirty
forced rebuild (Invalidate / size change / propagation)
Definition gui_ui_cache_subsystem.h:72
uint64_t lastUsedFrame
last frame BeginCached reached it, for eviction
Definition gui_ui_cache_subsystem.h:78
int2 drawCapturePos
Draw cache: the container's window-local position when its primitives were captured,...
Definition gui_ui_cache_subsystem.h:82
uint64_t themeEpoch
global epoch at capture; a newer one rebuilds
Definition gui_ui_cache_subsystem.h:77
int2 cachedSize
container inner size at capture
Definition gui_ui_cache_subsystem.h:64
bool usesPostLayout
The subtree uses AddPostLayout, so it needs the deferred-measurement settle.
Definition gui_ui_cache_subsystem.h:68
bool hasCachedSize
Definition gui_ui_cache_subsystem.h:66
std::vector< ID > claimedSwatches
Swatch color-style ids claimed while building the scope; kept alive on hit frames.
Definition gui_ui_cache_subsystem.h:53
bool missedThisFrame
rebuilt (not replayed) this frame
Definition gui_ui_cache_subsystem.h:73
bool captured
a snapshot exists
Definition gui_ui_cache_subsystem.h:70
ID snapActive
Definition gui_ui_cache_subsystem.h:58
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:57
IntRect cachedContentBounds
the built content's bounds, restored on clean frames
Definition gui_ui_cache_subsystem.h:65
std::vector< std::pair< ID, int2 > > scrollSnapshot
Scroll offsets of scroll containers in the scope at capture time.
Definition gui_ui_cache_subsystem.h:47
ID snapFocus
Definition gui_ui_cache_subsystem.h:59
ElementRef lastContainerRef
refreshed every frame in BeginCached
Definition gui_ui_cache_subsystem.h:63
Integer 2D vector.
Definition gui_base_types.h:18