I am building a custom UI framework in WPF where I basically ditch as much of the built-in layout system and controls as I can. So far I have been branching off from UIElement
directly, but since I am already doing the measure, arrange and rendering myself, I am thinking I could slice off more of the WPF legacy by getting even "closer to the metal" (especially when it comes to layout / rendering). How close is it possible to get while staying in managed code and not being afraid of doing the dirty work myself?
I am toying with a prototype concept on the side now where I only have one element inheriting from UIElement: a Root
object, similar to a stripped down Canvas
, that "hosts" the rest of my layout engine and channels relevant IInputElement
benefits into it. From that point onward, all elements would be completely custom objects not inheriting from anything in WPF, but rendering directly into the DrawingContext
of Root (in its OnRender
method).
Now I'm wondering about the relative performance of having a WriteableBitmap
root element and manually draw onto that instead, for example using WriteableBitmapEx for convenience. Not having anti-aliasing isn't an issue, neither is a custom hit testing system.
My thoughts are primarily that WriteableBitmap(Ex) does not have the privilege of any GPU acceleration gains and therefore will be [much] slower when large areas needs to be repainted / transformed.
I do have other needs for a "pixel-based-rendering-engine-in-the-engine", though, so I am still interested in some perspective on this.
Any insights?
Edit: And what about SharpDX in this context? Maybe once I'm at it I might as well go for a WinForms solution with a DirectX wrapper like SharpDX (..or.. I guess what I really should do is sign up for the whole C++ enchilada, but unfortunately I don't have time to start learning that in the midst of things)..
WriteableBitmapEx is quite fast, even when it just runs on the CPU. It's used in this high perf charting control: http://www.scichart.com
You should also checkout Direct3D indeed. You can get really good performance, but it really depends how it's used and that most draw operations are cached and the CPU-GPU communication is as lets as possible.