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 08:03:58 -0400
On 20-Oct-09, at 6:59 AM, Uli Kusterer wrote:
On 20.10.2009, at 03:02, Ben Haller wrote:
As for NSTableView, it does appear to be doing minimal drawing. So
I guess all the string-drawing overhead I see in Sampler is just
from the single column that is updating, which is unfortunate since
it means I have no room for optimization. I never imagined it
would take so much time just to draw the one column I dirtied.
This may help to optimize after all:
http://zathras.de/blog-cocoa-text-system-everywhere.htm
This is interesting, and I've done this sort of thing in the past
quite a bit actually. I'm surprised by one bit of it, though, where
it says:
...sometimes you need better performance than the NSStringDrawing
category will provide...
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.
In the past, playing around with such things, the big win I've
noticed over NSStringDrawing comes up only if you need to both measure
and draw the same string. Then you set everything up with your string
once, measure and draw, and layout needs to happen only once. So
drawing centered or right-aligned text is faster -- almost twice as
fast -- doing it yourself. If there's a way to get the same speedup
from Apple's API's I'm not aware of it; 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.
But if you're drawing text left-aligned, and thus don't need to
measure it, is there any speedup doing things yourself?
Cheers,
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