Use -display INSTEAD of -setNeedsDisplay: was Re: is [uiObject display] necessary?
Use -display INSTEAD of -setNeedsDisplay: was Re: is [uiObject display] necessary?
- Subject: Use -display INSTEAD of -setNeedsDisplay: was Re: is [uiObject display] necessary?
- From: "Erik M. Buck" <email@hidden>
- Date: Sun, 16 Dec 2001 21:24:46 -0600
Use -display INSTEAD of -setNeedsDisplay:
I need to humbly apologize to Norbert and the list as a whole. I was
completely wrong and Norbert was completely correct.
I hereby reverse my previous very insistent assertion that -setNeedsDisplay:
should be used in preference to -display whenever possible. The opposite is
actually true.
Use -display rather than -setNeedsDisplay: whenever possible.
Apple has completely broken all display optimization that used to exist in
Openstep variants. Norbert's excellent example proves without shadow of
doubt that using -display and doing your own context dependent display area
optimization is necessary due to Apple's evident failure to perform even the
tiniest optimization that is possible when -setNeedsDisplay: is used. In
fact, as Norbert demonstrated, Apple's implementation of window display is
always the WORST case when -setNeedsDisplay: is used and only sometimes the
worst case when -display is used.
I suppose in retrospect this is one reason why Cocoa app display performance
is so unimpressive in OS X.
Apple must fix several items of documentation ASAP:
http://developer.apple.com/techpubs/macosx/Cocoa/JavaTutorial/customview/Cre
ating_a__s_of_NSView.html
<Quote>
This indication is called invalidation. Invalidation marks an entire view or
a portion of a view as "invalid," thus requiring a redisplay. NSView defines
two methods for marking a view's image as invalid: setNeedsDisplay, which
invalidates the view's entire frame rectangle, and setNeedsDisplayInRect,
which invalidates a portion of the view.
You can also force an immediate redisplay of a view with the display and
displayRect methods, which are the counterparts to the methods mentioned
above. However, you should use these and related display... methods only
when necessary. Frequent forced displays can markedly degrade application
performance.
<End Quote>
The use of -setNeedsDisplay is incorrectly advised several times in the
following
http://developer.apple.com/techpubs/macosx/Cocoa/Reference/ApplicationKit/Ob
jC_classic/Classes/NSMatrix.html
I suspect that Apple's implementation of many classes including NSBox,
NSClipView, NSSplitView, and NSMatrix must be re-optimized to use -display
rather than -setNeedsDisplay: given the terrible performance induced
by -setNeedsDisplay:
(Don: I think we need to revise some writing...)
----- Original Message -----