Calling repaint() in timer callback in several components?


#1

Hi, is it something wrong in doing the folowing thing:

I’ve created an UI with (for example ) 2 knobs (filmstrip) and 2 VU meters (filmstrips)
Each VU meter have method setValue() to update its VU value.
Each VU meter have timer firing up 30 times per second and calling repaint();

So, once I enable my two VU meters, plugin UI becames “slow”. Knobs are moving slow and with a time lag, producing a lot of CPU usage spikes.
After disabling timers in VU meters, UI became fast and reponsive.
Currently, I’ve reimplemented it by starting single timer in main UI class, and in this timer callback I call repaint() of each VU meter.
Now it seems to be more or less ok.

And no, calling repaint for VU meter components does not lead to repainting of the whole plugin UI, I’ve checked it.

Juce version is somwhere from november 2009

On windows - all is perfect.


#2

If you have more than one timer calling repaint(), then depending on how the OS chooses to schedule its events, it could easily end up invoking separate repaint callbacks for each component, which would be much less efficient than having a single paint event that renders both components at once. So yes, you’re certainly better off doing all your repaint() calls at the same time, if possible.