• 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
drawing efficiently
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

drawing efficiently


  • Subject: drawing efficiently
  • From: Oscar Bascara <email@hidden>
  • Date: Sun, 24 Mar 2002 19:48:45 -0800

When I need a view refreshed, I try to use setNeedsDisplayInRect: whenever possible rather than just setNeedsDisplay:. Animation can be noticeably more responsive, for example, when dragging an element in the view. Now my question is: What is the exact mechanism between setNeedsDisplayInRect: and drawRect:? In particular, if I call setNeedsDisplayInRect: for a number of rectangles (some overlapping, some even may turn out to be identical), how is drawRect: ultimately called? Is it called many times? Or is it called once? I'm thinking that drawRect: gets called once, with the union of all the "dirty" rectangles passed as the parameter (where the union is the smallest rectangle that contains all the rectangles). Here's the thing. I've been trying to speed up the rendering of a selection rectangle (formed by clicking in the view and dragging to select elements) by only calling setNeedsDisplayInRect: for the parts that need updating since when the rectangle gets large, the rendering can lag the mouse movement. The idea is that a large rectangle may only need updating in two very thin rectangles, a vertical strip and a horizontal strip. But the union of these is the large rectangle so it really doesn't speed up rendering. Is there a way get drawRect: to update the two thin rectangles individually?

Another question about drawing efficiently has to do with the use of factory methods. How efficient is it to alloc, init, and autorelease many of these temporary objects every time drawRect: is called, like with [NSColor blackColor] and the NSBezierPath objects? Or, is the bottlenecking in the actual rendering (stroke, fill, etc.) and time spent handling temporarily created objects not significant?

Oscar Bascara
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: drawing efficiently
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Problems running UNIX Apps in Cocoa GUI
  • Next by Date: miscellaneous questions
  • Previous by thread: trouble : on mapping of the keyboard
  • Next by thread: Re: drawing efficiently
  • Index(es):
    • Date
    • Thread