-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Implement paintsChild on RenderObjects that skip painting on their children #103768
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
Conversation
| @override | ||
| void applyPaintTransform(RenderBox child, Matrix4 transform) { | ||
| if (size.isEmpty || child.size.isEmpty) { | ||
| if (!paintsChild(child)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this remove accessibility transform as well? I remember widget like Opacity can still include in semantics when opacity in zero. The semantics transform is calculate using this method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is existing behavior for this widget. Yes, this means the a11y transform will be zeroed out. If we want to change that I think it should be done in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does that mean it was already broken before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nvm, this is RenderFittedBox, I thought it was RenderProxyBox
| /// supply a zeroed out matrix if it would not otherwise be able to determine | ||
| /// a valid matrix for the child and thus cannot meaningfully determine where | ||
| /// the child would paint. | ||
| bool paintsChild(covariant RenderObject child) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there an easy way to check whether the layout will be offscreen? or if there is a parent with clip that clipped the whole renderobject? it may be a good default implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
RenderOffstage and RenderOpacity, for example, return the same exact transform/clip whether they are going to paint their children or not.
Offstage does not really mean the same as offscreen - it's not as if you're getting laid out or painted in some coordinates that are outside of the current viewport. It's just that you will never get paint called after being laid out.
| /// one render object into coordinates local to another render object. | ||
| /// | ||
| /// Some RenderObjects will provide a zeroed out matrix in this method, | ||
| /// indicating that even though |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indicating that even though ....?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah. I got halfway through writing this and thought of what I should say in paintsChild and forgot to come back. Updated.
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a reasonable approach
goderbauer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not super-exited about adding another method to RenderObject, but I also don't see another approach for this, so reluctantly
LGTM.
chunhtai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
This pull request is not suitable for automatic merging in its current state.
|
|
I only see scuba chagnes that look expected and/or unrelated to this patch. |
#103638 was an alternative attempt at this, but doesn't work:
Adds an optimization to InkFeature so that it avoids painting entirely if something between the target and feature stops painting.
Part of the visibility_detector refactor.
@gspencergoog @chunhtai might find this interesting since I'm touching some code you last modified.