• 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: Animation in Cocoa too slow? [was: Animation with CALayer?]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Animation in Cocoa too slow? [was: Animation with CALayer?]


  • Subject: Re: Animation in Cocoa too slow? [was: Animation with CALayer?]
  • From: alex <email@hidden>
  • Date: Thu, 7 Feb 2008 19:18:48 -0800

Thank you-  my guess at this was so far off!

While I may not use this for an 'audio level meter' I may use this technique for something a bit more complex and just as realtime!

Thanks again,
alex

On Feb 7, 2008, at 11:25 AM, Troy Stephens wrote:

On Feb 6, 2008, at 7:26 PM, alex wrote
This is the perfect answer!!  Thank you.

One more question (sorry):

How would one approach doing this exact thing with Layers? Or is that not recommended and it should be done in the view like below?

This could certainly be done using layers -- but if you aren't already using Core Animation-based rendering in your UI for other reasons, I'd recommend sticking with the plain NSView approach, as a CA renderer is an awfully big hammer to bring in just to draw a simple set of moving level bars.


If you did go the layer-based route, an efficient approach would be to create a layer for each level bar, whose content was provided as a CGImage or as a backgroundColor (which can be a solid or pattern color), and change the layer's bounds height (or width) when the level value changes. To suppress the default implicit layer bounds animation so as to get an immediate response to level changes, you'd make the change inside a CATransaction within which you disable actions:

[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithBool:YES] forKey:kCATransactionDisableActions];
levelLayer.bounds = CGRectMake(0, 0, LEVEL_BAR_WIDTH, heightForNewLevelValue);
[CATransaction commit];


Providing the layer content as described effectively allows the redraw work to be offloaded to the GPU, which should result in good performance.

Troy

_______________________________________________

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


References: 
 >Animation with CALayer? (From: alex <email@hidden>)
 >Re: Animation with CALayer? (From: Bill Dudney <email@hidden>)
 >Animation in Cocoa too slow? [was: Animation with CALayer?] (From: alex <email@hidden>)
 >Re: Animation in Cocoa too slow? [was: Animation with CALayer?] (From: Troy Stephens <email@hidden>)
 >Re: Animation in Cocoa too slow? [was: Animation with CALayer?] (From: alex <email@hidden>)
 >Re: Animation in Cocoa too slow? [was: Animation with CALayer?] (From: Troy Stephens <email@hidden>)

  • Prev by Date: Re: libPng.dylib: "file is not of required architecture"
  • Next by Date: Re: My app breaks when moved while running
  • Previous by thread: Re: Animation in Cocoa too slow? [was: Animation with CALayer?]
  • Next by thread: Itunes API/plugin
  • Index(es):
    • Date
    • Thread