-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(core): 💡 skip paint for out of bounds widgets #677
base: master
Are you sure you want to change the base?
refactor(core): 💡 skip paint for out of bounds widgets #677
Conversation
26dc27a
to
0bd7f9c
Compare
0bd7f9c
to
2155e81
Compare
2155e81
to
275b96e
Compare
275b96e
to
67c3a3f
Compare
67c3a3f
to
2ea230c
Compare
Thanks a lot. In previous versions, we did have a paint bounds check. However, we decided to remove it because we were not adhering consistently to the rule of how a widget should handle painting overflow outside its parent at that time. We shouldn't completely skip a whole subtree if it doesn't intersect with the paint bounds. This is because we want some widgets to be able to show overflow outside their parent. Consider this example: @Stack {
@Text { anchor: Anchor::left(-100.) }
} In this case, the text is allowed to show outside the stack. I believe we should implement this optimization eventually, but we are still working on defining a stable rule for it. Currently, I suggest allowing a widget to paint overflow outside its parent if the parent is not a fixed container. You can refer to #676 for more details on hit testing. Alternatively, we could add a |
Makes sense. Not that I have any say in any of this, but I personally feel like painting outside the bounds should be an explicit opt-in for a widget. |
Certainly, but performing additional clip checks and clip painting may not be the most efficient solution in the end. I believe we should consider whether to conduct the paint boundary check after implementing a straightforward and user-friendly LazyChildren feature. This way, we can prevent unnecessary generation of offscreen widgets. |
Purpose of this Pull Request
Widgets shouldn't paint outside of their bounds, as such we can just skip painting anything, saving a lot of work
especially for large widget trees with a lot of widgets that are off-screen.
Additionally, since saving the painter state isn't entirely free, we can also skip doing that when we aren't painting anything.
Checklist Before Merging
Please ensure the following are completed before merging:
CHANGELOG.md
file.Breaking
section of theCHANGELOG.md
file.Additional Information
The bot will replace
#pr
inCHANGELOG.md
with your pull request number. If your branch is out of sync, usegit pull --rebase
to update it.If you're unsure about which branch to submit your Pull Request to, or when it will be released after being merged, please refer to our Release Guide.
If you're working on a widget and need help writing test cases, we have some macros that can assist you. Please refer to the Ribir Dev Helper documentation.