• 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: Paul Tapper <email@hidden>
  • Date: Mon, 1 Oct 2007 12:31:02 +0000
  • Importance: Normal

Thanks everyone for the several answers I've had - really appreciated.
 
To answer Ian's questions below:
 
1. I'm using timings in the code gathered via mach_absolute_time, which seems to give me back sensible values.
 
2. I'm using GetGenericRGBColorSpace () and kCGImageAlphaPremultipliedFirst.  Is there some way I can find out whether its working in hardware or software mode?  Will that be dependant on what Mac hardware / OS its running on?
 
3. These are solid colour, one pixel wide, rectangles.
 
4. I don't think I'm constantly switching context.
 
5. The visual update is 3-10Hz.
 
Paul

> CC: email@hidden
> From: email@hidden
> Subject: Re: CGContextFillRect - is there a faster way?
> Date: Thu, 27 Sep 2007 20:29:05 +0100
> To: email@hidden
>
>
> 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
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - -
>
>



The next generation of MSN Hotmail has arrived - Windows Live Hotmail
 _______________________________________________
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

  • Prev by Date: Ang: Re: Logic Pro 8
  • Next by Date: Re: Logic Pro 8
  • Previous by thread: Re: Logic Pro 8
  • Next by thread: FW: CGContextFillRect - is there a faster way?
  • Index(es):
    • Date
    • Thread