Current application is working so well i decided to start profiling it. It turns out i spend over 50% of the total CPU time redrawing the background image of my GUI. The background image is redrawed often, i guess, because of child components changing. This doesn't really seem ideal, so i would like to optimize it.
I've tried implementing the background image as a child component of the main gui (DrawableImage), as an image and drawing it in maingui::paint(), but nothing really changes. Here's a view of Instruments profiling it:
It seems to spend almost all of the time 'acquireing' the image, so i made sure the image doesn't share it's data (using duplicateIfShared) - it didn't help though. As we can see, the actual rendering takes litterally no time.
Is there any way to cache the rendering of the image and quickly copy it in a paint() call, instead of redrawing and rendering it constantly?