Browse Source

Fix EGL surface recreation after native handle changes (#21816)

Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
pull/21852/head
AB901 2 months ago
committed by GitHub
parent
commit
06fdb648ac
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 15
      src/Avalonia.OpenGL/Egl/EglGlPlatformSurface.cs

15
src/Avalonia.OpenGL/Egl/EglGlPlatformSurface.cs

@ -40,7 +40,7 @@ namespace Avalonia.OpenGL.Egl
private EglSurface? _glSurface; private EglSurface? _glSurface;
private readonly IEglWindowGlPlatformSurfaceInfo _info; private readonly IEglWindowGlPlatformSurfaceInfo _info;
private PixelSize _currentSize; private PixelSize _currentSize;
private readonly IntPtr _handle; private IntPtr _handle;
public RenderTarget(EglSurface glSurface, EglContext context, IEglWindowGlPlatformSurfaceInfo info) : base(context) public RenderTarget(EglSurface glSurface, EglContext context, IEglWindowGlPlatformSurfaceInfo info) : base(context)
{ {
@ -58,16 +58,19 @@ namespace Avalonia.OpenGL.Egl
public override IGlPlatformSurfaceRenderingSession BeginDrawCore(IRenderTarget.RenderTargetSceneInfo sceneInfo) public override IGlPlatformSurfaceRenderingSession BeginDrawCore(IRenderTarget.RenderTargetSceneInfo sceneInfo)
{ {
// TODO: use expectedPixelSize // TODO: use expectedPixelSize
if (_info.Size != _currentSize var handle = _info.Handle;
|| _handle != _info.Handle var size = _info.Size;
if (size != _currentSize
|| _handle != handle
|| _glSurface == null) || _glSurface == null)
{ {
_glSurface?.Dispose(); _glSurface?.Dispose();
_glSurface = null; _glSurface = null;
_glSurface = Context.Display.CreateWindowSurface(_info.Handle); _glSurface = Context.Display.CreateWindowSurface(handle);
_currentSize = _info.Size; _currentSize = size;
_handle = handle;
} }
return base.BeginDraw(_glSurface, _info.Size, _info.Scaling); return base.BeginDraw(_glSurface, size, _info.Scaling);
} }
} }
} }

Loading…
Cancel
Save