Re: Drawing Invalidation Question
Re: Drawing Invalidation Question
- Subject: Re: Drawing Invalidation Question
- From: William Jon Shipley <email@hidden>
- Date: Sun, 1 Feb 2009 02:42:32 -0800
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@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