Re: Branch: Drawing noise in Cocoa (preferably fast)
Re: Branch: Drawing noise in Cocoa (preferably fast)
- Subject: Re: Branch: Drawing noise in Cocoa (preferably fast)
- From: Seth Willits <email@hidden>
- Date: Sat, 18 Jun 2011 11:30:47 -0700
On Jun 17, 2011, at 7:29 PM, Ken Tozier wrote:
> Keying off Stephen's idea of drawing noise quickly, I came up with a solution that I can use for my own purposes. It seems like splitting up large image manipulations for execution on different processor cores could be a good introduction to GCD and blocks. I read the intro to GCD docs but am still a little in the dark about the whole topic. For example, say I'm using the following method to generate 10,000 x 10,000 or 50,000 x 50,000 pixel images, how would I go about "blockifying" it for GCD?
Use dispatch_apply to replace main loop. Use the iteration parameter to the block to determine which chunk of memory you should be writing to. The block does the noise generation of pixels starting at basePtr + (totalPixels / iterations) * iteration.
dispatch_apply(size_t iterations, dispatch_queue_t queue, void (^block)(size_t));
--
Seth Willits
_______________________________________________
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