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

Refactor the selection system to use an Image instead of a BitMap #710

Merged
merged 25 commits into from
Aug 8, 2022

Conversation

OverloadedOrama
Copy link
Member

@OverloadedOrama OverloadedOrama commented Jun 24, 2022

Requires Godot 3.5 and above. Builds will most likely fail because of this and this PR will not be merged until Godot 3.5-stable is released and Pixelorama's workflows start using it.

This PR replaces the BitMap that was used to store the selected state of the pixels with an LA8 Image. This massively improves performance, since we get rid of the slow bitmap-to-image conversion. Images were used anyway for the selection marching ants outline to be drawn, and for shaders to use them as masks.

I have also refactor the selection code by making a new SelectionMap class that extends Image, and moved some methods from Project.gd to the new class, therefore making the code cleaner and putting the methods to a more correct place.

A comparison of approximate common timings of full canvas selections using the Rectangular Selection tool, between the current and the new method.

WxH Rectangular Selection (current) Rectangular Selection (new)
512x512 px 274 ms 6 ms
1024x1024 px 1000 ms 23 ms
2048x2048 px 3927 ms 85 ms
4096x4096 px 15534 ms 170 ms

The Select by Color tool now uses a shader for faster results, and a color similarity option has been added, similar to the same color fill in the Bucket tool. The below approximate timings were tested on blank canvases. Tested on an AMD Ryzen 5 1600 CPU and a NVIDIA GTX 1060 6GB GPU, on openSUSE Tumbleweed.

WxH Select by Color (current) Select by Color (new with shader)
512x512 px 410 ms 40 ms
1024x1024 px 1602 ms 65 ms
2048x2048 px 6376 ms 112 ms
4096x4096 px 26360 ms 391 ms

@OverloadedOrama OverloadedOrama merged commit 41ccc70 into master Aug 8, 2022
@OverloadedOrama OverloadedOrama deleted the selection-images branch August 8, 2022 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant