D2D 的一些 note

我猜想 D2D 只是 MS 搞的一套 对 D3D的封装,可以把D3D 和 GDI,GDI+ 更好的集成,
主要还是用GPU来做 GUI。
 
带着这个疑问,我开始查找:
 
首先看 MSDN 怎么说?
 
关键词:

Windows Imaging Component (WIC) 
IE9 用的 是 D2D

Purpose

Direct2D is a hardware-accelerated, immediate-mode, 2-D graphics API that provides high performance and high-quality rendering for 2-D geometry, bitmaps, and text. The Direct2D API is designed to interoperate well with GDI, GDI+, and Direct3D.

硬件加速, 高性能,高质量,2D的几何,可以集成GDI,GDI+,D3D,看来不是对D3D的封装。

因为从sample 来看,它不需要安装DX SDK.

MS还是很伟大的,最近几年的开发doc 写的很good。

http://msdn.microsoft.com/en-us/library/windows/desktop/dd370990(v=VS.85).aspx

Developer audience

Direct2D is designed primarily for use by the following classes of developers:

  • Developers of large, enterprise-scale, native applications.
  • Developers who create control toolkits and libraries for consumption by downstream developers.
  • Developers who require server-side rendering of 2-D graphics.
  • Developers who use Direct3D graphics and need simple, high-performance 2-D and text rendering for menus, user-interface (UI) elements, and Heads-up Displays (HUDs).
就是为了解决 在 3D 的应用中 UI的性能问题。
来看看它需要的最小运行时库:

Run-time requirements

  • Windows 7 or Windows Vista with Service Pack 2 (SP2) and Platform Update for Windows Vista
  • Windows Server 2008 R2 or Windows Server 2008 with Service Pack 2 (SP2) and Platform Update for Windows Server 2008
 
最后我找到了开发 D2D 的tech lead 的blog:
 

Direct2D (or D2D) is a native immediate-mode 2D graphics rendering API that is built on top of Direct3D, and offers some compelling performance and visual quality improvements over GDI and GDI+:

·         Hardware-acceleration

·         Software fallback when hardware isn’t available

·         Interoperability with GDI, GDI+, and Direct3D

·         ClearType text rendering

·         Per primitive antialiasing

·         Device-independent coordinate system

·         Draw and fill commands for geometries (lines, curves) and bitmaps

·         Solid color, linear, radial, and bitmap brushes.

·         Rendering to intermediate layers

·         Rich geometry operations (eg. unions, intersections, widening, outlining, etc)

·         Server-side rendering

·         Preservation of rendering state

 

所以证明我的猜想是正确的。 不过人家 2008年 就做了。

作者还解释了为什么要开发 D2D,以及 D2D 的名称来源:

So, we embarked on building the new API, which went through several geeky name changes, until it emerged from the primordial acronym-soup as Direct2D. This isn’t surprising, given that my team is part of the same group that produces Direct3D. It was a natural fit.

 

 Software Fallback – Should automatically fall back to software when hardware isn’t available (eg. session 0, server rendering scenarios).

 

关键还可以 向后兼容,如果硬件 不支持的,可以fallback to software。

 

 

还有最好的一点是:

Device-Independent Coordinate System – Should allow applications to be written that automatically handle DPI changes and differences.

·         Rich Geometry – Should provide a rich set of functions for both defining geometries and performing common geometric operations (eg. combining, intersecting)

 

设备无关的 坐标系统,这一点真的非常重要,从我多年的开发经验来看。

 

More Direct2D Blogs 

Tom Mulcahy — Tom is a Software Design Engineer on the Direct2D team, and owns a good swathe of infrastructure (bitmaps and texture management, WIC interop, clipping, etc). Prior to Direct2D, Tom worked on WPF and is widely regarded as our resident video guru. 
http://blogs.msdn.com/tmulcahy/default.aspx


Mark Lawrence — Mark is a Senior Software Design Engineer on the Direct2D team, and driving force behind the design and philosophy of the Direct2D API. He brings a ton of experience from his previous work on WPF, Windows Print architecture, and private industry.
http://blogs.technet.com/MarkLawrence/ 

 

Ben Constable — Ben is a Senior Software Design Engineer on the Direct2D team, and implemented all of the Direct3D and GDI Interop functionality within Direct2D. He is a self-described “graphics nerd” who brings  considerable experience in 2D and 3D rendering to the team, and has contributed to numerous Microsoft products (Visual Studio, Windows, Office, SQL, etc).

http://blogs.msdn.com/bencon/

 

 

最终说一点:万变不离其宗:

Or should we regard Direct2D as WPF re-surfacing in the unmanaged world?

Direct2D and WPF are targeted at different customers. Direct2D is a lightweight native code API which uses an immediate-mode calling pattern (like Direct3D), and will be used primarily by native C/C++ developers. WPF is a managed code framework which uses a retained-mode calling pattern, and will be used primarily by .NET developers.

习惯C++ 的可以选择 D2D 来 作WPF 的效果。 呵呵。

 

几个重要的问题:

“Server-side rendering” Does this mean support for RDP?

This is a two-part answer. Direct2D is built on top of Direct3D 10.1 and, since D3D10.1 provides both bitmap- and primitive-level remoting via RDP, it does mean support for RDP.

And, what will it take for broad adoption?  Unfortunately, there seems to be a dearth of WPF apps.

Developers should use whatever tool is appropriate for their needs. If you’re writing native C/C++ code, and you need to do high-quality 2D rendering with hardware acceleration on Win7, you should use Direct2D. If you’re using managed .NET code, you should use WPF.  The technologies are not in competition.

你熟悉啥,就用啥,技术无法比。

– Related to the previous question: What version(s) of D3D does this run on? Will it be backwards compatible?

It runs on Direct3D 10.1, which includes so-called 10Level9 functionality — which allows you to run D3D10.1 apps on a D3D9 driver.

需要 10.1 但可以 跑在 D3D9

 还可以制作 video playback,就是因为是建立在 D3D 上的。

 

 

does D3D10 GPU run as D3D10Level9 device for D3D10.1?

 No, D3D10Level9 is only used in conjunction with a D3D9 driver. 

http://channel9.msdn.com/blogs/pdc2008/pc03   channel19 的video PDC 2008

 

Can Direct2D ‘help out’ in WPF? I mean, my experience with WPF is its quite slow in terms of rendering compared to GDI/GDI+. Maybe you guys can build an additional layer that can make WPF render using Direct2D

WPF can interop with Direct3D9. Read these articles for more details.

http://msdn.microsoft.com/en-us/library/system.windows.interop.d3dimage.aspx

http://msdn.microsoft.com/en-us/library/cc656910.aspx

http://msdn.microsoft.com/en-us/library/cc656710.aspx

涉及 WPF 与 Win32 interoperability 。

http://msdn.microsoft.com/en-us/library/ms742522.aspx

 

D2D animation : http://blogs.msdn.com/b/directx/archive/2009/12/12/animated-2d-graphics-for-ui-games-and-demos.aspx

 

 

0
39 comments to “D2D 的一些 note”
  1. 对XP的支持,stay tuned?
    2. Will it run on Windows XP? I assume not…

    Not currently. We’ve had a number of customers asking for XP, and we’re still evaluating downlevel support. As above, stay tuned. 😉

Comments are closed.