It looks like you already have a solution, but here is another method.
Ø animate the opacity / ScaleX / ScaleY of pngs You can use the Silverlight's GPU capabilities for this, as long as you do not have too many large pngs, and you do not have other elements between the pngs*. To do this, turn on the "EnableGPUAcceleration" param (must do this before the Silverlight control is created). Set CacheMode=BitmapCache on the individual PNGs or the element that you are animating its properties for. GPU can accelerate the Opacity and RenderTransforms properties of any element, as long as it does not have any of the following properties set on itself or its parents: [Perspective, Shaders, an irrectangular clip or OpacityMask] (setting these properties on the children should be fine). To make sure that you are getting hardware acceleration, turn on EnableFrameRateCounter - you should see a box in the upper left which shows the framerate, the amount of VRAM that you are using in Mb, the # of cached nodes (which should be 100, in the case below) and the # of intermediates (this count goes up with more elements between the pngs - see the *, above. Having too many of these can deteriorate the perf of your app) To see what is hardware accelerated, turn on EnableCacheVisualization - which will show you the non-GPU-surfaces in tinted colors, and the GPU-surfaces in regular colors. YMMV. Seema, SL graphics From: [email protected] [mailto:[email protected]] On Behalf Of Ross Jempson Sent: Sunday, September 20, 2009 7:06 PM To: [email protected] Subject: animation cpu usage Hi there, This is an old question I posted when the list was down. Does anyone have any suggestions as to how I can minimise cpu usage when using a storyboard/animation(s) that repeat constantly. To explain the scenario, I have a screen that has a background that sort of looks like a night sky. There are say 100 little stars (the same png scattered around with various sizes). I animate the opacity / ScaleX / ScaleY of a random png every 1 second to create a twinkling effect that keeps running the whole time you view the screen. The effect is very nice, however I notice it hogs the cpu. I have tried 2 implementations. In the first implementation I created a storyboard with 3 animations. I created a timer that fired every 1 second, and on the fly set the animations to target one of the pngs randomly (stopping and starting the storyboard each time). This was consuming on average 80% of my CPU. I created a second implementation to see if I could improve the situation. In the second implementation I decided to build up the storyboard in code up front. I create 40 animations up front targeting random pngs, each with a begintime 1 second later than the previous and add them all to the one master storyboard. I then just run that storyboard over and over. However, this approach made no difference to the cpu being consumed. Cheers.
_______________________________________________ ozsilverlight mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/ozsilverlight
