Revamp draw_path_collection() API.
#30811
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR summary
closes #30547
This PR enhances the API of
draw_path_collection()for long term maintainability.Summary of Changes
Introduces the new
VectorizedGraphicsContextBaseclass, which is similar toGraphicsContextBase, but each attribute is vectorized. This serves as the dataclass through which all parameters are passed todraw_path_collection().Updated signature of
draw_path_collection()by making the parameters optional in order to support both the following:gcand all parameters presentvgcand none of the optional parametersUpdated signature of
_iter_collection()to takevgcinstead ofgcand added logic to cycle through all attributes.Changed
draw()inCollectionto use the newdraw_path_collection()API along with temporary fallback for third-party backends that use the old signature.Why is this change required?
It would become much simpler to add / vectorize new attributes in collections, without completely breaking third party backends. For example, it would greatly simplify #27937, that aims to vectorize the
hatchattribute.To-do
PR checklist