Direct2D
   HOME

TheInfoList



OR:

Direct2D is a 2D
vector Vector most often refers to: *Euclidean vector, a quantity with a magnitude and a direction *Vector (epidemiology), an agent that carries and transmits an infectious pathogen into another living organism Vector may also refer to: Mathematic ...
graphics
application programming interface An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how ...
(API) designed by
Microsoft Microsoft Corporation is an American multinational technology corporation producing computer software, consumer electronics, personal computers, and related services headquartered at the Microsoft Redmond campus located in Redmond, Washi ...
and implemented in
Windows 10 Windows 10 is a major release of Microsoft's Windows NT operating system. It is the direct successor to Windows 8.1, which was released nearly two years earlier. It was released to manufacturing on July 15, 2015, and later to retail on ...
,
Windows 8 Windows 8 is a major release of the Windows NT operating system developed by Microsoft. It was released to manufacturing on August 1, 2012; it was subsequently made available for download via MSDN and TechNet on August 15, 2012, and later to ...
,
Windows 7 Windows 7 is a major release of the Windows NT operating system developed by Microsoft. It was Software release life cycle#Release to manufacturing (RTM), released to manufacturing on July 22, 2009, and became generally available on October 22, ...
and Windows Server 2008 R2, and also
Windows Vista Windows Vista is a major release of the Windows NT operating system developed by Microsoft. It was the direct successor to Windows XP, which was released five years before, at the time being the longest time span between successive releases of ...
and
Windows Server 2008 Windows Server 2008 is the fourth release of the Windows Server operating system produced by Microsoft as part of the Windows NT family of the operating systems. It was released to manufacturing on February 4, 2008, and generally to retail on F ...
(with Platform Update installed). Direct2D takes advantage of hardware acceleration via the graphics processing unit (
GPU A graphics processing unit (GPU) is a specialized electronic circuit designed to manipulate and alter memory to accelerate the creation of images in a frame buffer intended for output to a display device. GPUs are used in embedded systems, mobi ...
) found in compatible graphics cards within personal computer, tablet, smartphone and modern graphical device. It offers high visual quality and fast rendering performance while maintaining full interoperability with classic Win32 graphics APIs such as GDI/GDI+ and modern graphics APIs such as
Direct3D Direct3D is a graphics application programming interface (API) for Microsoft Windows. Part of DirectX, Direct3D is used to render three-dimensional graphics in applications where performance is important, such as games. Direct3D uses hardware ...
.


Overview

Direct2D is a
native code In computer programming, machine code is any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a ver ...
API based on C++ that can be called by
managed code Managed code is computer program code that requires and will execute only under the management of a Common Language Infrastructure (CLI); Virtual Execution System (VES); virtual machine, e.g. .NET, CoreFX, or .NET Framework; Common Language Runt ...
and uses a "lightweight
COM Com or COM may refer to: Computing * COM (hardware interface), a serial port interface on IBM PC-compatible computers * COM file, or .com file, short for "command", a file extension for an executable file in MS-DOS * .com, an Internet top-level d ...
" approach just like
Direct3D Direct3D is a graphics application programming interface (API) for Microsoft Windows. Part of DirectX, Direct3D is used to render three-dimensional graphics in applications where performance is important, such as games. Direct3D uses hardware ...
, with minimal amount of abstraction. However, unlike WPF and similarly to GDI/GDI+, Direct2D is an "immediate mode" rendering API with simple BeginDraw/Draw/EndDraw calls; Direct2D has no concept of a "scene" and does not use retained tree structures, and the rendering state is preserved between drawing calls. Direct2D can minimize CPU usage and utilize hardware rendering on a graphics card with minimum support of Direct3D Feature Level 9 with WDDM 1.1 drivers. Applications can choose to use it exclusively with CPU, the so-called software rendering by using it in conjunction with WARP10 in situations when hardware capability is not available, such as when running within a device with minimal GPU support, under terminal service, Windows session 0, or when graphics rendering is performed in a remote server with the graphical result sent back to the client device. Direct2D performance and memory usage scale linearly with primitive counts in both software and hardware. Direct2D supports high-quality rendering with the following key features: * High-quality subpixel text rendering via
DirectWrite DirectWrite is a text layout and glyph rendering API by Microsoft. It was designed to replace GDI/GDI+ and Uniscribe for screen-oriented rendering and was first shipped with Windows 7 and Windows Server 2008 R2, as well as Windows Vista and Win ...
for both grayscale and
ClearType ClearType is Microsoft's implementation of subpixel rendering technology in rendering text in a font system. ClearType attempts to improve the appearance of text on certain types of computer display screens by sacrificing color fidelity for addit ...
technique * Per-primitive antialiasing * Bézier geometry draw and fill * Rich geometry operations (e.g. Boolean operations, path widening, outlining, etc.) * Composite layers * Primitive blend modes (e.g. source-over, source-copy, min blends, etc.) * Image built-in and custom effects for photo adjustment, graphical and color transform *
Gradient In vector calculus, the gradient of a scalar-valued differentiable function of several variables is the vector field (or vector-valued function) \nabla f whose value at a point p is the "direction and rate of fastest increase". If the gr ...
brush and mesh * Command list for command buffering and printing * Scalable ink stroke * Sprite batch for game development Direct2D allows full interoperability with GDI, GDI+, and permits rendering to and from a Direct3D surface, as well as to and from a GDI/GDI+ device context (HDC). It can be used effectively together with
Windows Imaging Component Windows Imaging Component (WIC) is a COM-based imaging codec framework introduced in Windows Vista (and later available in Windows XP Service Pack 3) for working with and processing digital images and image metadata. WIC enables application d ...
(WIC) for image encoding/decoding, and with DirectWrite for text formatting and font processing. Such interoperability allows developers to gradually replace critical code paths with Direct2D code without the need to overhaul their entire source code. In Windows 10 timeframe, an Open Source project called Win2D was developed by Microsoft to further simplify the usage of Direct2D and DirectWrite in
Universal Windows Platform Universal Windows Platform (UWP) is a computing platform created by Microsoft and first introduced in Windows 10. The purpose of this platform is to help develop universal apps that run on Windows 10, Windows 10 Mobile (discontinued), Windo ...
(UWP) application. Win2D is a highly-efficient WinRT wrapper of Direct2D and DirectWrite designed from the ground up to integrate seamlessly with XAML Canvas control while preserving the power of the underlying graphics subsystem.


Subsequent versions


Direct2D 1.1

An updated version of Direct2D was launched with
Windows 8 Windows 8 is a major release of the Windows NT operating system developed by Microsoft. It was released to manufacturing on August 1, 2012; it was subsequently made available for download via MSDN and TechNet on August 15, 2012, and later to ...
in October 2012. It was also
backport Backporting is the action of taking parts from a newer version of a software system or software component and porting them to an older version of the same software. It forms part of the maintenance step in a software development process, and it is ...
ed to Windows 7 SP1 (but not to Windows Vista) via the Windows 7 platform update. The original version of Direct2D was tied to
DirectX Microsoft DirectX is a collection of application programming interfaces (APIs) for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with "Direct" ...
11 (in hardware, up to
Direct3D Direct3D is a graphics application programming interface (API) for Microsoft Windows. Part of DirectX, Direct3D is used to render three-dimensional graphics in applications where performance is important, such as games. Direct3D uses hardware ...
10.1 is used), whereas this version of Direct2D integrates with DirectX 11.1. Windows 8 also added interoperability between
XAML Extensible Application Markup Language (XAML ) is a declarative XML-based language that Microsoft developed for initializing structured values and objects. It is available under Microsoft's Open Specification Promise. XAML is used extensively ...
and Direct2D along with Direct3D components, which can be all mixed in an application.


Direct2D 1.2

New features were added to Direct2D with
Windows 8.1 Windows 8.1 is a release of the Windows NT operating system developed by Microsoft. It was released to manufacturing on August 27, 2013, and broadly released for retail sale on October 17, 2013, about a year after the retail release of its pre ...
in October 2013: Geometry realizations, Direct2D effects API, command list API, multithreading APIs, per-device rendering priority, support for JPEG YCbCr images for smaller memory footprint, and support for block compressed formats (DDS files).


Direct2D 1.3

The release of
Windows 10 Windows 10 is a major release of Microsoft's Windows NT operating system. It is the direct successor to Windows 8.1, which was released nearly two years earlier. It was released to manufacturing on July 15, 2015, and later to retail on ...
in July 2015 brought important updates and new features to Direct2D such as the performance improvement of rendering scalable text without font rasterization, the ability to download the needed font from the cloud on demand without requiring the font installation step, an optimization for faster image loading and image effect rendering, and a more sophisticated way to apply gradient brush through the use of 2D mesh made of gradient patches. This release also introduced a brand-new API extension to support digital ink, which is highly leveraged by the Microsoft Edge browser as well as the ink canvas
XAML Extensible Application Markup Language (XAML ) is a declarative XML-based language that Microsoft developed for initializing structured values and objects. It is available under Microsoft's Open Specification Promise. XAML is used extensively ...
control.


Implementation

In their 2012 paper on the competing NV path rendering OpenGL extension,
Mark Kilgard Mark J. Kilgard is a graphics software engineer working at Nvidia. Prior to joining Nvidia, Mark Kilgard worked at Compaq and Silicon Graphics. While at Silicon Graphics, he authored the OpenGL Utility Toolkit, better known as GLUT, to make it ea ...
and Jeff Bolz explain (and criticize) the internals of Direct2D as follows: "Direct2D operates by transforming paths on the CPU and then performing a constrained trapezoidal
tessellation A tessellation or tiling is the covering of a surface, often a plane, using one or more geometric shapes, called ''tiles'', with no overlaps and no gaps. In mathematics, tessellation can be generalized to higher dimensions and a variety of ...
of each path. The result is a set of pixel-space
trapezoid A quadrilateral with at least one pair of parallel sides is called a trapezoid () in American and Canadian English. In British and other forms of English, it is called a trapezium (). A trapezoid is necessarily a convex quadrilateral in Eu ...
s and additional shaded geometry to compute fractional coverage for the left and right edges of the trapezoids. These trapezoids and shaded geometry are then rasterized by the GPU. The resulting performance is generally better than entirely CPU-based approaches and requires no ancillary storage for multisample or stencil state; Direct2D renders directly into an aliased framebuffer with properly antialiased results. Direct2D’s primary disadvantage is
hat A hat is a head covering which is worn for various reasons, including protection against weather conditions, ceremonial reasons such as university graduation, religious reasons, safety, or as a fashion accessory. Hats which incorporate mecha ...
the ultimate performance is determined not by the GPU (doing fairly trivial rasterization) but rather by the CPU performing the transformation and trapezoidal tessellation of each path and Direct3D validation work." In July 2012, the
Windows 8 Windows 8 is a major release of the Windows NT operating system developed by Microsoft. It was released to manufacturing on August 1, 2012; it was subsequently made available for download via MSDN and TechNet on August 15, 2012, and later to ...
team posted the following on the blog of Steven Sinofsky: "To improve geometry rendering performance in Windows 8, we focused on reducing the CPU cost associated with tessellation in two ways. First, we optimized our implementation of tessellation when rendering simple geometries like rectangles, lines, rounded rectangles, and ellipses." These common-case optimizations claimed to improve performance in the range of 184% to 438%, depending on the primitive. The post continued: "Second, to improve performance when rendering irregular geometry (e.g. geographical borders on a map), we use a new graphics hardware feature called '' Target Independent Rasterization'', or TIR. TIR enables Direct2D to spend fewer CPU cycles on tessellation, so it can give drawing instructions to the GPU more quickly and efficiently, without sacrificing visual quality. TIR is available in new GPU hardware designed for Windows 8 that supports DirectX 11.1."Rob Copeland, with contributions from Sriram Subramanian, Dan McLachlan, Kam VedBrat, Steve Lim, and Jianye Lu, and introduction by Steven Sinofsk
Hardware accelerating everything: Windows 8 graphics
/ref> This was followed by a benchmark using some 15
SVG Scalable Vector Graphics (SVG) is an XML-based vector image format for defining two-dimensional graphics, having support for interactivity and animation. The SVG specification is an open standard developed by the World Wide Web Consortium s ...
s, claiming performance improvements in the range of 151% to 523%. The section concluded: "We worked closely with our graphics hardware partners to design TIR. Dramatic improvements were made possible because of that partnership. DirectX 11.1 hardware is already on the market today and we’re working with our partners to make sure more TIR-capable products will be broadly available." The TIR feature was among those that caused a "war of words" between
Nvidia Nvidia CorporationOfficially written as NVIDIA and stylized in its logo as VIDIA with the lowercase "n" the same height as the uppercase "VIDIA"; formerly stylized as VIDIA with a large italicized lowercase "n" on products from the mid 1990s to ...
and AMD around December 2012, because Nvidia's Kepler GPU family does not support it, whereas AMD's GCN does. In response to customer demands, an Nvidia support staffer posted that TIR cannot be simply implemented at the driver level, but requires new hardware; the Maxwell 2 architecture, introduced in September 2014, is such hardware. In
Windows 8.1 Windows 8.1 is a release of the Windows NT operating system developed by Microsoft. It was released to manufacturing on August 27, 2013, and broadly released for retail sale on October 17, 2013, about a year after the retail release of its pre ...
, Direct2D can use the Direct3D11 hardware tesselators, but only in conjunction with D2D1_FILL_MODE_ALTERNATE. If another fill mode is used (e.g. D2D1_FILL_MODE_WINDING) then Direct2D falls back to tessellation on the CPU, but still uses TIR for anti-aliasing (if TIR is available). Since hardware tessellation is available in base Direct3D11 (not necessarily 11.1), Microsoft claimed significant performance improvements with Direct2D in Windows 8.1 (vs. Windows 8) on non-TIR hardware.


Uses and performance

Internet Explorer 9 Internet Explorer 9 or IE9 (officially Windows Internet Explorer 9) is a web browser for Windows. It was released by Microsoft on March 14, 2011, as the ninth version of Internet Explorer and the successor to Internet Explorer 8, and can replace p ...
and later versions use Direct2D and
DirectWrite DirectWrite is a text layout and glyph rendering API by Microsoft. It was designed to replace GDI/GDI+ and Uniscribe for screen-oriented rendering and was first shipped with Windows 7 and Windows Server 2008 R2, as well as Windows Vista and Win ...
for improved performance and visual quality. Direct2D support was added in the alpha version of
Firefox Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements current ...
3.7, roughly doubling its rendering speed. (Firefox 4 also added DirectWrite support, but this was made non-default for some fonts in Firefox 7 due to user complaints about the rendering quality.
Google Chrome Google Chrome is a cross-platform web browser developed by Google. It was first released in 2008 for Microsoft Windows, built with free software components from Apple WebKit and Mozilla Firefox. Versions were later released for Linux, macOS, ...
uses its own 2D library called Skia, which in turn renders through
ANGLE In Euclidean geometry, an angle is the figure formed by two rays, called the '' sides'' of the angle, sharing a common endpoint, called the ''vertex'' of the angle. Angles formed by two rays lie in the plane that contains the rays. Angles ...
on Windows.) In
Firefox Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements current ...
70.0, on old hardware, Direct2D is disabled on blacklisted old graphics drivers if they lack features and area is blacked out e.g. in
Google Maps Google Maps is a web mapping platform and consumer application offered by Google. It offers satellite imagery, aerial photography, street maps, 360° interactive panoramic views of streets (Street View), real-time traffic conditions, and rou ...
.
Ars Technica ''Ars Technica'' is a website covering news and opinions in technology, science, politics, and society, created by Ken Fisher and Jon Stokes in 1998. It publishes news, reviews, and guides on issues such as computer hardware and software, sc ...
's Peter Bright noted in the summer of 2012 that "most desktop applications don't use Direct2D."
Microsoft Office 2013 Microsoft Office 2013 (codenamed Office 15) is a version of Microsoft Office, a productivity suite for Microsoft Windows. It is the successor to Microsoft Office 2010 and the predecessor to Microsoft Office 2016. Unlike with Office 2010, no OS X ...
supports either Direct2D+DirectWrite or GDI+ Uniscribe for display rendering and typography.


See also

*
DirectX Microsoft DirectX is a collection of application programming interfaces (APIs) for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with "Direct" ...
*
Direct3D Direct3D is a graphics application programming interface (API) for Microsoft Windows. Part of DirectX, Direct3D is used to render three-dimensional graphics in applications where performance is important, such as games. Direct3D uses hardware ...
*
Cairo Cairo ( ; ar, القاهرة, al-Qāhirah, ) is the capital of Egypt and its largest city, home to 10 million people. It is also part of the largest urban agglomeration in Africa, the Arab world and the Middle East: The Greater Cairo metr ...
– a cross platform vector graphics library *
OpenVG OpenVG is an API designed for hardware-accelerated 2D vector graphics. Its primary platforms are mobile phones, gaming & media consoles and consumer electronic devices. It was designed to help manufacturers create more attractive user interfac ...
*
Simple and Fast Multimedia Library Simple and Fast Multimedia Library (SFML) is a cross-platform software development library designed to provide a simple application programming interface (API) to various multimedia components in computers. It is written in C++ with bindings a ...
* Starling Framework *
Quartz 2D Quartz 2D is the native two-dimensional graphics rendering API for macOS and iOS platforms, part of the Core Graphics framework. Overview Quartz 2D is available to all macOS and iOS application environments and provides resolution-independent an ...


References


External links


Main Direct2D page at MSDN
with links t
the programming guidenew features in Windows 8.1interoperability with Direct3D
etc.
Blog of Direct2D Lead Developer Thomas Olsen

Blog of Direct2D Developer Tom Mulcahy

Windows 7: Introducing Direct2D and DirectWrite
- PDC 2008 video
Windows API Code Pack for Microsoft .NET Framework
- allows developing Direct2D apps in managed code
Introducing Direct2D
- June 2009 issue of MSDN Magazine
Drawing with Direct2D
- September 2009 issue of MSDN Magazine
Direct2D API for Microsoft .Net Framework 4
- Direct2D API for Microsoft .Net Framework 4
USPTO application for target independent rasterization

Direct2D 1.1 Migration Guide for Windows 7 Developers
*
Charles Petzold Charles Petzold (born February 2, 1953) is an American programmer and technical author on Microsoft Windows applications. He is also a Microsoft Most Valuable Professional and was named one of Microsoft's seven Windows Pioneers. Biography He g ...
'
column on DirectX
has several articles on Direct2D ranging from introductory ones lik
Triangles and Tessellation
o
Direct2D Geometries and Their Manipulations
to more advanced ones lik
Finger Painting with Direct2D GeometriesA 2D Portal into a 3D World
etc. {{Microsoft APIs 2d Direct2D Graphics libraries