Re: is [uiObject display] necessary?
Re: is [uiObject display] necessary?
- Subject: Re: is [uiObject display] necessary?
- From: Norbert Heger <email@hidden>
- Date: Mon, 17 Dec 2001 02:15:47 +0100
Erik M. Buck <email@hidden> wrote:
>
What do we have to do to convince you that -setNeedsDisplay: is the method
>
best suited to updating the user interface ? Do we need to show you timing
>
and sequence diagrams or will it be enough that your applications are just
>
slower than the competitions ?
>
>
There is no mystery when views will be displayed. Any view marked with
>
setNeedsDisplay: will be displayed before the next user input (usually when
>
control is returned to the event loop) .... The primary difference between
>
calling -display and calling setNeedsDisplay: is that the Application Kit
>
can be much smarter about coalescing displays and minimizing the number of
>
changes to the current graphics context needed to display the content of a
>
window.
The current AppKit implementation of this "optimized" automatic display
update simply collects all -setNeedsDisplay: calls to calculate ONE
enclosing rectangle that covers all the views marked for display, then it
updates that whole rectangle. This will cause EVERY view inside that
rectangle to be redisplayed (instead of only those marked dirty), which can
result in very bad display performance under some circumstances. If you
update two views at the opposite corners of your window, the ENTIRE window
will be redisplayed!
Related to this, if you implement -windowDidUpdate: in your window delegate
in order to update a view at the bottom right window corner, moving the
mouse over the close/min/max traffic lights will also cause the whole window
to be redrawn. If the window contains some views that are expensive to draw
(e.g. NSTableViews with lots of visible rows and columns), you will notice a
significant delay in the update of the traffic lights.
I've prepared a simple example project to demonstrate these problems. It can
be downloaded from:
http://homepage.mac.com/noheger/DisplayPerformance.tgz
Best Regards, Norbert
_____________________________________________
Norbert Heger, Objective Development
http://www.obdev.at/