Re: lockFocusIfCanDraw behavior in layer-backed mode
Re: lockFocusIfCanDraw behavior in layer-backed mode
- Subject: Re: lockFocusIfCanDraw behavior in layer-backed mode
- From: Tor Arne Vestbø <email@hidden>
- Date: Mon, 17 Dec 2018 01:34:42 +0000
- Thread-topic: lockFocusIfCanDraw behavior in layer-backed mode
> On 15 Dec 2018, at 18:49, Richard Charles <email@hidden> wrote:
>
>
>> On Dec 15, 2018, at 8:07 AM, Tor Arne Vestbø <email@hidden> wrote:
>>
>> Piggy-backing on this thread, what does lockFocusIfCanDraw actually do in
>> layer-backed mode?
>
> I have a layer-hosting view running under macOS 10.12.6 and lockFocus is
> called by the system frameworks.
Right. I was thinking more what happens when calling it outside of the display
cycle. The behavior I described was on Mojave (10.14.2)
>
> WWDC 2018 Session 209 states the following.
>
> "With our changes to layer backing, there's a few patterns I want to call out
> that aren't going to work in macOS 10.14 anymore. If you're using NSView
> lockFocus and unlockFocus, or trying to access the window's graphics contents
> directly, there's a better way of doing that. You should just subclass NSView
> and implement draw rect. Both of those methods have been kind of finicky for
> a while. So, you'll be saving yourself some trouble."
>
> Note that all of the NSView focus methods are now depreciated.
The session doesn’t go into what do if you want to draw synchronously outside
of the display cycle though. Is it enough to setNeedsDisplay and then call
[NSView displayIfNeeded] or [CALayer displayIfNeeded]? I guess the latter since
I don’t want AppKit to walk the view hierarchy and display other views (unless
it’s smart enough to treat a layer-backed view as not needing that behavior).
Cheers,
Tor Arne
_______________________________________________
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