On 11 Dec 2013, at 22:43, Greg Parker <gpar...@apple.com> wrote:

> On Dec 11, 2013, at 9:53 AM, Steve Sisak <sgs-li...@codewell.com> wrote:
>> Not to hijack the thread, but I'm just getting head into optimizing some 
>> code which displays live preview for a number of JPEG streams simultaneously.
>> 
>> Most implementations I've tried result in being CPU bound in JPEG code on 
>> the main thread with the 7 other cores idle.
>> 
>> I've tried variants of NSImageView, CGImage and CIImage and all that's 
>> needed to render them on alternate threads but Cocoa appears to so good at 
>> delaying evaluation as long as possible that it seems to end up calling the 
>> JPEG decoder synchronously from -drawRect of whatever view subclass I've 
>> chosen on the main thread.
> 
> Simple attempt: when you get the JPEG, create a CGBitmapContext on a 
> background thread and draw the JPEG into it. Then use the CGBitmapContext to 
> draw on the main thread.

I think I must have missed something, because when drawing from the context 
created using CGBitmapContext don't you have to create a CGImage from the 
bitmap first and then draw that. Plus didn't part of the previous discussion in 
this thread suggest that you can't get the details of the window context that 
you'll be drawing into so that the image will have to be drawn again rather 
than just a bunch of memory copies. See Graham Cox's e-mail 9 December at 19:02 
(GMT). So that's a jpeg decompress and draw, the CGImage creation, and then a 
draw into a context that you don't know what it is. I haven't profiled this but 
it doesn't seem efficient though the main thread might be a little more 
responsive.

Kevin






_______________________________________________

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