Forgive me for asking questions about drawing I realise this topic has come up many times in the past but I’m just trying to wrap my head around some logic that I was unable to make sense off (yet).
When repaint() is called on a component why does it invalidate() it’s parent? I don’t mean why does it repaint it, that makes perfect sense if the component is not opaque.
For example, lets say the parent has a CachedComponentImage set, and I call repaint() on a child component, that child will then call internalRepaint() on it’s parent (which I’m sure is all well and good) but that then calls internalRepaintUnchecked() which will in turn invalidates the parent and forces it to repaint into the image before drawing the image to the screen.
Compare that scenario to if there are two siblings, with the new sibling now having the CachedComponentImage and having it’s size follow that of the parent. In this case the sibling would be asked to draw the image but it wouldn’t be marked invalidated.
The outcome of both scenarios ‘should’ visually be the same - but one is much more efficient than the other (assuming the paint routine is more expensive than drawing an image).
I intuitively thought that repaint() would only invalidate the component it was explicitly called on, I didn’t expect it to implicitly call it on parent components.
Even more surprisingly it seems that marking the original child component (that is having repaint called on it) as opaque also has no effect, again I intuitively thought marking it opaque would mean the parent component would not have to redraw into its image, actually I would have thought it didn’t even need to draw the image to screen at all!
I’m just wondering why this is, I suspect there is a good reason it is the way it is, maybe paintOverChildren() is an issue intertwined with this?
Thanks for your time.