Browse Source

Fix iOS OpenGL rendering with newer Skia

pull/7565/head
Max Katz 4 years ago
parent
commit
4756a0a769
  1. 13
      src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs
  2. 18
      src/iOS/Avalonia.iOS/EaglDisplay.cs

13
src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs

@ -69,6 +69,7 @@ namespace Avalonia.Skia
gl.GetIntegerv(GL_FRAMEBUFFER_BINDING, out var fb);
var size = glSession.Size;
var colorType = SKColorType.Rgba8888;
var scaling = glSession.Scaling;
if (size.Width <= 0 || size.Height <= 0 || scaling < 0)
{
@ -81,12 +82,16 @@ namespace Avalonia.Skia
{
_grContext.ResetContext();
var renderTarget =
new GRBackendRenderTarget(size.Width, size.Height, disp.SampleCount, disp.StencilSize,
new GRGlFramebufferInfo((uint)fb, SKColorType.Rgba8888.ToGlSizedFormat()));
var samples = disp.SampleCount;
var maxSamples = _grContext.GetMaxSurfaceSampleCount(colorType);
if (samples > maxSamples)
samples = maxSamples;
var glInfo = new GRGlFramebufferInfo((uint)fb, colorType.ToGlSizedFormat());
var renderTarget = new GRBackendRenderTarget(size.Width, size.Height, samples, disp.StencilSize, glInfo);
var surface = SKSurface.Create(_grContext, renderTarget,
glSession.IsYFlipped ? GRSurfaceOrigin.TopLeft : GRSurfaceOrigin.BottomLeft,
SKColorType.Rgba8888);
colorType);
success = true;

18
src/iOS/Avalonia.iOS/EaglDisplay.cs

@ -74,7 +74,21 @@ namespace Avalonia.iOS
public GlVersion Version { get; } = new GlVersion(GlProfileType.OpenGLES, 3, 0);
public GlInterface GlInterface { get; }
public int SampleCount { get; } = 0;
public int StencilSize { get; } = 9;
public int SampleCount
{
get
{
GlInterface.GetIntegerv(GlConsts.GL_SAMPLES, out var samples);
return samples;
}
}
public int StencilSize
{
get
{
GlInterface.GetIntegerv(GlConsts.GL_STENCIL_BITS, out var stencil);
return stencil;
}
}
}
}

Loading…
Cancel
Save