使用WPF视觉层高性能显卡 [英] High performance graphics using the WPF Visual layer

查看:2018
本文介绍了使用WPF视觉层高性能显卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个WPF绘图程序,这将有可能在任何时间加载并绘制数百个文件在屏幕上,并且用户可能想缩放和平移此显示。有些文件类型可能包含数千个点,其中最有可能被连接成某种路径的。其他支持的格式包括TIFF文件。

I am creating a WPF mapping program which will potentially load and draw hundreds of files to the screen at any one time, and a user may want to zoom and pan this display. Some of these file types may contain thousands of points, which would most likely be connected as some kind of path. Other supported formats will include TIFF files.

它是为更好的性能有,这是所有的数据绘制一个DrawingVisual,或加载每一个文件,我应该创建一个新的DrawingVisual?

Is it better for performance to have a single DrawingVisual to which all data is drawn, or should I be creating a new DrawingVisual for each file loaded?

如果任何人都可以在此提供任何意见这将是更AP preciated。

If anyone can offer any advice on this it would be much appreciated.

推荐答案

你会发现很多堆栈溢出相关的问题,然而他们不是所有提到的最高性能的方法之一得出大量数据的屏幕是使用<一href=\"http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspx\">WriteableBitmap API。我建议采取一看 WriteableBitmapEx 开源项目上codePLEX。的披露,我对这个曾经做出了贡献,但它不是我的图书馆的。

you will find lots of related question on Stack Overflow, however not all of them mention that one of the most high performance ways to draw large amounts of data to the screen is to use the WriteableBitmap API. I suggest taking a look at the WriteableBitmapEx open source project on codeplex. Disclosure, I have contributed to this once, but it is not my library.

已经尝试了DrawingVisual,StreamGeometry,的OnRender,帆布,所有这些翻倒,一旦你有吸引逾1,000个以上的物到屏幕上。有迹象表明,用帆布的虚拟化(有处理技术一<一href=\"http://blogs.msdn.com/b/kaelr/archive/2010/08/11/zoomableapplication2-a-million-items.aspx\">million项目演示与虚拟工作区),但即使这是仅限于1000〜可见在同一时间之前放慢。 WriteableBitmap的,您可以直接访问一个位图和借鉴的(OLDSKOOL风格),这意味着你可以在速度绘制对象数以万计。你可以自由地实现自己的优化(多线程,详细程度),但做的注意,您没有得到太多多余的装饰与API。你从字面上都在做自己的工作。

Having experimented with DrawingVisual, StreamGeometry, OnRender, Canvas, all these fall over once you have to draw 1,000+ or more "objects" to the screen. There are techniques that deal with virtualization of a canvas (there' a million items demo with Virtualized Canvas) but even this is limited to the ~1000 visible at one time before slow down. WriteableBitmap allows you to access a bitmap directly and draw on that (oldskool style) meaning you can draw tens of thousands of objects at speed. You are free to implement your own optimisations (multi-threading, level of detail) but do note you don't get much frills with that API. You literally are doing the work yourself.

有一点需要注意,虽然。而WPF使用CPU进行镶嵌/ GPU进行渲染,WriteableBitmap的将使用CPU的一切。因此,填充率(每帧再现像素数)成为依赖于你的CPU功率的瓶颈。

There is one caveat though. While WPF uses the CPU for tesselation / GPU for rendering, WriteableBitmap will use CPU for everything. Therefore the fill-rate (number of pixels rendered per frame) becomes the bottleneck depending on your CPU power.

如果做不到这一点,如果你真的需要高性能的渲染,我建议采取看看 SlimDX (托管DirectX),并与互操作WPF。这会给你最高的性能,因为它会直接使用GPU。

Failing that if you really need high performance rendering, I'd suggest taking a look at SlimDX (Managed DirectX) and the interop with WPF. This will give you the highest performance as it will directly use the GPU.

最好的问候,

这篇关于使用WPF视觉层高性能显卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆