Win2D 1.10.0 - sprite batches, Windows.UI.Composition, CanvasVirtualBitmap, more text features, and effect rectangle mapping


Win2D version 1.10.0 is now available on NuGet (for Windows 10 or Windows / Phone 8.1) and GitHub.

This release adds new features that depend on the Windows 10 November Update, and removes workarounds for older Visual Studio versions (thanks to those who shared feedback about this).  Win2D now requires Visual Studio 2015 with Update 1 to build UWP apps:

 

Required Visual Studio version to build your app

Required operating system to run the app

Required operating system to use new APIs (such as CanvasSpriteBatch) that are marked "Win10NovUpdate"

Win2D.uwp

Visual Studio 2015 with Update 1

Any version of Windows 10

Windows 10 November Update (build 10586 or greater)

Win2D.win81

Visual Studio 2013 Update 5, or any version of Visual Studio 2015

Any version of Windows 8.1 or above

n/a

 

Sprite batches

CanvasSpriteBatch is optimized for efficiently drawing large numbers of bitmaps.  This provides several advantages over the existing DrawImage API:

  • Better performance, especially if many sprites are drawn in a row using the same source bitmap (for example when using sprite sheets).
  • Optionally sort sprites by bitmap, which can improve performance. To enable sorting, pass CanvasSpriteSortMode.Bitmap to drawingSession.CreateSpriteBatch.
  • Optional special filtering behavior avoids bleeding artifacts when using sprite sheets that do not contain gutter regions. This comes at some GPU cost, though, so it’s still better to include gutters in your sprite sheets wherever possible. To enable this mode, pass CanvasSpriteOptions.ClampToSourceRect to drawingSession.CreateSpriteBatch.
  • Individual sprites within a batch can be easily and efficiently tinted with different colors.

CanvasSpriteBatch is built on top of a new Direct2D feature which requires the Windows 10 November Update, so it will not work on older versions of Windows 10.  Use CanvasSpriteBatch.IsSupported to check if it is available on the current operating system.

The new Sprite Sheets demo (part of Example Gallery) uses CanvasSpriteBatch.  Some of you may recognize these graphics, which are borrowed from an old XNA starter kit:

 

 

Windows.UI.Composition

The Win2D CanvasComposition class supports the composition APIs that were added to Windows 10 in the November Update.  You can now use Win2D to draw onto composition drawing surfaces and swapchains.  The new CompositionExample shows this in action:

 

 

 

CanvasVirtualBitmap

CanvasVirtualBitmap can be used to load and draw images larger than the maximum bitmap size supported by the current GPU.  The implementation will automatically split up the bitmap into multiple smaller pieces, and tile its drawing operations as needed to make this work.

Virtual bitmaps are supported on any version of Windows 10 (not just the November Update) but not on Windows 8.1.

 

Text features

Added:

 

Effect rectangle mapping

Added an ICanvasEffect interface which provides per-effect control over BufferPrecision, CacheOutput, and a set of APIs for mapping rectangles between the input and output coordinate systems of an effect processing graph.


Comments (6)

  1. Maxim Kirshin says:

    Great! Thx for a job

  2. Chris says:

    Wow, this is such an essential release!  Sprite batching is critical and not much more needs to be said about it.

    CanvasVirtualBitmap will be endlessly convenient and the effect stuff should be handy for optimization.

    I'm a bit blurry on what kind of scenarios CanvasComposition would be used in.  From what I remember, UWP XAML UI uses Win2D for composition, but doesn't make use of every feature of Win2D.  If you're doing games with the CanvasAnimated control, is there any reason to use a CanvasSwapChain from the composition API, or to use CanvasComposition for UI above the CanvasAnimated control?

  3. > I'm a bit blurry on what kind of scenarios CanvasComposition would be used in.

    Windows.UI.Composition offers a middle ground in between XAML and CoreWindow, for those who want something lower level and less intrusive than a complete UI framework, but more than the "do it all yourself" of a pure CoreWindow app.

  4. Francesco says:

    Very very very happy for the spriteBatch! Thanks for you work!

  5. Chris says:

    I'm curious if in order to support continuum I'll need to do anything special with resource loading in Win2D?  Does the switch between phone display and external display just manifest itself as a resize request and everything else is taken care of automatically?  I don't have a continuum capable device to test on, so I'm just hoping that I can do things now which might avoid issues in the future.

  6. Andy says:

    Great work with the spritesheets. I just wrote a little texturepacker parser with support for sequences. Now I'm just lost getting things animated... bit offtopic here: How would you animate the movemeont of the sprites... all the way down calculating everything myself (including easings etc) or could we just use storyboards? Also I'm curious if there's the possibility to animate a sprite/canvasimage on a path (since you clearly have some great path tools in win2d too).

Skip to main content