• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Dirty rects getting merged together makes for inefficient drawing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dirty rects getting merged together makes for inefficient drawing


  • Subject: Re: Dirty rects getting merged together makes for inefficient drawing
  • From: Graham Cox <email@hidden>
  • Date: Tue, 20 Oct 2009 23:15:34 +1100


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).

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.


--Graham


_______________________________________________

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


  • Follow-Ups:
    • Re: Dirty rects getting merged together makes for inefficient drawing
      • From: Ben Haller <email@hidden>
References: 
 >Dirty rects getting merged together makes for inefficient drawing (From: Ben Haller <email@hidden>)
 >Re: Dirty rects getting merged together makes for inefficient drawing (From: Dave Keck <email@hidden>)
 >Re: Dirty rects getting merged together makes for inefficient drawing (From: Ben Haller <email@hidden>)
 >Re: Dirty rects getting merged together makes for inefficient drawing (From: Andy Lee <email@hidden>)
 >Re: Dirty rects getting merged together makes for inefficient drawing (From: Ben Haller <email@hidden>)
 >Re: Dirty rects getting merged together makes for inefficient drawing (From: Uli Kusterer <email@hidden>)
 >Re: Dirty rects getting merged together makes for inefficient drawing (From: Ben Haller <email@hidden>)

  • Prev by Date: iPhone: UIDatePicker plus touch events?
  • Next by Date: Re: Dirty rects getting merged together makes for inefficient drawing
  • Previous by thread: Re: Dirty rects getting merged together makes for inefficient drawing
  • Next by thread: Re: Dirty rects getting merged together makes for inefficient drawing
  • Index(es):
    • Date
    • Thread