Re: Speed up drawing of View with multiple NSBezierPaths
Re: Speed up drawing of View with multiple NSBezierPaths
- Subject: Re: Speed up drawing of View with multiple NSBezierPaths
- From: publiclook <email@hidden>
- Date: Sun, 6 Jul 2003 21:39:58 -0400
On Sunday, July 6, 2003, at 09:09 PM, Chuck Soper wrote:
At 12:13 PM -0700 7/6/03, Henry McGilton wrote:
Depending on your application could you just reduce the number of
NSBezierPaths. For example, if you're drawing a thousand rectangles
with a thousand NSBezierPaths you should be able to draw a thousand
rectangles with one NSBezierPath. Yet, all of the rectangles will
need to have the same attributes (line width, color, etc.).
Not quite true. Check out the AppKit function
NSRectFillListWithColors and
NSRectFillListWithColorsUsingOperation (this second one for the
benefit of those who will not scroll down half a page)
What was "Not quite true" about my statement? Isn't appending a
thousand rectangles to a single path (using appendBezierPathWithRect)
significantly faster than using a thousand paths each with a single
rectangle? The original question was about general optimization not
rectangles.
I don't know about the argument you are having with Mr. McGilton, but
adding 1000 rectangles to a single NSBezierPath is probably the SLOWEST
way to draw a 1000 rectangles using Cocoa. NSBezierPath and Quartz end
up using a N squared algorithm or O of 1000000 to determine if any
rectangles overlap so that antialiasing and transparency can be handled
correctly.
"Cocoa Programming" contains a length discussion of how to efficiently
draw points and rectangles. I just checked and Chapter 13 includes a
sample showing different ways to draw thousands of points (and
rectangles) and times them. The sample source code is available at
www.cocoaprogramming.net. Quartz is wonderful for high quality 2D
rendering (it's the best available) but is is dog slow and near useless
for quick and dirty "as fast as you can" drawing. Ultimately, you must
use OpenGL if you want fast drawing on Mac OS X.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.