GPU accelerated off-screen rendering

Hi, i'm using SKGLControl to draw some graphics with GPU acceleration.

I want to draw some stuff off-screen.

I tried to create a new SKSurface with SKSurface.Create() but GPU acceleration is not working when drawing on this surface.
The same thing happens with SKCanvas(SKBitmap)

How can I create a GPU accelerated surface\canvas?

Some other questions:
Is SKGLControl cross platform? (Windows\Mac\Linux)
Does Skia\SkiaSharp supports custom GLSL shaders?

Answers

  • ppc2017ppc2017 GRMember

    I managed to create a GPU backed SKSurface with the following code

    public GRContext GetGRContext(SKGLControl control)
    {
        var field = typeof(SKGLControl).GetField("grContext", BindingFlags.NonPublic |
        BindingFlags.GetField | BindingFlags.Instance);
        return field.GetValue(control) as GRContext;
    }
    

    var gpuSurface = SKSurface.Create(GetGRContext(OpenGLControl), true, new ImageInfo(640, 480));

    Is there a better way to do this?

  • mattleibowmattleibow ZAXamarin Team Xamurai

    Hmm... I see what you are doing.

    That might be a feature that should be available as a property. I will see about getting that in. https://github.com/mono/SkiaSharp/issues/358

Sign In or Register to comment.