GlPlatformSurface.cs 972 B

123456789101112131415161718192021222324252627282930
  1. using Avalonia.OpenGL.Egl;
  2. using Avalonia.OpenGL.Surfaces;
  3. namespace Avalonia.Android.OpenGL
  4. {
  5. internal sealed class GlPlatformSurface : EglGlPlatformSurfaceBase
  6. {
  7. private readonly EglPlatformOpenGlInterface _egl;
  8. private readonly IEglWindowGlPlatformSurfaceInfo _info;
  9. private GlPlatformSurface(EglPlatformOpenGlInterface egl, IEglWindowGlPlatformSurfaceInfo info)
  10. {
  11. _egl = egl;
  12. _info = info;
  13. }
  14. public override IGlPlatformSurfaceRenderTarget CreateGlRenderTarget() =>
  15. new GlRenderTarget(_egl, _info, _egl.CreateWindowSurface(_info.Handle), _info.Handle);
  16. public static GlPlatformSurface TryCreate(IEglWindowGlPlatformSurfaceInfo info)
  17. {
  18. if (EglPlatformOpenGlInterface.TryCreate() is EglPlatformOpenGlInterface egl)
  19. {
  20. return new GlPlatformSurface(egl, info);
  21. }
  22. return null;
  23. }
  24. }
  25. }