Re: slow text drawing
Re: slow text drawing
- Subject: Re: slow text drawing
- From: Douglas Davidson <email@hidden>
- Date: Fri, 21 Feb 2003 14:47:50 -0800
On Friday, February 21, 2003, at 1:11 PM, Simon Olsberg wrote:
I am trying to look for ways to speed up text drawing for a
spreadsheet-type view in my application but do not seem to be getting
very good results.
I have abstracted the problem into the simple example below which draws
a series of random strings in a grid. If you size the window quite
large to about a grid of 20 x 40 or around 800 strings there is a
significant wait for the view to redraw - a couple of seconds.
I can't believe that this is the fastest that Cocoa can manage and
would appreciate any tips on how to speed things up. I have also tried
to use NSLayoutManager & NSTextStorage directly but this seems to do no
better.
Your example alters the strings every time the view is drawn, which
places you in the worst possible case--all of the text must be laid out
at every iteration. If this is really what you intend, it limits the
sort of optimizations you can use; one might be to use a monospaced
font, in particular Courier or Monaco.
If you expect some of your strings to remain the same from one drawing
iteration to the next, then you can employ some caching using
NSLayoutManager. I would suggest placing each string on a separate
line in the text storage, then using NSLayoutManager to draw them,
somewhat along the lines of the CircleView example.
There are other optimizations that can be used--check the archives for
some of my previous posts on this topic--but these are the ones I would
probably try first in this case.
Douglas Davidson
_______________________________________________
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.