March 28, 2023

Windows Graphics: Direct2D DirectWrite Direction Xojo Programming Blog

  • September 30, 2022
  • 8 min read

In that case, simply render a quad per segment, using 8x or 16x MSAA. Quality-wise, the results at these MSAA levels are surprisingly good. Performance-wise, modern PC-class GPUs (including thin laptops and CPU-integrated graphics in them) are usually IT consulting rates per hour 2022 Latest statistics OK at that use case even with 16x MSAA. Also I’m not sure I understand why you’re buffering anything. If you’re “reinventing the wheel”, just stick to modern techs, and stick to the GPU, forget about WM_PAINT and use Direct Composition.

It’s basically reinventing the wheel and implementing many controls found in Windows’ common controls, QT and other frameworks. The FUseD2D Boolean field is used later in the component to select either the GDI or the Direct2D canvas. The new Direct2D interfaces are supported on Windows 7 with the Platform Update for Windows 7 installed. This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

The following features and APIs were added or updated for Windows 10 Creators Update. Microsoft Office 2013 supports either Direct2D+DirectWrite or GDI+Uniscribe for display rendering and typography. The TIR feature was among those that caused a “war of words” between Nvidia and AMD around December 2012, because Nvidia’s Kepler GPU family does not support it, whereas AMD’s GCN does. The latest version of my Direct2D-based graphics library Simple2D is now available. You do not need to use any of the classes of this assembly , and should just use the UI controls from the Eto assembly.

What’s new for Windows 10 Creators Update

However, if you want to develop high-performance and high-quality commercial applications, you’ll still look to C++ and native code to deliver that power. That’s why few things excite me more about Windows 7 than the introduction of Direct2D and DirectWrite. Direct2D is a brand new 2D graphics API designed to support the most demanding and visually rich desktop applications with the best possible performance.

The brush is used to basically draw all the color information. Improves draw speed for normal WM_PAINT commands, for example, when the client area of the window is uncovered/moved/etc. GetGDICanvas is used internally to access the inherited Canvas property that returns the original GDI canvas. It also serves as a getter method for the GDICanvas property.

  • Internet Explorer 9 and later versions use Direct2D and DirectWrite for improved performance and visual quality.
  • I want to make sure I do not implement major design flaws that early in the project.
  • The FUseD2D Boolean field is used later in the component to select either the GDI or the Direct2D canvas.
  • SetAccelerated is the setter method for the Accelerated property.
  • The brush is used to basically draw all the color information.

GDI, even with the help of GDI+, had been showing its age especially when compared to the superior graphics capabilities of Windows Presentation Foundation . As if that weren’t enough, GDI lost its hardware acceleration while WPF took advantage of Direct3D’s abundance of hardware acceleration. Here is an example showing how to create a CanvasVirtualBitmap from an IWICBitmapSource starting with the IWICBitmapSource and the shared CanvasDevice.

Platform Games Part 8: Pass-through Platforms

This does not affect the behaviour or performance of regular controls, which will use the Windows Forms platform. Include this along with your Eto.Forms application to provide a WinForms interface with Direct2D drawing for your windows users. Win2D is implemented as a layer on top of Direct2D, and supports interop in both directions. If you have a Win2D object, you can access the native Direct2D object that is used to implement it. If you have a Direct2D object, you can look up the Win2D object that wraps it, or create a new wrapper if one did not already exist. This section shows how to develop a custom paint box that uses either the Direct2D or the GDI canvas.

I now have a dilemma because I want to be both fast but also not using more GDI objects than I absolutely have to. So not using a separate memory buffer is an option if the draw described above is in-fact not slow objectively. The WMSize method is used to process the WM_SIZE Windows message.

When Microsoft started pushing WPF as the “one true path” I just couldn’t persuade myself to buy the sales pitch. Remember to include the header in pch.h before any winrt headers . I want to make sure I do not implement major design flaws that early in the project. I’ve been working on a GUI toolkit for my future programming needs.

windows direct2d

Because TCustomCanvasdoes not expose a Pen property, we had to resort to object casting to access this functionality. They do not share a common ancestor; but you can assign a GDI pen to a Direct2D pen, for example. It is important to note that even though the VCL provides the necessary classes, you still need to use Direct2D interfaces to benefit How to Build a Custom Pagination Component in React from the most advanced features that make the Direct2D canvas useful. Direct2D effects is a set of APIs, new in Windows 8, for applying high quality effects to images. It also includes APIs that allow you to make your own custom effects. The command list API allows you to share the rendering path for on screen rendering and printing.

Katy’s Code

For most types GetWrappedResource can be called with only a Win2D wrapper object as parameter. For a few types it must also be passed a device and/or DPI value. It is not an error to pass a device or DPI when using GetWrappedResource with types that do not require them. The simplest case is when your lines are straight segments or polylines of them, you have decent GPU, and you don’t have weird requirements about line caps and joins.

windows direct2d

Direct2D’s semantics for devices and device contexts have been updated to more closely resemble the semantics used by Direct3D, and to provide concise operation on Windows Store apps. The following features and APIs were added or updated for Windows 8. The following features and APIs were added or updated for Windows 8.1. The following features and APIs were added or updated for Windows 10. The following features and APIs were added or updated for Windows 10 Anniversary Update.

The component, called TAcceleratedPaintBox, does not derive from Vcl.ExtCtrls.TPaintBox, because TPaintBox itself derives from TControl and not TWinControl. This is an important decision factor–controls derived from TControl do not have a Window Handle, which is required to create a dedicated Direct2D canvas. An updated version of Direct2D was launched with Windows 8 in October 2012. It was also backported to Windows 7 SP1 via the Windows 7 platform update.


It also allows you to use primitives to create an image brush for filling primitives. Big thanks to Mark Lawrence and Ben Constable, from the Direct2D team, for their feedback on the article as well as for providing a side bar discussing rendering performance. With the introduction of Windows Vista a few years ago, it was clear that the era of the Windows Graphics Device Interface was coming to an end.

Share this:

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 . It can be used effectively together with Windows Imaging Component 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 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. The issue is now that I create a separate memory DC for every control instance, which I later draw to using the code above.

Main Direct2D page at MSDN with links to the programming guide, new features in Windows 8.1, interoperability with Direct3D, etc. In Windows 8.1, 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 . Since hardware tessellation is available in base DORA Metrics: How to Measure Software Delivery Performance Direct3D11 (not necessarily 11.1), Microsoft claimed significant performance improvements with Direct2D in Windows 8.1 (vs. Windows 8) on non-TIR hardware. Direct2D is a 2D vector graphics application programming interface designed by Microsoft and implemented in Windows 10, Windows 8, Windows 7 and Windows Server 2008 R2, and also Windows Vista and Windows Server 2008 . In this issue I introduce a new technology that I’m very excited about.

Welcome to Africa Light TV 👋
It’s nice to meet you.

Sign up to Africa Light TV Daily to receive daily updates on a round-up of top stories released daily.

We don’t spam or share your info! ! Read our privacy policy for more info.

About Author

Damaris Tabe


Leave a Reply

Your email address will not be published. Required fields are marked *