On Oct 25, 2009, at 14:44, Matthias Arndt wrote:

I'm nearly convinced to look into the gradients tomorrow, although I'm afraid it won't result in a better performance: Empty the path, calculate the angle, create the rect (with rounded edges), apply the gradient and fill the path ... vs. three move to / line to ... I'll see.

It seems as likely as not that using gradients is going to be a performance drag too.

I'd suggest that you should *not* empty existing Bezier paths -- it's quite possible that creating a new NSBezierPath object is *much* faster than changing an existing one.

Better still, I'd suggest that you try to use the NSBezierPath class methods (in particular, +strokeLineFromPoint:toPoint:) instead of creating short-lived path objects, since those methods may have optimizations to draw without actually creating any path objects.

Besides all that, and besides jumping into OpenGL, you might need to consider some sort of caching mechanism to get the kind of performance you want. It may be better, for example, to keep a lot of pre- configured NSBezierPath objects around instead of creating them every time your view draws -- or to put all of your individual line segments with the same drawing characteristics (whether connected to each other or not) into a single semi-persistent path object -- or to cache a bitmap of the view contents that you can use for scrolling.

Etc.

I'm hoping you'll have noticed that all of the above consists of guesswork. A better answer is to do some initial profiling of your app with Instruments, to try to identify what's really causing the performance bottleneck. Then you can look for specific optimizations, or redesign some of your code, to tackle the true problem head on.


_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to