drawing in a separate thread
drawing in a separate thread
- Subject: drawing in a separate thread
- From: Graham Cox <email@hidden>
- Date: Fri, 2 May 2008 17:13:01 +1000
I think I would like to try drawing my app's content in a secondary
thread to see if it will improve performance and teh snappy™. Docs on
this topic are a bit sketchy, and I've not been able to put my finger
on any sample code that is pertinent.
The docs mention bracketing all drawing between lockFocusIfCanDraw:
and unlockFocus, which sounds OK, but it's when I should be creating
my thread that has me puzzled. Should I spawn a new thread for each
update, or should I have a worker thread that just keeps going,
repeatedly doing any needed drawing? If the former, where should I
spawn the thread? If the latter, how will it know when something needs
to be drawn (and if nothing, can I make it sleep until there is)? Do I
need one thread per view, or can a single thread handled different
views of the same class (that do share the same drawing code otherwise).
I realise these questions must sound rather fundamental, but nothing
in the Cocoa Drawing Guide or Thread Guide really addresses them. I
have used threads before to perform tasks not involving drawing, so
I'm not completely unfamiliar with them, but I haven't tried drawing
on a secondary thread before.
Any pointers (to sample code, 3rd party code, or just tips) gratefully
received - thanks in advance.
G._______________________________________________
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