• 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: CGContextFillRect - is there a faster way?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CGContextFillRect - is there a faster way?


  • Subject: Re: CGContextFillRect - is there a faster way?
  • From: Ian Kemmish <email@hidden>
  • Date: Thu, 27 Sep 2007 20:29:05 +0100


On 27 Sep 2007, at 7:23 am, Paul Tapper <email@hidden> wrote:


Well, the shortest answer to your question is "no" since on a modern computer you'd expect CGContextFillRect() to simply clip the rectangle and pass its co-ordinates onwards to the graphics hardware. Stuffing four numbers into registers on the GPU doesn't take long at all:-)

I'm finding that the graphical performance is a bit of a problem for me - its just too slow.My code seems to spend much of its time trying to fill in a rectangle with a solid colour by calling CGContextFillRect. Is there a quicker way of doing this sort of thing? How much does it depend on what kind of CGContext I'm using? (I'm using a CGBitmapContext)Thanks for any help.Paul

So what might be going wrong? Here are some questions you might want to ask yourself:


1) The time might actually be spent in some other routine just *after* CGContextFillRect() in memory, if that routine is local (static, in C parlance). Some profilers get confused by this, others don't. You may be able able to resolve this question by looking at your own code. Are you calling CGContextFillRect() a humungous number of times? Are there any other graphics routines that you call a lot?

2) Is there anything odd about your CGBitmapContext? Perhaps it has an unusual pixel organisation, so that the drawing has to be done in software rather than hardware.

3) Are you drawing a flat colour? A pattern? A gradient? The answer to this may in particular interact with 2)

4) Are you constantly switching between graphics contexts in the same thread of execution? Unnecessary context switching can affect performance (depending on OS and graphics architecture).

5) "has a dynamically updating display" - How often do you update the display? Remember that on a computer screen, anything that updates more than 25 times per second is just wasted effort, and in practice, for things like level displays, 10 times per second is plenty. Arrange for your drawing to be driven not by the AU itself but by a timer in the UI.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ian Kemmish 18 Durham Close, Biggleswade, Beds SG18 8HZ
email@hidden Tel: +44 1767 601361 Mob: +44 7952 854387
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



_______________________________________________ Do not post admin requests to the list. They will be ignored. Coreaudio-api mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: CGContextFillRect - is there a faster way?
      • From: David Duncan <email@hidden>
  • Prev by Date: Problem with loading Factory Presets in Soundtrack Pro 2
  • Next by Date: Re: CGContextFillRect - is there a faster way?
  • Previous by thread: Re: CGContextFillRect - is there a faster way?
  • Next by thread: Re: CGContextFillRect - is there a faster way?
  • Index(es):
    • Date
    • Thread