On Aug 8, 2016, at 1:48 PM, Jens Alfke <j...@mooseyard.com> wrote:
> On Aug 8, 2016, at 12:46 PM, Aaron Tuller <mandelb...@mac.com 
> <mailto:mandelb...@mac.com>> wrote:
>> 
>> Search for NSImage here:
>> 
>> https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html#//apple_ref/doc/uid/10000057i-CH12-126728
>>  
>> <https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html#//apple_ref/doc/uid/10000057i-CH12-126728>
>> 
> 
> All it says about NSImage is: "One thread can create an NSImage object, draw 
> to the image buffer, and pass it off to the main thread for drawing. The 
> underlying image cache is shared among all threads.”
> 
> So it sounds like the problem isn’t the new NSImage but the existing one 
> being drawn into it. It might help to get the NSImage’s imageRep on the main 
> thread and then pass that to the background thread.
> 
> (I’ve got some similar code in one of my apps that creates NSImages on a 
> parallel dispatch queue and draws into them, but it only draws text, not any 
> pre-existing images. This code works fine even with dozens of tasks at a 
> time.)


Well it also says:

"The following classes and functions are generally not thread-safe. In most 
cases, you can use these classes from any thread as long as you use them from 
only one thread at a time."

and then lists NSImage. That's why a serial queue would probably work...or 
using something else like passing around an image rep as Jens suggests and 
drawing it to a local NSGraphicsContext backed by a NSBitmapImageRep.

-aaron
_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to