On 15/06/2011, at 10:30 PM, Wolfgang Kundrus wrote:

> We have to update a lot of small onscreen objects and performance is way 
> better, when we travers them outside the Cocoa view tree. If we would use 
> invalidating, we would have to go thru our complete view tree and check for 
> overlaps with the update rect.
> 

Does each object have its own view? If so, then that's definitely not a good 
idea. If not, then there really shouldn't be a problem  - checking for overlap 
with the update rect is a simple matter of a) invalidating the update rect(s) 
and b) at DRAW time, call [NSView needsToDrawRect:] to test for overlap. 
Invariably it is drawing that dominates performance for this type of scenario, 
so a simple YES/NO test of this type is well worthwhile and is very fast.

If you have, say < 1000 objects that need updating, a linear list of these will 
probably suffice on a modern machine. If you have more, a spatial hashing 
scheme such as BSP can give useful improvements, and NSView has the method 
-getRectsBeingDrawn:count: that can be used as an input to a spatial hash. I 
use this technique in DrawKit, and unless the objects are especially complex in 
what they draw, it's easy to achieve a refresh of many thousands of objects 
within 16mS (which equates to 60fps).

If you have found performance to be bad using Cocoa's drawing mechanism, I 
suggest you must have overlooked something or made a newbie error such as 1 
view per object, because in my experience it is adequate in terms of scheduling 
the updates and testing for objects needing to be drawn. Cocoa caps the 
framerate at 60fps anyway so you will never do better than that, but it sounds 
like you're way off base, so there's a long way to go before giving up on the 
standard mechanism.

--Graham



_______________________________________________

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