Win2D integration with Windows 10


One of the unique challenges with Win2D being an open source project is how to make it integrate nicely with other Windows features that are being developed in a more traditional manner.

APIs that are built in to the Windows platform cannot take a dependency on external projects like Win2D – that would be upside down and would make it impossible to build Windows itself!  And the other way around, Win2D cannot take a dependency on new platform APIs that are added in Windows 10, because we want to keep Win2D running on 8.1 as well.

 And yet, we want Win2D to play nice with exciting new features like video editing and composition that our colleagues are so hard at work developing…

 I think the solution we came up is working pretty well:

  • For each place we want Win2D to integrate with a new Windows 10 feature, identify the minimal set of interfaces needed to make that possible, and bake these interfaces into the Windows 10 platform.
  • Built-in operating system features can now use these interfaces without having to depend directly on Win2D, GitHub, or NuGet.
  • The Win10 version of Win2D implements the interfaces provided by the OS, so it can seamlessly integrate with any other APIs that also use them.
  • In order to run Win2D on Windows 8.1, where the interop interfaces were not yet available, the 8.1 version of Win2D must provide its own local version of these interfaces.  The local versions have the same names and methods as the built-in Win10 versions, but are in a different namespace and use different interface GUIDs.  This allows us to build the 8.1 and 10 flavors of Win2D from almost identical source code, merely changing a few using statements to pull in the right interfaces.

 When you move from 8.1 to Win10, you will notice that some interfaces which used to be part of Win2D are now part of Windows itself, and as a result have moved to different namespaces:

 

Win2D 8.1 version

Version built-in to Windows 10

Microsoft.Graphics.Canvas.DirectX.*
Microsoft.Graphics.Canvas.DirectX.Direct3D11.*

Windows.Graphics.DirectX.*
Windows.Graphics.DirectX.Direct3D11.*

Microsoft.Graphics.Canvas.Effects.IGraphicsEffect
Microsoft.Graphics.Canvas.Effects.IGraphicsEffectSource

Windows.Graphics.Effects.IGraphicsEffect
Windows.Graphics.Effects.IGraphicsEffectSource

Microsoft.Graphics.Canvas.Numerics.*

Windows.Foundation.Numerics.*

 

The DirectX.* types are used by the new Win10 video editing APIs (among others).  To see this in action, check out BasicVideoEffectExample and CameraEffectExample in the UAP version of Win2D Example Gallery, which show just how easy it is to do cool stuff when combining Win2D image effects with APIs such as VideoFrame and IBasicVideoEffect:

               

 

IGraphicsEffect is used by Windows.UI.Composition, which can apply Win2D effects (eg. SaturationEffect) directly to a composition visual.

Stay tuned for more info about the numerics types…


Comments (0)

Skip to main content