-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
Flood fill issue #639
Comments
I have attempted to implement the floodfill routine from the Allegro library (https://www1.udel.edu/CIS/software/dist/allegro-4.2.1/src/flood.c). I can provide a PR, but I'm not 100% confident I tested everything. Let me know if you are interested anyway, and if anyone can guide me making sure it's properly tested. Some approximate common timings for flood fill of an entire picture on my machine for the different implementations follow. The columns labeled
It's probably not a game changer. It's likely that looking at my code someone more experienced with gdscript might find better ways to optimize it. |
@MatteoPiovanelli-Laser That sounds very interesting! Feel free to open a PR and we can review the code and test if it's working properly. |
In case of specific image formats, it's possible to replace repeated calls to For example, see the
Unfortunately that involves a steep memory cost, because it basically requires creating a duplicate of the image in memory. Once my original PR gets through, I'll also add this code if you are interested. |
I'm investigating a bit more the reason why this bucket fill is still so slow compared to implementations of the same algorithm in other languages. This screenshot is a snapshot from Godot's profiler showing the functions relevant to the bucket fill process, taken while filling a 1024x1024 image. Cutting down on the calls to
What I did was basically take advantage of the fact that the test See #672 for the code corresponding to these tests. |
I did a final refactor in #681 so it's easier to profile what's costing in terms of performances now. I have to say, I gave the code one more look and I couldn't see more corners to cut to make it faster right now. |
Pixelorama version:
0.9.1 stable
OS/device including version:
Ubuntu 21
Issue description:
Bucket/Flood fill is insanely slow
Steps to reproduce:
Use flood fill on a blank 4096x4096 image.
The text was updated successfully, but these errors were encountered: