Re: NSBezierPath vs. NSImage
Re: NSBezierPath vs. NSImage
- Subject: Re: NSBezierPath vs. NSImage
- From: Alastair Houghton <email@hidden>
- Date: Fri, 11 Dec 2009 10:59:50 +0000
On 11 Dec 2009, at 10:35, Michael Abendroth wrote:
> Woah, thanks a lot, Alastair! The reason I asked was because e.g.
> NSTextFieldCell subclasses get drawn & redrawn quite a lot, so on
> slower systems this might have been a problem ...
If you were e.g. rendering something huge with an NSShadow set in the graphics context, it might be a problem, since the shadow drawing is an expensive operation. There are ways around that (caching the rendering yourself to an image, for instance).
Just to give an example of what is possible, at a reasonable speed, take a look at the pie chart in iPartition (excuse the blatant plug, but it's kind of pretty and a fairly complex piece of drawing):
<http://www.coriolis-systems.com/iPartition.php>
It's rendered using NSBezierPath; we use an NSShadow for the shadow behind it, but drawing that is too slow on slower machines so that gets cached to an NSImage. Quartz is more than fast enough to render the chart and the shadowed text in real time, and to update them as the user drags the slider. In this particular case we also render differently during a live resize (specifically, we draw the background by scaling the cached image, because re-rendering the shadow is too expensive and would make the resize jerky on slower machines). That's another useful trick, I might add, if you do find that drawing is too slow in some case.
Anyway, the thing to do is to draw what you want, and then *if* it's going too slowly there are various things you can do to speed it up (like caching any expensive rendering in an NSImage, doing reduced or simplified rendering during live resize and so on).
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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