Buffering semitransparent layers

Sharing my silly discovery of the day, just in case it helps someone.

I have some 30 fps visualisations shown above some semitransparent layers that update much less often, so they’re setBufferedToImage. Given the current state of things (and OpenGL’s memory overhead), I’m using the software renderer. The performance was pretty awful, with 60% of CPU time spent on the UI.

It happens that blending ARGB images is dirt slow: 45% was spent in RenderingHelpers::EdgeTableFillers::ImageFill::copyRow, which uses memcpy for RGB, otherwise blends pixel by pixel. So having a fast layer on top of several semitransparent buffered components makes the buffering pointless. After grouping all background layers in a single buffered component, the UI CPU usage went from 60 to 44%, with the row copying from 45 to 23. The more you know!

2 Likes

setBufferedToImage() is often heralded as a quick get-better-performance solution - however in many cases it can make the performance worse.

It your Component takes less time to render than it would to draw an image of the same size, then setBufferedToImage (true) will make your rendering slower. This can be difficult to benchmark if the component in question is resizable, it may be faster to buffer it at smaller sizes, but slower at larger sizes.

4 Likes