WPF - GDI/GDI+的末路, Direct3D的盛宴[zz]

GDI/GDI+ 是什么

GDI is the main graphics library for Windows applications today. It provides 2D graphics and text functionality, as well as limited imaging functionality. There is some level of acceleration support in graphics cards for GDI, but it is almost negligible nowadays (especially when compared to the level of investment in Direct3D acceleration).

GDI+ was introduced around 2001 and it brought anti-aliased 2D graphics, floating point coordinates, gradients, per-pixel alpha value support, and support for multiple image formats to the Windows platform, but no hardware acceleration abstraction (all rendering is done in software). Windows Form provides managed wrappers on top of the GDI+ interfaces.
 

GDI/GDI+的前途 

如果微软按下面的计划执行,那么GDI/GDI+在未来不会有什么发展,可能会逐渐淡出主流了。

We continue to put a lot of effort in ensuring compatibility for GDI and GDI+ (and Windows as a whole I might add) for every Windows release, and both technologies will continue to be supported, but no functionality improvements are planned in these technologies for future Windows releases. Of course, we will continue to address security and customer issues; if any arise (the GDI and GDI+ development work takes place as part of the Avalon organization – we invest significant time on GDI/GDI+ work). 

WPF如何实现的 

WPF GDI/GDI+是不同技术实现。它是对DirectXmanaged封装,准确的说是Direct3D,所有2D的表现也都是通过其实现。由于Direct3D是基于硬件的Native API,而WPFmanaged code,因此WPF存在managed codenative资源的交互开销。这一点很象GDI+是对native GDI的封装,同样存在类似开销。因此,对于性能要求甚高的3D游戏,直接使用DirectX要比WPF 在性能表现上要强。 

Windows Presentation Foundation does not depend on either GDI or GDI+ for its rendering (GDI, GDI+, and WPF coexist side by side). The mainstream scenario has Windows Presentation Foundation doing all its rendering through Direct3D, for all primitives (2D, text, imaging, video, and of course 3D), through Direct3D’s native interface (the managed/native transition takes place within the Windows Presentation Foundation stack, as the bulk of WPF was written in managed code). 

正由于WPF依赖于Direct3D,因此它的图形的表现依赖于硬件显卡。如果,硬件本身不支持一些图形特效的硬实现,那么会不会对WPF编程带来复杂性,代码中还需要判断硬件是否适用?

不必担心,既然是对Direct3D的一种更高层次的封装,开发人员可以不必考虑硬件:硬实现不支持(GPU的工作),那么会有软实现(CPU的工作

Windows Presentation Foundation takes advantage of hardware rendering as appropriate. It uses Direct3D to provide accelerated rendering on DirectX 7 or above, with further optimization for graphics cards with DirectX 9 and Pixel Shader 2.0 hardware. For machines without these capabilities, Windows Presentation Foundation uses software rendering, a CPU-based, SSE and SSE2 optimized rasterizer. This is also used when Windows Presentation Foundation is unable to render something using the hardware pipeline, and guarantees that rendering output is available across all machine hardware configurations.

As a result, Windows Presentation Foundation has both hardware and software pipelines, both with difference performance characteristics. This could make application performance very difficult to predict, since there are two code paths. In practice, hardware is reliably faster; for a given application, it's simply a matter of setting a minimum requirement. Windows Presentation Foundation supports simple runtime hardware detection and allows you to dynamically tailor your application for the platform it's running on using resource dictionaries. 

Will Windows Presentation Foundation require a certain level of video card? 

Windows Presentation Foundation will take advantage of the latest graphics cards, but it can also use software emulation if a system doesn't have a supported video card. 

软实现是需要耗费更多的CPU资源,因此硬件对于WPF在性能方面的表现有很大影响。那么发挥WPF价值的硬件有什么要求? 

What graphics card should I use for Windows Presentation Foundation?

Any high performance DX9 Pixel Shader 2.0 card will give good results. The fastest PS 2.0 card with the most memory your bank account can afford is the ticket. 

若干年前上演过 Win+Intel的神话,今天一场WPF+显卡硬件厂商的盛宴又要开始了。

 引用:

http://www.fernicola.org/loquitor/index.php?/archives/4-Windows-Presentation-Foundation-Graphics-Under-the-Hood.html

http://msdn2.microsoft.com/en-us/library/aa480221.aspx

你可能感兴趣的:(WPF)