When inside of -[NSView drawRect:], what's the difference between- (void)drawRect:(NSRect)rect; { if ([self needsToDrawRect:someRect]) .... } - (void)drawRect:(NSRect)rect; { if (NSIntersectsRect(rect, someRect)) .... }
The NSView keeps a list of the actual subrectangles inside its bounds which are dirty, but it unions them all together into the single 'rect' parameter in -drawRect:, so 'rect' can be much larger than the strict minimum of what needs to be drawn.
You can get the actual list of dirty rects with - getRectsBeingDrawn:... or, alternately, if you have an expensive element you can check ahead of time if you need to draw it at all with -needsToDrawRect: -- even though the element might lie inside your bounds and inside 'rect', it still might not be touched by a dirty region.
-W _______________________________________________ Cocoa-dev mailing list ([email protected]) 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 [email protected]
