Re: Optimizing NSRectFill
Re: Optimizing NSRectFill
- Subject: Re: Optimizing NSRectFill
- From: Bill Bumgarner <email@hidden>
- Date: Fri, 19 Dec 2008 10:30:28 -0800
On Dec 19, 2008, at 7:37 AM, Oleg Krupnov wrote:
I'm developing a custom view and noticed that drawRect is becoming
increasingly slow. The Shark has pointed out that the bottleneck is
the NSRectFill function (that calls CGContextFillRect under the hood)
that I use to draw the background of the view. I am disappointed that
such a basic operation could ever impair performance, but it does. It
looks like the bigger is the rectangle, the slower is performance.
I have read the list regarding this issue, but I haven't found any
solution. NSRectFillList, CGContextFillRect do not give any
performance gain.
My question is - is there a way to bypass the advanced path-related
stuff that causes the slow-down, and just get down to some kind of
fast drawing?
NSRectFill is really damned fast. Very very fast. In my
experience, it was the fastest way to draw points into a view (and
then cache the points into bitmap images for subsequent renderings).
See:
http://svn.red-bean.com/restedit/trunk/source/HopView.py
(It is in python, but it is Cocoa and uses the same APIs as you'd use
in ObjC).
That code is literally rendering 10,000 points -- 10,000 1x1 rects --
at a time in a few milliseconds. From what anyone could tell, it was
the fastest way to get individual points to the screen without going
to Open GL.
That makes me suspect that there is something else going on in your
drawing code. That it becomes increasingly slow indicates that you
are accumulating and then drawing more and more stuff over time?
Are you doing the calculations necessary to not draw the overlapping
bits? A little bit of math is always going to be faster than drawing
to the screen.
b.bum
_______________________________________________
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