3

I am evaluating SkiaSharp library (from nuget, version 1.59.3). Everything is rendered well. But it seems Skia is not using GPU for accelerated rendering. Windows 10 Task Manager doesn't detect any uses of GPU for my testing application. I am using next commands to create SKCanvas:

 using (SKBitmap bitmap = new SKBitmap(gWidth, gHeight, SKColorType.Bgra8888, alphaType))
 using (SKCanvas canvas = new SKCanvas(bitmap))
 { ... }

Does GPU acceleration requires some special way to initialize SkiaSharp ?

I have tried next command:

GRContext context = GRContext.Create(GRBackend.OpenGL);

but it returns null.

4

1 回答 1

3

啊,GPU。

您需要在现有的 OpenGL/ANGLE 上下文中。

我正在这样做: https ://github.com/mono/SkiaSharp/blob/master/source/SkiaSharp.Views/SkiaSharp.Views.UWP/SKSwapChainPanel.cs

但是,在我真正初始化 SkiaSharp 之前,我首先必须手动创建 ANGLE 上下文: https ://github.com/mono/SkiaSharp/blob/master/source/SkiaSharp.Views/SkiaSharp.Views.UWP/AngleSwapChainPanel.cs

这对所有平台都是一样的,首先设置OpenGL/ANGLE上下文,然后当是当前上下文时,启动SkiaSharp GRContext。

这也是我为单元测试所做的事情: https ://github.com/mono/SkiaSharp/blob/master/tests/Tests/GlContexts/Wgl/WglContext.cs

如果您不喜欢所有这些 setup-y 代码,这并不总是最好的代码,但您可以使用其他一些库来编写所有样板代码。只要有一个有效的 OpenGL/ANGLE 上下文,你就很好。

于 2018-02-23T03:45:53.507 回答