Re: needsDisplay and subviews
Re: needsDisplay and subviews
- Subject: Re: needsDisplay and subviews
- From: Quincey Morris <email@hidden>
- Date: Wed, 08 Mar 2017 17:49:39 -0800
On Mar 8, 2017, at 15:25 , Jeremy Hughes <email@hidden> wrote:
>
> My conclusion (for now) is that “needsDisplay” causes subviews to be redrawn - except when “wantsLayer” has been set to true.
>
> Does that make sense?
Sure. In some cases, such as when using layers, the result of your “draw(_:)” methods for custom subviews can be skipped as an optimization, since their output might have been cached earlier in a backing store.
“needDisplay” applies to the view(s) for which it is set. That means the “draw(_:)” method is called for that view (or those views). However, in a later part of the screen update process, this new drawing output must be composited with subview drawing output.
For subviews that didn’t have “needsDisplay” set, this compositing can be done with the existing backing store, if available. Otherwise, the subview “draw(_:)” methods have to be called too, simply to (re)create the subview contents. It can be difficult to predict which drawing paths will be taken.
One situation where subviews may already be cached is when you are using layers, since layers *are* drawing caches.
So, the correct answer to your original question, I think, is that if your model data has changed in such a way that the representation in custom views no longer reflects the data, then you should set “needsDisplay” on *every* custom subview that uses “draw(_:)”.
If you just need your changed view to be re-composited with the same subview contents as previously, then you don’t need to set “needsDisplay” on the subviews, just the parent view.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden