nsherry4 / Peakaboo

XRF Analysis Software
https://peakaboo.org
GNU General Public License v3.0
24 stars 10 forks source link

Large maps slow to draw #135

Closed nsherry4 closed 5 years ago

nsherry4 commented 5 years ago

Maps on the order of 1000x1000 take several seconds to render. We can mitigate this issue with #133 but speeding up the actual drawing would help too, especially since larger maps seem to be becoming more common.

nsherry4 commented 5 years ago

Selection Masks turned out to be really slow because while they require a buffer (so that the pixels can be directly altered), the selection mask object was being discarded after every rendering, rather than saved like the ones to draw the actual maps. This issue is addressed in commit ec5dfb9527f3f5344c05e18ab27574254e074a43

nsherry4 commented 5 years ago

Selection Masks further don't draw anything now if there is no selection. Previously it would still compose a transparent selection layer onto the drawing when the selection was empty.

nsherry4 commented 5 years ago

GridPerspective getXYFromIndex was heavily used in Cyclops' MapPainter::transformDataForMap method. getXYFromIndex returned a Pair<Integer, Integer>, and every time one of these was constructed to return an x,y pair, it would incur a penalty from autoboxing the ints to Integers. Creating an IntPair class to act like a Pair<Integer, Integer> helped speed this method up drastically.

nsherry4 commented 5 years ago

Calculating the max intensity required summing all maps and taking the max. This was done every time the map was redrawn. MapFilteringController now caches the summed map to speed this process up.

nsherry4 commented 5 years ago

Performance of drawing large maps has now substantially improved. Unless there is a user request for even better performance, I'm going to consider this issue resolved.