pencil2d / pencil

Pencil2D is an easy, intuitive tool to make 2D hand-drawn animations. Pencil2D is open source and cross-platform.
http://pencil2d.org
GNU General Public License v2.0
1.45k stars 272 forks source link

Canvas performance roadmap #1760

Open MrStevns opened 1 year ago

MrStevns commented 1 year ago

I'll use this issue for keeping tab on my ongoing work in improving painting performance.

The list of changes I have on my roadmap:

Note to self: The reason for the transformation misalignment is that the vector strokes can be remapped correctly when applying the stroke, where as the bitmap stroke has to be mapped to the correct coordinate system in order to place it correctly on the canvas. It's likely that we won't be able to align because of that.

chchwy commented 1 year ago

Hey @MrStevns thanks for this fabulous roadmap! This is what I have been thinking for years but still not able to finish.

Just a little reminder, please ensure that you run the profiler after you make changes. When working on performance things, programmers sometimes make assumptions about the bottleneck by just looking at code, but it may not have a significant impact on performance.

For the stroke painting mBufferImg issue, I was thinking to make a buffer image which the size is slightly bigger than the current viewable area of the canvas, to avoid the frequent image copy and allocations.

Anyway, I look forward to your improvements!

MrStevns commented 1 year ago

Just a little reminder, please ensure that you run the profiler after you make changes. When working on performance things, programmers sometimes make assumptions about the bottleneck by just looking at code, but it may not have a significant impact on performance.

So far i've been using the time profiler in Instruments for Mac OS, for discovering and verifying my changes, so that should be covered 😄 For more precise profiling it could make sense to gather some data using hayai (that was also used for the bucket tool performance PR). To avoid having these regressions, we could even include some tests in the project that compares previous and current results, so we are made aware of when we make changes that have major impact on performance.

For the stroke painting mBufferImg issue, I was thinking to make a buffer image which the size is slightly bigger than the current viewable area of the canvas, to avoid the frequent image copy and allocations.

I too considered making that change but having worked with a tiled surface via the mypaint branch i've been experimenting with, I think there are more possibilities going that way. This will also benefit our rasterized vector strokes. I already have a branch with it working and the results are promising, but it could still make sense to compare that against having a big BitmapImage which is pre-allocated.