Re: Threaded drawing
Re: Threaded drawing
- Subject: Re: Threaded drawing
- From: Graham Cox <email@hidden>
- Date: Wed, 11 Dec 2013 11:20:54 +0100
On 10 Dec 2013, at 7:39 pm, Kyle Sluder <email@hidden> wrote:
>> but more directly, by using CATiledLayer you don't have to handle the tiling and threading yourself, and it avoids the final blit of your buffer into the view because you're (presumably) drawing directly into the layer backing.
>
> Yup, these two points are exactly why I suggested it.
Well, looks like we have a winner :)
Thanks to all that suggested CATiledLayer, I guess I shouldn’t be surprised, but it does actually work, and as well as performing excellently is very easy to set up as well. Seems to do the job without any kinks in the road - just set it as the view’s layer and away it goes.
The documentation is sparse though, I’m not quite sure what I should be using for -levelsOfDetail and -levelsOfDetailBias. It’s clear I do need to set these to something other than their defaults to get the behaviour I need, which is not to pixelize my vector drawing as I zoom in. The defaults do show pixelization.
My understanding is that -levelsOfDetail pertains to zooming OUT, and how many images get cached. So I have a fairly small number here, as zooming out isn’t a huge deal. -levelsOfDetailBias*, on the other hand, appears to pertain to zooming IN, and at what point the content is redrawn at a higher resolution. Since I need to attain up to 250x zoom, I’ve set this to 8, as each level is double the res of the last one, and 2^8 is 256. That’s my somewhat limited understanding, not particularly well-informed by the docs, but appears to work by experimentation. If anyone knows more than this, I’d love to know if I’m off-track.
*who comes up with these names? Are they self-describing?
Performance wise, It’s very hard to come up with a number as to whether this is showing any benefit in my test case (which isn’t very ‘heavy’ on drawing). Instruments shows a very different profile, with no one stack really dominating, which I suppose is good. The CPU Usage graph also shows considerably less overall work being done with no peaks hitting the max level. But the overall milliseconds appears to be very slightly more than straight drawing in the test case. *Shrugs*, I guess I have to throw it at my ‘heavy’ drawing and just see if it is noticeably better.
—Graham
_______________________________________________
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