Reputation: 81
I'm working on an app made by a NSWindow which own a lot of custom subviews, that could be opaque or not. Whenever I call SetNeedsDisplay: or SetNeedsDisplayInRect: on a subview, the system calls the drawRect of each single subview starting from the content view of the parent NSWindows.
How can it be avoided? How can I redraw just the dirty subview (it should be the default behaviour)? Is there something that I'm missing maybe in subclassing the NSView? Or in setting the properties or the syle of the parent NSWindow?
Thanks
Upvotes: 0
Views: 361
Reputation: 81
Ok, I think I’ve figured it out. It seems that turning all the subviews into layer-backed views did the trick. And this is reasonable giving the way the layers are managed by the gpu and how the layer compositing is performed. But I still don't understand why, using the "classic" NSViews, no matter if they are opaque or not, siblings or children, overlapped or not , I cannot invalidate a single view without the system calls the re-drawing of the entire view hierarchy of the window
Upvotes: 0
Reputation: 3018
The that could be opaque or not is the trouble-some bit. Any non-opaque view triggers a redraw of the entire view hierarchy, because the window must restore that views background to a pristine state. Only views set to opaque may not require anything else below them to be redrawn. They might still trigger redraws "above" though, if the opaque view itself is partially covered by other views.
Upvotes: 0