Repository navigation
refactor: separate renderer initialization from resize - #164
Conversation
No changeset neededThis pull request is classified as no_release_impact: no published package |
commit: |
|
Size Reduced — -0.3 KB 132.1 KB unpacked |
7460265 to
e7f5b2b
Compare
There was a problem hiding this comment.
awesome job charles, looks good to me.
but i got one question, resize still drops the last frame and resets clay's arena, and opsBuf can move when the state size changes, so i'd guess replay entries get invalidated on resize anyway. is the plan that replay only survives across normal frames, and this pr just keeps the instance itself (caps, pointer shape) from being recreated?
It's a great question. The answer is that further up this PR stack, the unary state is split into two frames, |
e7f5b2b to
bfac0b7
Compare
What does this PR do?
Why?
The context of this is that I spiked out a caching techique where as part of the
ElementInforeturned for each element in aRenderResulit has not only the bounding box, but also areplayoperation:This
replayis an operation that is a drop in replacement for the list of ops that rendered the element in the first place. Internally, it is just a byte offset and length to operations in the last frame, so when tty sees it, it just copies those bytes directly from the last frame into the current one.It performed 25% better than the snapshotting mechanism, and it means that every element that gets replayed takes up only 2 bytes in the transfer buffer.
But, as a result it requires that we not destroy that information on a resize which currently re-initializes the entire native renderer.
What
Split this into
clayterm_init(), which initializes the instance once, andclayterm_resize(), which rebuilds cells, the output buffer, and Clay's arena while invalidating the old layout and diff state.Capabilities and the emitted pointer shape now stay on the native instance across resizes. Remove the JavaScript save/restore bookkeeping and the unused native pointer-shape accessors. Regression coverage checks growth, shrink, and capability changes interleaved with resizing.
Based on
mainafter #162 merged. This is an internal refactor preparing the renderer lifecycle for replay; no public API change or separate issue.Type of change
Checklist
deno task test: 29 suites, 387 steps)deno task fmtanddeno task fmt:check)Also verified the WASM build,
deno lint,deno task verify, andgit diff --check.AI-generated code disclosure