• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Drawing Invalidation Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Drawing Invalidation Question
  • Next by Date: Re: +[NSColor highlightColor] returns white instead of actual color
  • Previous by thread: Re: Drawing Invalidation Question
  • Next by thread: Re: Drawing Invalidation Question
  • Index(es):
    • Date
    • Thread