Re: Drawing strings at 20fps
Re: Drawing strings at 20fps
- Subject: Re: Drawing strings at 20fps
- From: John Stiles <email@hidden>
- Date: Thu, 22 Jul 2004 16:41:45 -0700
On Jul 22, 2004, at 2:24 PM, Douglas Davidson wrote:
>
On Jul 22, 2004, at 2:15 PM, John Stiles wrote:
>
>
> From personal experience, I've found that trying to draw text via
>
> drawGlyphs is not very fast, but drawing text into an NSImage and
>
then
>
> drawing that NSImage on-screen is super-fast (it rasterizes the text
>
> once and then essentially does CopyBits from then on). I had code
>
that
>
> needed to draw text several times a second; originally I tried saving
>
> the glyphs into an NSBezierPath, but that was just terrible
>
> performance-wise (literally an order of magnitude slower than QD or
>
> Win32 text). The NSImage technique was a lifesaver. The downside was
>
> that I needed a separate NSImage for each color of text (I was
>
drawing
>
> the same strings in varying colors) but no big deal; I looked at it
>
in
>
> MallocDebug and it wasn't using a huge amount of memory. The
>
> performance boost was worth it.
>
>
Again, the result depends fairly heavily on the details. Glyph
>
rasterization has also been the subject of a great deal of performance
>
work recently, so you might try benchmarking on several OS versions for
>
comparison.
Well, my results were in 10.2.x and 10.3.0~3. (I'm not sure if I tested
the bezier-style code path under 10.3.4.) Anyway, it was just night and
day performance-wise when I tried it. I was expecting Bezier paths to
be pretty good based on what I'd heard from some Cocoa books and this
list, but NSImage completely rocked it. That's just my experience, of
course. (This seems to line up with common sense to me, though--no
matter how fast glyph rasterization gets, could it really get much
better than a bit blit?)
If I were trying to solve the numbers-in-a-grid problem, hmm... maybe
I'd make 128 NSImages (one for each number) and then composite the
proper one to screen when needed. It sounds expensive, but if you want
speed, there isn't going to be a much faster way, and the memory
consumption seems pretty small when you look at MallocDebug. There's
also the option of rasterizing the numbers zero through nine into
individual NSImages and then drawing each digit separately; this is
probably going to be much nicer on your cache at the expense of more
NSImage per-call overhead.
_______________________________________________
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.