Friday, 20 March 2009

Silverlight: SL3 Dropshadows are slow

This is probably no great surprise to anyone but bitmap effects have quite a significant performance hit on your CPU.

The following code is an example of how to apply a drop shadow

<Button Content="Drop Shadow Under Me" Width="200">
<DropShadowEffect Color="Black" Direction="320"
ShadowDepth="25" BlurRadius="5" Opacity="0.5" />

So just be aware before you start apply dropshadows to every button / element on the page that it will slow your application down.

Just be considerate in your use (and always check your performance), especially since some effects (such as dropshadow) can easily be produced using more performant techniques.


Joeyw said...

Just wondered, is this with GPU enabled? Why would this be different to WPF?

chrishayuk said...

I'm afraid so, but I do think there is a bug in there.

CPU is about 2% with 70 buttons without GPU

CPU is about 13% with 70 buttons with drop shadows without GPU

CPU is about 45% with 70 buttons with drop shadows with GPU

As i said I think there is something going wrong there

Jaison Green said...

Yup yup,

Here is a post I made on the forums.

Animating dropshadows is even worse.

Rich C said...

Seema's Mix09 Session indicated that GPU support does not extend to PixelShaders - so it's only using software rendering..