David, Le 25 janv. 2010 à 21:39, David Duncan a écrit :
> If you want to draw to a layer on a separate thread, you need to run the > runloop on that thread, as Core Animation is pretty highly dependent on the > run loop operating. If you call -setNeedsDisplay on a thread where you never > run the runloop, then it is likely that the layer's -display method will not > be called until the thread terminates, which is likely your issue. I've done that (I had to swallow all the doc, that was a headache ;)), but to no avail. Let's say I have a ScrollLayer with 9 underlying tiles (CALayer). Each tile has a delegate to provide contents via DrawLayer:inContext:. At init time, these delegates create a linked object that spawns a thread that runs its run loop (I end up therefore with 9 threads). When DrawLayer:inContext: is called, the delegates initializes the CGContextRef variable and sends a message to the run loop of the corresponding thread, starting the refresh code. I set NSLog so I know the drawing function is called. At best, I get a transitory partial display that vanishes at once. At worse, it crashes in aa_render (), called by CGStrokePath – I had to put a global lock to avoid this. If I understand the docs correctly – despite not being a native English speaker – there is one graphic context per thread, so, instead of passing the CGContextRef to the drawing thread, which obviously crashes unless a lock is set, shall I spawn a new thread that will create the CAScrollLayer and its sublayers? If yes, is there somehow a way to refresh the tiles concurrently? Somehow, I think that one cannot return immediately from DrawLayer:InContext: and refresh the layer in background. Everything has to be in place since the recaching takes place immediately after. Is that correct? Thanks, Vincent_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com