This project has moved and is read-only. For the latest updates, please go here.

WPF and some administrative questions

Topics: SharpMap Project, SharpMap v2.0
Oct 4, 2007 at 12:59 AM
Edited Oct 4, 2007 at 1:00 AM
Hi codekaizen, hi guys,
First some administrative questions:
1. Is it appropriate to upload patches to V2 in the CodePlex patches area?
2. Is it the right time and place (considering all the rush around the beta release) to discuss some design questions, especially ones relating WPF rendering and presentation potential implementation (which I'm trying to work on, and hopefully soon, publish some results to the community's fierce judjment… :-)
Besides, had any of you being toying with/pondering about the WPF frontend of SharpMap – I'd be glad to share some ideas. From what I've been trying in the few past weeks – the design of V2 fits almost like a glove to the WPF world codekazien deserves a great kudos on this. The " almost" are the issues I'd like to discuss, especially regarding caching, re-rendering on Zoom/Pan actions (when there no actual change to the layers, just to the transform matrices – but that’s after I'll get answers to the administrative ones…
Oct 4, 2007 at 10:00 AM
Hi blackrussian -

Feel free to contribute patches, but things are in a state of considerable flux yet until I can freeze on some key scenarios which will allow me to kick out a release.

As far as the WPF stuff, I think you might not have a clear picture on what is intended. I don't expect to re-render path instances on every call to a render method, as is currently done in the GDI renderer (and what you are probably concerned about). While I haven't been able to completely flesh it out, the current idea is to have a buffer cache of paths which a render call would just select, modify (if needed) and enumerate for any post processing. In a way, this is like the DirectX programmable graphics pipeline which accesses a pool of resources as rendering objects are streamed through it. Granted, it's not fully apparent in the current codebase, but that is where it is headed. I'm hoping to work with the Proj.Net and NTS projects to create a core set of interfaces for vertex data, so that both geospatial operations and rendering become very compact and efficient. It might even make sense to use a graphics buffer for the vertex data (like DirectX's VertexBuffer), since it is already well developed and very fast for computation and rendering.

So there you have it... feel free to contribute patches to v2.0 as it is, but it's risky.

I think it will be better to do tighter release cycles after the first one (Beta 1)... that way we can share a little more freely.
Oct 4, 2007 at 12:50 PM
Hi blackrussian and codekaizen,

I'm interesting also for V2.0 WPF stuff.
What's about to create XAML as render layer and use generated XAML for zoom and pane?
I'm not really very sure, but what I know, WPF/XAML are already DirectX crafted and uses his pipeline rendering capabilities (build on top of it).
What I'm seen, it's really much faster as GDI+ in every cases. My small 3D-example rocks, but WPF 3D has one disadvantage, it's difficul to draw anything such lines unscaled. Otherwise, the big advantage of XAML, it can be easily printed or saved and viewed (and later edited) with external viewers, i.e. built in IE7. The XAMl can be automatically generated by programmatically adding elements on WPF control.
Oct 4, 2007 at 3:23 PM
Hi Alex -

The plan with the WPF renderer is to just create instances of StreamGeometry and transform those in and out of view as zoom and pan (and rotate) operations are dispatched to the view. These StreamGeometry instances can be created directly from SharpMap.Geometries.Geometry instances, without needing to go through XAML and the required slower compilation to BAML and then to IL. XAML seems like it will be quite useful for printing (like you mention), export, symbology or layer feature definition, however.

I'm sorry I was confusing about the DirectX pipeline. I was only making a comparison on how SharpMap can render geometries and rasters and how DirectX (Direct3D, really) renders vertex and texture data. I see that there are certain parallels with that and SharpMap's rendering in that there are a set of stages and a shared resource cache.

On a tangential note, even though WPF uses the DirectX rendering pipeline internally, it isn't exposed to WPF consumers in the current version of WPF. If we wanted to take advantage of it (say by writing a vertex shader to do map reprojection), a DirectX renderer for SharpMap would be needed.
Oct 8, 2007 at 6:20 PM
Edited Oct 8, 2007 at 6:22 PM

all of the WPF elements can be created on the fly and then will be cached as XAML scene internally.
For the rendering will be used DirectX and this is really very fast.
The printing is also not the problem, the same is export the scene as XAML or generating XPS documents.
As we can see, we don't need to generate BAML and compile then to IL.

Maybe it will be very usefull (if not already done) to create an intermediate abstract presentation layer which is only holds the geometries and other drawable parts of map and events to draw those maps, and then derive concrete technology relevant (GDI+, OpenGL, WPF) implementations, which only transforms abstract intermediate calls to concrete engine calls; this mechanism can also create an visual object hierarchy if thsi is supported by an technology.

Is development with WPF presentation already started? In every case it's interesting to see, how fast it is before deal with some optimisations.
Oct 8, 2007 at 10:33 PM
Edited Oct 8, 2007 at 10:34 PM
First, I must note that I'm quite a newcomer to this project, and not a member of its dev team (hopefully will be one day :-) so one must be humble discussing others work….
I feel that before going into technical discussions of future design issues, one have to understand well the design and intention of the current state. Tried to stay in the learning phase by now… but the WPF stuff is too exiting, so I couldn't hold myself…

I have implemented by now an initial prototype of the rendering / presentation layers in WPF (pretty much the same feature set as in the GdiRendering/presentation of revision 230). Still don't feel comfortable enough with the code to publish it, and in any case I think it's better to wait first for the beta release.

From my limited number of experiments – yes, the WPF rendering is damn fast. But there are many many ways to fine tune it – (e.g. in what stage you Freeze freezable objects – if you freeze 'em you'll have to recreate them on update, if you don't – they'll render slower, and you can't move them between threads, so you have to create them on the main thread…). In addition there are many things, not immediately related to the rendering layer which affect performance.- e.g. how the geospecial query of the view envelope is done, and more importantly is it synchronous or not. Since async querying wasn't implanted yet I had to do some threading juggling in order to achieve the smooth performance, but again once the beta ships – I'm sure thing will be much nicer.
I do not really understand what you mean by "all rendering will be cached internally as XAML". According to my understanding – the internal representation of the drawing instructions in WPF is: 1. Opaque from WPF API perspective. 2. The closest visible WPF concept is StreamGeometry , so in principle it's the most efficient way to store cached shapes (as codekaizen mentioned).
Same goes regarding "rendering using DirectX", well, internally WPF renders everyting through the DirectX pipeline. The point of using WPF is that you don't have to deal with such a low level, and still gain most of the performance benefits.

Regarding the rendering abstraction layer you've mentioned - I think that the current design of SharpMap2 does exactly this (and that was the main reason, as I can guess for the massive refactoring that the project undertook) – dive into the code – it's all there.
By now - lets keep our fingers crossed, and wait to the Beta.


Oct 14, 2007 at 4:18 AM
Hey blackrussian -

Beta 1 is out. If you get around to updating the WPF implementation you have, I hope you'd be willing to share it. For Beta 2, I'm planning on reworking how vertexes are stored and processed which will likely change how a renderer could get data from set of features, but the overall design should remain the same.
Oct 14, 2007 at 12:53 PM
Hi codekaizen,

this is really very nice announcement!!!
Now I hope also blackrussian will share the WPF implementation of presentation layer with us.
I'm also very interested in comparision, how many times the GDI+ implementation will be outperformed by WPF implemetation :)
Oct 14, 2007 at 1:42 PM
These are great news,
I believe I'll have some time to update and organize my WPF experiments around the next weekend. as soon as that done, the patch will be uploaded.

Nov 3, 2007 at 2:12 PM
Hi blackrussian!

Is the patch already available somewhere?
Nov 4, 2007 at 10:10 AM
Edited Nov 4, 2007 at 10:12 AM
Unfortunately I had a some more urgent stuff to take care off in my schedule, so currently no. I will make an effort to uploaded it within a week.
Sorry for the delay,