Re: Faster way to draw strings?
Re: Faster way to draw strings?
- Subject: Re: Faster way to draw strings?
- From: Dustin Mierau <email@hidden>
- Date: Thu, 24 Jan 2002 02:59:04 -0800
I don't think this is really possible in an NSTableView, from
what I understand, each cell in a table column uses the same
instance of a cell class to do the drawing. Your data source is
just queried whenever it needs a cells data, which it passes to
the cell class to display. I guess you could write your own cell
class that used a data class that held layout information.
Yea that makes sense.
Lates,
-dustin
On Thursday, January 24, 2002, at 02:27 AM, Marco Scheurer wrote:
Cool. How do you do this in an NSTableView? Scrolling my table
view is slow (10 columns x 15-20 visible alterning white and
blue rows out of several hundreds). Sampler showed that
scrolling spends most of the time in _NXDrawTextCell. ie in
NSLayoutManager and glyph stuff.
marco
Marco Scheurer
Sen:te, Lausanne, Switzerland http://www.sente.ch
On Wednesday, January 23, 2002, at 06:57 pm, Douglas Davidson wrote:
On Wednesday, January 23, 2002, at 05:03 AM, Stephan R.
Cleaves wrote:
I've been having difficulties with redraw speed in my
application and have narrowed the problem down to NSGraphics
drawAttributedString method. The problem is most noticeable
during resizing of the window which contains my custom view.
What I have done is turn off the drawing of the strings during
resize and i can achieve acceptable redraw speeds, then when
the live resize ends I turn back on the strings. This looks a
bit odd, but currently its the only solution I have. I have
over 100 unique strings being drawn in the view, and I do make
sure only to draw the requested region, but often that is the
entire view area during live resize. Is there a faster way to
draw strings? Other than using the font attribute, the over
head off the NSAttributedStrings is completely unnecessary for
my application. I Actually use NSMutableAttributedStrings and
pre-cache these, though doing so is not noticeably faster than
just using a single NSMutableAttributedString in drawRect and
changing its string reference string value.
There is a faster way to draw strings; as a matter of fact, we
gave an example of this at last year's WWDC. The problem with
the string drawing routines is that they generate glyphs for
the string and lay them out, then throw that information away
after the string has been drawn. All of that work has to be
redone when the string is drawn again. You can see
significant improvements by preserving this information
instead in your own NSLayoutManager. For ~100 strings you may
wish to use a single NSLayoutManager rather than a separate
NSLayoutManager per string; you can do this by concatenating
the individual strings into the NSTextStorage, separated by
hard line breaks, and maintaining an index of the subranges
they occupy. The exact procedure used would depend a bit on
what you know about your strings--for example, whether they
might contain line breaks within themselves, whether they are
to be allowed to wrap, etc. The CircleView example
demonstrates basic NSLayoutManager-based drawing, although in
that case the drawing is done glyph by glyph rather than by
ranges of glyphs, as you would probably wish to do it. If you
need help with this, you can probably get it on this list.
_______________________________________________
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.