Performance of DrawingVisual vs Canvas.OnRender for lots of constantly changing shapes

Posted by romkyns on Stack Overflow See other posts from Stack Overflow or by romkyns
Published on 2010-02-23T15:36:47Z Indexed on 2010/06/13 10:22 UTC
Read the original article Hit count: 420

Filed under:
|

I'm working on a game-like app which has up to a thousand shapes (ellipses and lines) that constantly change at 60fps. Having read an excellent article on rendering many moving shapes, I implemented this using a custom Canvas descendant that overrides OnRender to do the drawing via a DrawingContext. The performance is quite reasonable, although the CPU usage stays high.

However, the article suggests that the most efficient approach for constantly moving shapes is to use lots of DrawingVisual instances instead of OnRender. Unfortunately though it doesn't explain why that should be faster for this scenario.

Changing the implementation in this way is not a small effort, so I'd like to understand the reasons and whether they are applicable to me before deciding to make the switch. Why could the DrawingVisual approach result in lower CPU usage than the OnRender approach in this scenario?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about Performance