Draw grid and rulers only once

How can I draw a background grid only when resize or zoom, and draw the audio-signal or fft result over it with high frame rate. In my pure objectiveC app I could solve this with CALayer. Draw some layer (grid, ruler) only when resize, one layer for current time and other text informations in higher frame rate, and the audio signal as fast as possible.

My very old Application Sonifyer with CALayer. Video: Sonifyer, Sonification of Tohoku Earthquake

It sounds like you want a buffered background image (which would be the only way I can see to “draw only once”).
But I would advice against it, unless your background is very colourful and not made of simple geometries. Because you are trading drawing a few lines against a possibly expensive image copy (or even worse: scaling) function.
If you want to try it out, I would use a Component with your rulers and set Component::setBufferedToImage (true);. And then draw your fft or whatever as transparent component on top (setOpaque (false);).

Having said that, in OpenGL that might worthwhile, since as texture it is already on graphics memory, so this could boost things. But I have only little experience with openGL, maybe someone else wants to chime in.


Thanks Daniel.
I’ve done a test with component’s, which do a repaint with different time intervals.

The source code and a screenshot can be found here.
github juce_guitest01
I will now try to create a background component and a foreground component.