perf(transform): translate-only fast path for global transforms#13
Merged
Conversation
Three changes covering the hot update path for x/y changes on simple nodes (no rotation/scale/mount): 1. CoreNode.update Global block: when both the node is simple and the parent's global is translate-only, the resulting global is also translate-only and collapses to two adds on tx/ty — bypassing the 6-field Matrix3d.copy + 2 mul-add translate. Tracked with a per-node _globalIsTranslate flag that propagates down the tree. RTT chains conservatively opt out. 2. updateLocalTransform simple path: localTransform is guaranteed to be identity-shape (ta=1, tb=0, tc=0, td=1), so only tx/ty need to change between frames. _localIsTranslate tracks whether the matrix is still in identity-shape so a non-simple -> simple transition correctly restores it. 3. updateBoundingRect: fix `||` -> `&&` on the axis-aligned-fast-path check. With `||`, a matrix with one zero shear component and the other non-zero (e.g. tb=0, tc=-0.5) wrongly took the diagonal fast path and produced incorrect bounds. Now matches calculateRenderCoords semantics. Adds setTranslate() helper to Matrix3d for the in-place tx/ty + mutation flag write used by both #1 and #2. Adds 12 unit tests covering simple-path reuse, non-simple -> simple transitions, translate-only propagation through grandchildren, fast-path opt-out when parent has rotation, and the bounding-rect axis check. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three fixes covering the hot update path for x/y changes on simple nodes (no rotation/scale/mount). Targets
CoreNode.updateandMatrix3d.updateGlobal block (🐛 [BUG] - CanvasTextRenderer tints color-emoji glyphs with node.color, crushing native emoji colors #1, big win): when both the node isisSimpleand the parent's global is translate-only, the resulting global is also translate-only and collapses to two adds ontx/ty. Bypasses the 6-fieldMatrix3d.copy+ 2 mul-addtranslate. Tracked with a per-node_globalIsTranslateflag that propagates down the tree. RTT chains conservatively opt out.updateLocalTransformsimple path ([fix] [sdf] Sdf text alpha double multiplication #2):localTransformis guaranteed identity-shape (ta=1, tb=0, tc=0, td=1), so onlytx/tyneed to change between frames — skips 4 redundant field writes._localIsTranslatetracks identity-shape so a non-simple → simple transition correctly restores the matrix.updateBoundingRect([fix] [subtexture] Update quad on subtexture node texture set #5, correctness bug): fix||→&&on the axis-aligned-fast-path check. With||, a matrix with one zero shear component and the other non-zero (e.g.tb=0, tc=-0.5) wrongly took the diagonal fast path and produced incorrect bounds. Now matchescalculateRenderCoordssemantics.Adds a
setTranslate(x, y)helper onMatrix3dfor the in-placetx/ty+ mutation-flag write used by both the local and global fast paths.Test plan
pnpm test— 120/120 passingpnpm build— cleansetTranslate, simple-path reuse, non-simple → simple transitions, translate-only propagation through grandchildren, fast-path opt-out, and the bounding-rect axis check🤖 Generated with Claude Code