• 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: NSView -drawRect optimization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSView -drawRect optimization


  • Subject: Re: NSView -drawRect optimization
  • From: Paul Bruneau <email@hidden>
  • Date: Thu, 14 Feb 2008 08:47:17 -0500

On Feb 12, 2008, at 5:39 PM, Greg Titus wrote:

Hi Paul,

Here are a couple of suggestions:

1) Create an OrderStepCell class, which represents the visible display of a single OrderStep. Have it have a pointer to the OrderStep and the rect that it draws in (i.e. it caches your OSRect value).

2) Only update that drawing rect for the cell when the OrderStep is moved. Or update them all when your scale changes (the pixelsPerSecond) or when enough time passes (1.0 / pixelsPerSecond = # of seconds before the display changes by a single pixel). Use an NSTimer for the latter.

3) When a cell moves, scale changes, or time passes, call - updateTrackingAreas. Implement -updateTrackingAreas to removeAllTooltips, and then create a tooltip for each order step. Cocoa will also call -updateTrackingAreas whenever the view's geometry changes such that tracking areas / cursor rects / tooltips need to be updated. See the NSView documentation.

4) As a result of these changes, you should be able to remove the computation of off-line time and the tooltip creation from your drawing loop. You also shouldn't need to constantly redisplay - only do it when your timer goes off or when order steps are being moved.

In short, most of your slowness here isn't really the drawing, it is that you are doing a lot of computation during drawing that ought to be done much less often.

Hope this helps!

Thank you, Greg, that is all Very Good Stuff™. I can see the wisdom of getting my computations out of drawRect. I will also go learn about -updateTrackingAreas.


_______________________________________________

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


References: 
 >NSView -drawRect optimization (From: Paul Bruneau <email@hidden>)
 >Re: NSView -drawRect optimization (From: Greg Titus <email@hidden>)

  • Prev by Date: Re: MD5 check sum of a file
  • Next by Date: Safari scrolling issue while capturing video
  • Previous by thread: Re: NSView -drawRect optimization
  • Next by thread: Re: NSView -drawRect optimization
  • Index(es):
    • Date
    • Thread