Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[impeller] use cullRect for drawAtlas coverage #35133

Merged
merged 3 commits into from
Aug 3, 2022

Conversation

jonahwilliams
Copy link
Member

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.

Copy link
Member

@bdero bdero left a 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.

@jonahwilliams
Copy link
Member Author

jonahwilliams commented Aug 3, 2022

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.

Do we need to protect against users providing arbitrarily large or infinite cull rects, or are limits enforced elsewhere?

@bdero
Copy link
Member

bdero commented Aug 3, 2022

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).

@bdero
Copy link
Member

bdero commented Aug 3, 2022

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.

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 3, 2022
@auto-submit auto-submit bot merged commit 1188a80 into flutter:main Aug 3, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 3, 2022
@jonahwilliams jonahwilliams deleted the draw_atlas_cull_rect branch August 3, 2022 21:32
betrevisan pushed a commit to betrevisan/engine that referenced this pull request Aug 5, 2022
emilyabest pushed a commit to emilyabest/engine that referenced this pull request Aug 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants