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

后端 未结 4 832
死守一世寂寞
死守一世寂寞 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:43

    I thought Petzold explains in this paragraph;

    The ScatterPlotVisual class works by creating a DrawingVisual object for each DataPoint. When the properties of a DataPoint object change, the class only needs to alter the DrawingVisual associated with that DataPoint.

    Which builds on an earlier explanation;

    Whenever the ItemsSource property changes, or the collection changes, or a property of the DataPoint objects in the collection changes, ScatterPlotRender calls InvalidateVisual. This generates a call to OnRender, which draws the entire scatter plot.

    Is this what your asking about?

    By the way, this is a fairly recent high-performance WPF tutorial, many tens of thousands of points in that plot, it is 3D rendered and animated also (even uses mouse input to drive some of the transforms).

提交回复
热议问题