skia hardware acceleration on windows

2,381 views
Skip to first unread message

blay

unread,
Aug 9, 2017, 12:44:18 PM8/9/17
to skia-discuss
Hi
I'm interested in using skia on windows. I see that the API has more than one way to create a surface. From https://skia.org/user/api/creating_skcanvas:

SkSurface::MakeRasterN32Premul for  CPU-only raster surface
SkSurface::MakeRenderTarget(context...) for a OpenGL accelerated surface

Is that the whole story? I've seen other posts that talk about use of Direct2D on windows etc. What API does the windows backend use?
Do you get some hardware acceleration without using an OpenGl context + surface?
If you do need an OpenGl context + surface, how does that relate internally to use of Direct2D.

I'm sure I've betrayed my ignorance of the Graphics stack on windows, and of this area in general by now...

But, anyway, I'm looking for a model that will help me understand whether and how to use Skia at all.
My use case is providing a new implementation of our in house drawing API (line, text and images) that is faster than GDI, looks better, and it would be good if it renders like the canvasrenderingcontext2d in Chrome.

thanks
ben

Brian Osman

unread,
Aug 9, 2017, 1:00:37 PM8/9/17
to skia-d...@googlegroups.com
Skia itself currently has three "rasterizing" backends: Software, OpenGL, and Vulkan. (There are other backends that are probably less suitable to your use-case). There is no Direct2D version of Skia - the only hardware accelerated backends are OpenGL and Vulkan. I don't actually know if anyone has tried to wire things together to share surfaces with a Direct2D application. However ... you can share surfaces with a standard OpenGL application.

Additionally, if you are using Direct3D, you may be able to integrate by using ANGLE, which acts as an OpenGL -> Direct3D translation layer on Windows. Skia is tested against ANGLE, so you may be able to construct a stack with Skia on ANGLE on Direct3D, and have your Direct3D surfaces interoperate with Direct2D content via the techniques described here: https://msdn.microsoft.com/en-us/library/windows/desktop/dd370966(v=vs.85).aspx (This is extremely uncharted territory, so tread carefully).

Another alternative (again, depending on the details of the rest of your app/stack), is to use SkiaSharp (https://developer.xamarin.com/guides/cross-platform/drawing/introduction/). This is a third party library built using Skia, but exposes most of Skia's functionality via .NET.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

blay

unread,
Aug 11, 2017, 9:29:03 AM8/11/17
to skia-discuss
Thanks for the clarification.
Although it does seem that on Windows DirectWrite is used for rendering glyphs: https://groups.google.com/forum/#!topic/skia-discuss/XlERgpCD3Uk 
I presume that the glyph rendering is independent of whether a Software or OpenGL backend is used and blitting would be different.

I found this article on CPU and GPU rendering in Chrome interesting on this area: https://software.intel.com/en-us/articles/software-vs-gpu-rasterization-in-chromium


I'm not clear whether Chrome itself uses ANGLE for OpenGL -> DirectX translation. And if so why, and what the difference is likely to be from OpenGL in appearance and speed.
In my use case rendering that is similar in appearance to the canvasrenderingcontext2d API in chrome on windows is an advantage.

thanks
ben

Brian Osman

unread,
Aug 11, 2017, 9:47:43 AM8/11/17
to skia-d...@googlegroups.com
More details:
Yes, you're write about DirectWrite and glyphs - that's used to create the glyph masks that we draw, but the actual blitting is then done with Skia's CPU or GPU backend.

Chrome on Windows does use ANGLE right now. Ultimately, the speed, reliability (and even presence) of DirectX drivers is much better than OpenGL on Windows.

Reply all
Reply to author
Forward
0 new messages