Unnecessary paintEntireComponent calls for covered Component

is there a way to avoid that a completly covered Component may lead to a call to paintEntireComponent?

For example if we take the juce demo plugin and put a Component (let’s name it fillComp) on top of the others, which only fills the complete parent area with black colour and setOpaque is true. Now if the infoLabel of the demo changes because of new values, it results in a call to paintEntireComponent even if it is covered by our fillComp. That makes the fillComp beeing repainted within the bounds of the infoLabel. This seems unnecessary because the fillComp on top of the others hasn’t changed.

What I described is not a big problem when the Components are that simple. But in my case I have a base Component with many children that are repainted in different intervalls (meters, fft displays, labels…). Now I need to open a new Component on top of these children, which itself has a lot of children. Everytime one of the covered children behind the new Component changes, paintEntireComponent is called and the new top Component and all of it’s children are repainted (or at least the parts that are over a changed covered Component). This is not necessary because the top Component itself hasn’t changed and therefore it should not be repainted and its children shouldn’t be repainted, too.
Since my covering top Component is quite a bit expensive regarding the painting and because it doesn’t need to be repainted that often, I need a way to avoid this repainting caused by Components in that back, that aren’t visible at all.

Any ideas how do this?
Thanks in advance.

The painting system is smart enough that if you repaint an opaque comp, none of its parents will be painted, but optimising it in the way you need here is a lot harder. To do it, every repaint call would need to check which part of its comp is obscured by others, which would involve going right to the top of the component tree and recursing down every single child, which could be very expensive, and in most cases will be pointless.

I’d suggest either making your background comps invisible when they’re covered up, or using setBufferedToImage to speed up the drawing of the overlaid one?

Damn, I was afraid that making every covered child invisible would be the only answer. So here we go, hoping that it’s not ending up in big mess.

Anyways, thanks for your quick reply.