I'm drawing some vector data, slightly under 9000 polygon objects, using FrameworkElement:DrawingVisual which in turn is a child of a Canvas object. My tree of objects would look something like this:
WPF Window
-Canvas
--FrameworkElement
---DrawingVisual -> DrawingContext.DrawGeometry
So far so good. I'm timing all the rendering methods and it is pretty much as expected, 0.32 seconds for the DrawingContext to do its stuff and 0.5 seconds total. With EdgeMode set to default (anti-aliased) the completed drawing appears on my canvas barely half a second later.
However, because I need all lines to be aliased I use RenderingOptions.SetEdgeMode to EdgeMode.Aliased on the canvas object.
After doing this there is no discernible difference in rendering time, 0.5 seconds total time. But - the completed drawing now takes over 4 seconds before it appears in my window. This compared to under 0.5 seconds for the anti-aliased version. The only difference is this single line of code:
RenderOptions.SetEdgeMode(myCanvas, EdgeMode.Aliased);
If I resize the window same thing happens, it takes much longer for the aliased version to resize compared to the anti-aliased one. Obviously, in this case my drawing code isn't even invoked so the problem must lie elsewhere.
It seems that something external to my code is slowing things down drastically when in aliased rendering mode, quite opposite of what I would have expected. So what am I missing here?