Skip to content
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

perf(SprayBrush): enhance perf using new Group #7675

Merged
merged 9 commits into from
Apr 8, 2022

Conversation

ShaMan123
Copy link
Contributor

@ShaMan123 ShaMan123 commented Feb 13, 2022

This PR is an excellent demonstration of the power of the new Group and what can be unlocked using it
control
perf

Basically it reduces computation cost by iterating only once over the spray dots instead of a number of times.
It split up the dots into a number of groups that act as buffers to cut down iterations.
I need to get these buffers to render cache once they're maxed out and then performance will rise even more (splitting the rendering of the entire spray into smaller chunks and then at mouseup the create path is a group of groups that have already been cached so overhead will be minimal)

Will merge once v6! stabilizes

The buffering approach can/should be used by canvas for perf

If we wrap the result of the spray brush with another group we enhance perf even more in case it is used with clip path or in other cases that invalidate cache.

In action

You'll see that the dots double every second or so. That's the buffering group.
Notice that normally there is a massive frame drop on mouse up and here, even though the spray is huge there is no visible drop.

Zoom in on mouse up

spray1.mp4

@ShaMan123 ShaMan123 changed the base branch from v6! to master April 8, 2022 04:34
@ShaMan123 ShaMan123 closed this Apr 8, 2022
@ShaMan123 ShaMan123 reopened this Apr 8, 2022
@ShaMan123 ShaMan123 changed the base branch from master to v6! April 8, 2022 04:41
@ShaMan123 ShaMan123 merged commit a5a3bf5 into fabricjs:v6! Apr 8, 2022
@ShaMan123 ShaMan123 deleted the spray-brush-perf branch April 8, 2022 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant