开发者

WPF high performance drawing - should I group by brush color?

In Direct2D they recommend 开发者_如何转开发drawing similar things together, to avoid unnecessary GPU state changes. They also do some drawing operation reordering behind the scene just for that.

I have to draw a lot of rectangles which can have one of two colors. I'm thinking of doing the drawing in two passes, one for the rectangles with the first color and another for the ones with the other color.

Do you have any idea if this will improve the rendering speed? The speed I have right now is not that great. I draw into a DrawingContext obtained from a DrawingVisual.


I really don't know what effect grouping by brush will have, but there are some things you should check first:

  • Make sure all brushes, pens and other freezables are frozen.
  • Simplify your visual tree, try to reduce element count.
  • Try to reduce the number of elements that change every time you update your drawing.

Read: http://msdn.microsoft.com/en-us/magazine/dd483292.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜