The changes improve the performance quite a lot on my workstation and my laptop:
Instead of changing brightness factor and alpha of the texture images on per-pixel basis using JavaFX API, it's now set directly into the buffer of the image (using BufferExposingWritableImage similarly to the renderer). Individual pixel updates were too slow because on each update JavaFX notified the listeners that the image has changed.
These updates are now throttled, so the actual textures will be modified every 50ms.
For painting, keep track of the affected intervals and update the texture only within that interval.
There is also another version of the fix that performs texture updates on a background thread: https://github.com/saalfeldlab/paintera/tree/optimize-orthoslice-textures-background-thread
But the current state of that branch doesn't improve the performance much because of strict synchronization between the FX thread and the background thread. It should be possible to relax the synchronization, but it's more complicated and error-prone.
I'll merge and release the fixes in this PR, but I'll also keep the background thread version in case it turns out that the current fix is still slow in some circumstances.
Fixes #395
The changes improve the performance quite a lot on my workstation and my laptop:
BufferExposingWritableImage
similarly to the renderer). Individual pixel updates were too slow because on each update JavaFX notified the listeners that the image has changed.There is also another version of the fix that performs texture updates on a background thread: https://github.com/saalfeldlab/paintera/tree/optimize-orthoslice-textures-background-thread But the current state of that branch doesn't improve the performance much because of strict synchronization between the FX thread and the background thread. It should be possible to relax the synchronization, but it's more complicated and error-prone.
I'll merge and release the fixes in this PR, but I'll also keep the background thread version in case it turns out that the current fix is still slow in some circumstances.