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

后端 未结 4 821
死守一世寂寞
死守一世寂寞 2020-12-30 03:52

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 mo

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-30 04:41

    Everyone in the answers got it wrong. The question is whether rendering shapes directly in the drawing context is faster than creating DrawingVisual. The answer is obviously 'yes'. Functions such as DrawLine, DrawEllipse, DrawRectangle etc. do not create any UI Element. DrawingVisual is much slower because it does create a UI Element, although a lightweight one. The confusion in the answers is because people simply copy/paste the DrawingVisual performs better than distinct UIElement shapes statement from MSDN.

提交回复
热议问题