Re: Dirty rects getting merged together makes for inefficient drawing
Re: Dirty rects getting merged together makes for inefficient drawing
- Subject: Re: Dirty rects getting merged together makes for inefficient drawing
- From: Ben Haller <email@hidden>
- Date: Tue, 20 Oct 2009 09:15:27 -0400
On 20-Oct-09, at 8:15 AM, Graham Cox wrote:
On 20/10/2009, at 11:03 PM, Ben Haller wrote:
AFAIK even -[NSAttributedString drawWithRect:options:] doesn't let
you draw a string centered or right-aligned in the rect, which
seems like a big oversight. I've just logged 7318495 on that.
That's not the case - NSAttributedString takes its left/right/center/
justified setting from the NSParagraphStyle attribute attached to
the string. If it's not there, it defaults to natural alignment for
the font (left for English).
Oh! Good to know. Didn't occur to me somehow!
I.e. I'm trying to understand what the tradeoffs are here.
Convenience versus speed. Setting up a text layout system
programatically is quite involved, and for a high-level solution
that is equivalent to olde-worlde DrawThemeTextBox the string
drawing methods do that for you. But they have to build up and tear
down a text system for every call, so incur this overhead and can't
cache any layout information. I still think it's the case (borne out
by profiling here) that glyph rendering still dominates the process
however.
But if you're drawing text left-aligned, and thus don't need to
measure it, is there any speedup doing things yourself?
Yes, if you are drawing the same string over and over again (as in
repeated refreshes of the same string in a view). The question is
whether the speed-up matters. If you have thousands of text objects
in your view, probably yes. If just one or two, probably not.
There's no need to (and you can't) draw faster than 60 fps so you
have ~16mS to draw everything. If it takes longer, text caching etc
may help.
Ah, yes, that is true, repeated drawing of the same string would be
a big win for this.
Uli had much the same to say. Good points. Thanks guys.
Ben Haller
Stick Software
_______________________________________________
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