Re: initializing images with view contents, then displaying those images instead of the view
Re: initializing images with view contents, then displaying those images instead of the view
- Subject: Re: initializing images with view contents, then displaying those images instead of the view
- From: Fritz Anderson <email@hidden>
- Date: Fri, 12 Oct 2007 16:44:03 -0500
On 12 Oct 2007, at 3:53 PM, David Harper wrote:
In an effort to improve efficiency in my current project, I have
decided to create NSImages to represent the contents of some of the
subviews in the application. This is a somewhat well-documented
process that I've read about in several different places.
These views contain dynamically positioned text, and when many of
them are on screen and thousands of individual characters are being
drawn using layoutmanagers etc, the application can gradually slow
down to unacceptable levels (~4 frames per second or lower). The
solution I've come up with so far works, except that the image being
drawn in the view does not exactly match the one which was copied
using the view's contents... Its width and height seem to vary by
1-2 pixels.
This may have something to do with the fact that the view frame
sometimes has non-integer width and height. I'm not sure if
NSImages are required to have integer NSSize values...
I am skeptical of fronting a live view of dynamic contents with an
image. I last did it in 1987. Computers have gotten faster since then;
a live representation should practically always be possible. Have you
used Shark to determine where your performance problem actually is?
I'd almost guarantee it would surprise you.
The Cocoa text stack is much faster when you divide the text among
separate storage and container objects, then draw the containers in a
stack.
I once did a terminal emulator that kept an indefinite scrollback
buffer. I had the advantage that only the bottom of the buffer (the
part comprising the terminal screen) ever changed. I put every couple
of thousand lines into a SectionRecord, which had its own
NSTextStorage and shared a custom NSLayoutManager. It knew how to draw
itself. It was owned by a TallTextView, which knew how to stack the
sections and handle mouse events.
See the Crescat project at
<http://www.manoverboard.org/~fritza/uoc/>
The Download link includes the GPL source. May help, may not.
— F
_______________________________________________
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