fix: stack clip regions so nested clips restore the parent rect#85
fix: stack clip regions so nested clips restore the parent rect#85natemoo-re wants to merge 5 commits into
Conversation
commit: |
|
Size Increased — +0.7 KB 111.0 KB unpacked |
4300a52 to
4b35dc4
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
|
@natemoo-re This is a great addition. I've made a few tweaks:
As for feedback, This seems like a very necessary addittion. The thing that I added to the spec that isn't currently present in the implementation is the behavior when we overflow the clip stack. Right now, it will silently corrupt every command that comes after the overflow. I've specified the behavior to add the constraint that even in overflow, the stack must be balanced, and also that in the event of overflow, it must be signaled back via the error channel that overflow occurred so that the front end can issue a warning. In practice, I have no idea what kind of UI that would in any way be usable would also have a clip stack of 16, but hey 🤷🏻 Lemme know what you think! |
Highly suspicious since this is an input parser benchmark, and the only code changes were to the render pipeline |
Clip state was a single rect, so closing an inner clip turned clipping off entirely and later siblings leaked past the outer bounds. Replace it with a fixed-depth stack: SCISSOR_START pushes intersect(parent, child) and SCISSOR_END pops, restoring the parent rect while the stack is non-empty. The active top mirrors into the existing clipx/clipy/clipw/cliph scalars, so setcell is unchanged. Fixes #77
b5a355d to
32deb34
Compare
|
Noting this up here: there is an upstream issue and draft PR for having Clay track the clip stack natively. We should track this and we can remove our own implementation when this lands upstream. |
Still needs to implement the clip stack symmetry in the spec
SCISSOR_STARTpushesintersect(parent, child),SCISSOR_ENDpops and restores the parent rect while the stack is non-emptyclipx/clipy/clipw/cliphscalars, sosetcellis untouched; depth-1 nesting reduces to the previous behavior; stack depth resets each frametest/clip.test.tsunderdescribe("clip")rather than a standalone filedeno testgreen (8 passed);deno lint+deno fmt --checkclean