-
Notifications
You must be signed in to change notification settings - Fork 6k
[impeller] use cullRect for drawAtlas coverage #35133
Conversation
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 will technically behave differently than Skia in subtle ways if the API is abused. For example: This will cause the cull rect to act like a clip rect if it's the only item in a SaveLayer, whereas Skia's cull rect won't have this effect.
Also, if the user sets the cull rect to be too large, this will cause Impeller to create filter and layer textures that are larger than is necessary, which is likely to be a worse outcome than if the user didn't attempt to optimize in the first place.
That being said, it would make the coverage computation go from linear to constant -- which could help some users out if a cull rect is computed that's roughly the right size.
Do we need to protect against users providing arbitrarily large or infinite cull rects, or are limits enforced elsewhere? |
We limit layer coverage to never go outside the screen. We don't have any limits like this in contents that produce textures though (like filters). |
The exception is that we have a mechanism to do this when rendering advanced blends using the blend filter. This is something I've been thinking about adding to the filter API overall (as I'm sure the need for it will arise). Can add it to the backlog of things for the next round of filter refactoring. |
Context >
On the cullRect argument to drawAtlas, the documentation states:
"The optional cullRect argument can provide an estimate of the bounds of the coordinates rendered by all components of the atlas to be compared against the clip to quickly reject the operation if it does not intersect."
And from my observed testing, as long as some part of the cull rect would be on screen - everything is drawn. Which makes sense, its not a clip rect. It sounds like a correct implementation for this for impeller would be to use the provided cullRect in place of the computed coverage, if provided.