Re: lockFocusIfCanDraw behavior in layer-backed mode
Re: lockFocusIfCanDraw behavior in layer-backed mode
- Subject: Re: lockFocusIfCanDraw behavior in layer-backed mode
- From: Richard Charles <email@hidden>
- Date: Mon, 17 Dec 2018 09:00:34 -0700
> On Dec 16, 2018, at 6:34 PM, Tor Arne Vestbø <email@hidden> wrote:
>
> 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).
Yes, the session does not go very deep. Here are some of my notes on the
subject which may or may not be helpful.
Generally speaking there are three ways to execute draw code. You can use a
timer-based mode where it will execute draw code at a regular interval in
synchronization with a display. You can use an event-based mode which will
trigger draw code whenever an event has occurred. Finally, you can explicitly
drive the draw code, perhaps in an open loop on a secondary thread at your own
frame rate.
My application uses the second approach. Draw code is triggered whenever an
event has occurred. However dynamic resources may be concurrently generated on
demand on a background thread. Also the main layer may be drawn using a texture
generated by a background thread. Concurrent drawing is coordinated with
setNeedsDisplay using a run loop observer on the main thread. When it is
necessary to display the layer, simply call setNeedsDisplay on the layer.
Lili Sang, Apple DTS Engineer, was helpful in providing insight. You may want
to submit a technical support incident on your particular use case.
--Richard Charles
_______________________________________________
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