Is any-scaling or transformation involved, if yes, keep in mind that the boundaries could be on sub-pixel positions, which result in a mix of the background and foreground component on the boundary pixel positions.
also you may have a second redraw(dirty) region, on some other position, which on mac will be summarized to one big redraw region, which may intersects with areas which don’t have to be redrawed (you can use the JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS, to change this behavior)
I’m on retina. I don’t have anything else that those 2 components, and I have this behaviour whatever the child bounds, even if it has the same bounds as the parent.
standalone (example code is above, I tested it within a projucer generated gui app).
I don’t have much time to look further into that at the moment unfortunately.
But I already wanted to know if it was really not expected or if I was missing something.
So this is because in paintComponentAndChildren, clipObscuredRegions() is not called if dontClipGraphicsFlag is true.
As a consequence, if a component is setPaintingIsUnclipped(), it will always get repainted whenever its child is repainted, even if it’s unnecessary.
shouldn’t clipObscuredRegions() be called even if dontClipGraphicsFlag is true?
We’ll have a look, but it’s fairly low priority for us, and actually may turn out to just be a case which we choose not to optimise. To do a 100% perfect cull of all obscured components is an operation that scales very badly to large numbers of components, so the algorithm we use doesn’t attempt to traverse the entire tree, it just does enough to cover the common use-cases.
Sure, but the dontClipGraphics flag was never supposed to be used for components with children. The purpose of that flag is to avoid clipping components which just contain some simple graphics.
In the setPaintingIsUnclipped() documentation, it is written : Your component also can’t have any child components that may be placed beyond its bounds. So I assumed it could be called on components that have children (like a simple slider which has a label child).
We could simply add a numChildComponents condition (line 1969 in paintComponentAndChildren()):
if (flags.dontClipGraphicsFlag && getNumChildComponents() == 0)
Wondering why I get unnecessary repaints and realizing, its because I have set setPaintingIsUnclipped(true).
I think it would be good to document this better. In some of his talks, Jules recommends setting setPaintingIsUnclipped(true). Thats where I got the idea from.
So whats the general advice now? Use setPaintingIsUnclipped(true) if you can, but only on components , which have no children. Does that seem sound?