boost speed of bucket in the pressence of selection by about 87% #1304
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.
This introduces two independent optimizations:
1.
lock_selection_rect
optimization:Stores existing selection rect as cache and forces
get_selection_rect
inSelectionMap
to use cache instead. use this to save time when the rect isn't meant to change between repeated calls (e.g see it's use in Bucket tool_flood_fill
). This causes roughly an 87% boost to the area fill algorithm2. area_fill compatible with selection size:
when segments were created in
_compute_segments_for_image
When we have selection, this ends up adding segments not necessary for calculation. As an optimization, i change it to
This dramatically decreases the fill time even further.
Benchmark of area_fill on a
30x30
selection in a646x646
canvasmaster
PR
Related optimization that tagged along.
draw_tool
anddraw_fill_gap
as well (this will be noticeable when drawing a line using Pencil on a 5000x5000 canvas in presence of selection).