Re: CALayer -drawInContext and GCD
Re: CALayer -drawInContext and GCD
- Subject: Re: CALayer -drawInContext and GCD
- From: Chris Parker <email@hidden>
- Date: Thu, 02 Sep 2010 14:26:46 -0700
Hi Vincent,
On 2 Sep 2010, at 11:29 AM, vincent habchi wrote:
> I promise I did not plan to start an Apple internal quarrel! ;)
I don't think there's any real quarrel here; David and I are looking at this from two distinct points of view. :)
The docs for +[CATransaction flush] make the statement that you shouldn't call it in the general main run loop case, but you should call it yourself if you have no run loop in place.
In your case:
>>>> dispatch_async(queue, ^{
>>>> [layer display];
>>>> [CATransaction flush];
>>>> }
As David says, this is fine if you own and control the dispatch queue yourself and thus you know you're the only one setting up transactions on that queue.
In the above code, if 'queue' were the main queue, you'd likely be interfering with whatever the AppKit or UIKit might have in flight. Typical symptoms might include animations happening "early" or out of order from when you expect, or starting from odd locations.
If you're going to be doing a high transaction rate, you probably don't want to be calling +[CATransaction flush] after every one of them. You'll likely want to simulate what the run loop implementations do and fire it off after a preset number, or after a group of related displays/animations.
.chris
_______________________________________________
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