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: Uli Kusterer <email@hidden>
- Date: Tue, 20 Oct 2009 14:42:42 +0200
On 20.10.2009, at 14:03, Ben Haller wrote:
implying that doing things this way is faster than NSStringDrawing.
Is that actually true? Why would that be? NSStringDrawing does
more or less exactly this, doesn't it, using cached a cached
textstorage/layout/container set? If NSStringDrawing is less
efficient than doing it yourself, where does that inefficiency lie,
and why doesn't Apple fix that inefficiency? Presumably because
Apple's way has some other benefit? So what is that benefit? I.e.
I'm trying to understand what the tradeoffs are here.
Apple's code has to be generic. It can only cache the last call, or
maybe a few. It has to be conservative in its decision whether to
cache so it doesn't cache stuff that's actually changed. You know your
array storage, so you could cache more aggressively. Only you know
your code, it might not make sense there, but in a lucky case, you
could probably keep around the text system objects for each of your
cells, and thus draw way faster than the OS's functions could do.
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.
Haven't tried that, but have you tried setting the paragraph style
in the attributed string to use the right alignment?
But if you're drawing text left-aligned, and thus don't need to
measure it, is there any speedup doing things yourself?
If you draw the same bunch of strings repeatedly, and you know their
lifetime, you can definitely make them draw faster.
Cheers,
-- Uli Kusterer
"The witnesses of TeachText are everywhere..."
_______________________________________________
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