Re: Getting the best frame rate for NSView drawing
Re: Getting the best frame rate for NSView drawing
- Subject: Re: Getting the best frame rate for NSView drawing
- From: Uli Kusterer <email@hidden>
- Date: Wed, 28 Mar 2012 10:58:57 +0200
On 28/03/2012, at 6:36 PM, Kenneth Baxter wrote:
> I am trying out some different ideas for animating portions of a view, but am having problems with performance.
On current hardware, the main bottlenecks in the drawing pipeline are two spots:
1) The CPU, i.e. drawing stuff using Quartz calls.
2) Transfer between RAM and GPU (graphics card) memory.
#1 is the classic, intuitive bottleneck that is usually solved by only drawing what you have to. Quartz is fast at what it does, but it does a lot (sub-pixel anti-aliasing etc.), so if you can avoid drawing at all, that's still better than drawing with really fast Quartz calls. (Graham Cox gave you great directions how to optimize that)
#2 arrived with GPU-accelerated graphics (Quartz Extreme), and usually means that whenever you draw in a view in a window, the whole layer's pixels need to be re-uploaded from the CPU/RAM where your drawing code happened to the graphics card. By default, each window gets its own layer. If you find yourself updating small subsections of a window, it is therefore often a good idea to turn on layer-backed views (CALayer/CGLayer), so only the pixels for that frequently-changing view are updated.
Moreover, moving a layer is inexpensive, because all it has to do is upload a single point to the graphics card telling it where to move the layer to. The pixel data stays identical. So if you're moving stuff around that otherwise doesn't change, the fastest way is generally to put that in its own layer (or, if you must, layer-backed view).
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.masters-of-the-void.com
_______________________________________________
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