NSView drawing optimization question
NSView drawing optimization question
- Subject: NSView drawing optimization question
- From: Matt Neuburg <email@hidden>
- Date: Mon, 09 Jul 2007 10:59:46 -0700
- Thread-topic: NSView drawing optimization question
My custom NSView background is updated very frequently (30 times a second;
I'm doing a kind of animation).
What really needs updating is a bunch of small rectangles, so I'm sending
each of those to a setNeedsDisplayInRect call. The result is that when my
drawRect comes around, I am passed a rect consisting of the union of the
areas needing updating.
That's good, but I can go further: I can cycle through all those areas
individually, using getRectsBeingDrawn, and draw them. There can be up to 18
of these.
I've tried both implementations and they both work very happily (and I
enjoyed watching the flashes in QuartzDebug confirming that I was doing what
I thought I was doing).
My question is: which is more "optimal"? Assuming this is happening 30 times
a second, is it "better" to redraw a single rectangle, which is sometimes
fairly small but might sometimes be nearly as large as the entire view, or
to redraw 18 small rectangles? (You can infer from the scare-quotes that I'm
not even sure what the goal should be.)
m.
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide - Second Edition!
http://www.amazon.com/gp/product/0596102119
Take Control of Word 2004, Tiger, and more -
http://www.takecontrolbooks.com/tiger-customizing.html
Subscribe to TidBITS! It's free and smart. http://www.tidbits.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