diff --git a/src/Avalonia.OpenGL/EglDisplay.cs b/src/Avalonia.OpenGL/EglDisplay.cs index 20ed11d273..ea0a9bf087 100644 --- a/src/Avalonia.OpenGL/EglDisplay.cs +++ b/src/Avalonia.OpenGL/EglDisplay.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using System.Runtime.InteropServices; using Avalonia.Platform.Interop; using static Avalonia.OpenGL.EglConsts; + namespace Avalonia.OpenGL { public class EglDisplay : IGlDisplay @@ -201,6 +202,4 @@ namespace Avalonia.OpenGL } } } - - } diff --git a/src/Avalonia.OpenGL/EglGlPlatformFeature.cs b/src/Avalonia.OpenGL/EglGlPlatformFeature.cs index 13304cae14..535e32924e 100644 --- a/src/Avalonia.OpenGL/EglGlPlatformFeature.cs +++ b/src/Avalonia.OpenGL/EglGlPlatformFeature.cs @@ -3,7 +3,6 @@ using Avalonia.Logging; namespace Avalonia.OpenGL { - public class EglGlPlatformFeature : IWindowingPlatformGlFeature { public IGlDisplay Display { get; set; } diff --git a/src/Avalonia.OpenGL/EglGlPlatformSurface.cs b/src/Avalonia.OpenGL/EglGlPlatformSurface.cs index 198c7de8fd..19894e4ec5 100644 --- a/src/Avalonia.OpenGL/EglGlPlatformSurface.cs +++ b/src/Avalonia.OpenGL/EglGlPlatformSurface.cs @@ -10,13 +10,11 @@ namespace Avalonia.OpenGL // TODO: Change to PixelSize struct once https://github.com/AvaloniaUI/Avalonia/pull/1889 is merged System.Drawing.Size PixelSize { get; } double Scaling { get; } - } private readonly EglDisplay _display; private readonly IGlContext _context; private readonly IEglWindowGlPlatformSurfaceInfo _info; - public EglGlPlatformSurface(EglDisplay display, IGlContext context, IEglWindowGlPlatformSurfaceInfo info) { @@ -79,3 +77,4 @@ namespace Avalonia.OpenGL } } } + diff --git a/src/Avalonia.OpenGL/EglInterface.cs b/src/Avalonia.OpenGL/EglInterface.cs index 025281ff74..535f66ee1f 100644 --- a/src/Avalonia.OpenGL/EglInterface.cs +++ b/src/Avalonia.OpenGL/EglInterface.cs @@ -33,7 +33,6 @@ namespace Avalonia.OpenGL return (s, o) => dyn.GetProcAddress(lib, s, o); } - // ReSharper disable UnassignedGetOnlyAutoProperty public delegate IntPtr EglGetDisplay(IntPtr nativeDisplay); [EntryPoint("eglGetDisplay")] @@ -90,6 +89,5 @@ namespace Avalonia.OpenGL public EglGetConfigAttrib GetConfigAttrib { get; } // ReSharper restore UnassignedGetOnlyAutoProperty - } } diff --git a/src/Avalonia.OpenGL/GlInterface.cs b/src/Avalonia.OpenGL/GlInterface.cs index 95479d027f..60dc5381d4 100644 --- a/src/Avalonia.OpenGL/GlInterface.cs +++ b/src/Avalonia.OpenGL/GlInterface.cs @@ -9,7 +9,6 @@ namespace Avalonia.OpenGL { private readonly Func _getProcAddress; - public GlInterface(Func getProcAddress) : base(getProcAddress) { _getProcAddress = getProcAddress; @@ -44,7 +43,6 @@ namespace Avalonia.OpenGL [EntryPoint("glGetIntegerv")] public GlGetIntegerv GetIntegerv { get; } - // ReSharper restore UnassignedGetOnlyAutoProperty } } diff --git a/src/Skia/Avalonia.Skia/GlRenderTarget.cs b/src/Skia/Avalonia.Skia/GlRenderTarget.cs index 6800bfb5b2..0435e1060a 100644 --- a/src/Skia/Avalonia.Skia/GlRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/GlRenderTarget.cs @@ -5,6 +5,7 @@ using Avalonia.Platform; using Avalonia.Rendering; using SkiaSharp; using static Avalonia.OpenGL.GlConsts; + namespace Avalonia.Skia { public class GlRenderTarget : IRenderTarget @@ -26,8 +27,10 @@ namespace Avalonia.Skia var disp = session.Display; var gl = disp.GlInterface; gl.GetIntegerv(GL_FRAMEBUFFER_BINDING, out var fb); + var size = session.PixelSize; var scaling = session.Scaling; + GRBackendRenderTargetDesc desc = new GRBackendRenderTargetDesc { Width = size.Width, @@ -38,10 +41,12 @@ namespace Avalonia.Skia Origin=GRSurfaceOrigin.BottomLeft, RenderTargetHandle = new IntPtr(fb) }; + gl.Viewport(0, 0, desc.Width, desc.Height); gl.ClearStencil(0); gl.ClearColor(0, 0, 0, 0); gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + var surface = SKSurface.Create(_grContext, desc); var nfo = new DrawingContextImpl.CreateInfo @@ -52,13 +57,13 @@ namespace Avalonia.Skia VisualBrushRenderer = visualBrushRenderer, DisableTextLcdRendering = true }; + return new DrawingContextImpl(nfo, Disposable.Create(() => { surface.Canvas.Flush(); surface.Dispose(); session.Dispose(); })); - } } } diff --git a/src/Windows/Avalonia.Win32/Win32GlManager.cs b/src/Windows/Avalonia.Win32/Win32GlManager.cs index e0a96108ff..585e68056b 100644 --- a/src/Windows/Avalonia.Win32/Win32GlManager.cs +++ b/src/Windows/Avalonia.Win32/Win32GlManager.cs @@ -7,7 +7,8 @@ namespace Avalonia.Win32 /// This property is initialized if drawing platform requests OpenGL support public static EglGlPlatformFeature EglFeature { get; private set; } - private static bool s_attemptedToInitialize; + private static bool s_attemptedToInitialize; + public static void Initialize() { AvaloniaLocator.CurrentMutable.Bind().ToFunc(() =>