in source/SkiaSharp.Views/SkiaSharp.Views/Platform/Android/SKGLSurfaceViewRenderer.cs [32:87]
public void OnDrawFrame(IGL10 gl)
{
GLES20.GlClear(GLES20.GlColorBufferBit | GLES20.GlDepthBufferBit | GLES20.GlStencilBufferBit);
// create the contexts if not done already
if (context == null)
{
var glInterface = GRGlInterface.Create();
context = GRContext.CreateGl(glInterface);
}
// manage the drawing surface
if (renderTarget == null || lastSize != newSize || !renderTarget.IsValid)
{
// create or update the dimensions
lastSize = newSize;
// read the info from the buffer
var buffer = new int[3];
GLES20.GlGetIntegerv(GLES20.GlFramebufferBinding, buffer, 0);
GLES20.GlGetIntegerv(GLES20.GlStencilBits, buffer, 1);
GLES20.GlGetIntegerv(GLES20.GlSamples, buffer, 2);
var samples = buffer[2];
var maxSamples = context.GetMaxSurfaceSampleCount(colorType);
if (samples > maxSamples)
samples = maxSamples;
glInfo = new GRGlFramebufferInfo((uint)buffer[0], colorType.ToGlSizedFormat());
// destroy the old surface
surface?.Dispose();
surface = null;
canvas = null;
// re-create the render target
renderTarget?.Dispose();
renderTarget = new GRBackendRenderTarget(newSize.Width, newSize.Height, samples, buffer[1], glInfo);
}
// create the surface
if (surface == null)
{
surface = SKSurface.Create(context, renderTarget, surfaceOrigin, colorType);
canvas = surface.Canvas;
}
using (new SKAutoCanvasRestore(canvas, true))
{
// start drawing
var e = new SKPaintGLSurfaceEventArgs(surface, renderTarget, surfaceOrigin, colorType);
OnPaintSurface(e);
}
// flush the SkiaSharp contents to GL
canvas.Flush();
context.Flush();
}