Re: Fastest way to push strings to the screen in an NSView?
Re: Fastest way to push strings to the screen in an NSView?
- Subject: Re: Fastest way to push strings to the screen in an NSView?
- From: Robbie Haertel <email@hidden>
- Date: Wed, 17 Nov 2004 19:45:57 -0700
I got that quote straight from Apple's documentation. I agree that
NSLayoutManager should only be used if it is really worth it, but he
asked why he might be having problems so I'm assuming there's a
possibility that he thinks it is worth it or he wouldn't of asked. I
also agree that things aren't always optimized for all cases, but hey,
he wanted to know why he was having a bottleneck and I offered an
answer :)!
I do believe that NSLayoutManager also caches glyphs. So, even if the
same letter and attribute (I believe he said his attributes are always
the same) are reused more than once (versus say entire strings that
are the same), there should still be an increase in performance. The
amount of the increase will depend on the amount of redudancy, in this
case I imagine certain letters will be used with very high frequency
(the vowels, t, n, etc.)
Could be wrong, though :)
Robbie
On Wed, 17 Nov 2004 18:39:09 -0800, Douglas Davidson <email@hidden> wrote:
>
> On Nov 17, 2004, at 6:24 PM, Robbie Haertel wrote:
>
> > The drawAtPoint: and drawInRect: methods are designed for drawing
> > small amounts of text or text that must be drawn rarely. They create
> > and dispose of various supporting text objects every time you call
> > them. To draw strings repeatedly, it is more efficient to use
> > NSLayoutManager, as described in "Drawing Strings".
>
> This isn't necessarily always the case; the drawAtPoint: and
> drawInRect: methods have been optimized for certain common cases, and
> continue to be further optimized with each new release. However, they
> can be called with arbitrary attributed strings--anything from "Hello,
> world" to a novel--and they certainly cannot be optimized for all
> cases; in the general case the use of an NSLayoutManager to retain
> layout information is definitely faster when the same string is drawn
> more than once. I would recommend moving to the use of a layout
> manager only if testing shows that the string drawing methods are a
> bottleneck.
>
> Douglas Davidson
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden