From 4ee07b73554d0aec44f789e924e2ebabc920a88a Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 29 Oct 2018 15:35:33 +0000 Subject: [PATCH 1/2] fixes/2042-opengl-using-pixelsize-struct --- src/Avalonia.OpenGL/EglGlPlatformSurface.cs | 5 ++--- src/Avalonia.OpenGL/IGlPlatformSurfaceRenderingSession.cs | 5 ++--- src/Skia/Avalonia.Skia/GlRenderTarget.cs | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.OpenGL/EglGlPlatformSurface.cs b/src/Avalonia.OpenGL/EglGlPlatformSurface.cs index 19894e4ec5..c99c869c4f 100644 --- a/src/Avalonia.OpenGL/EglGlPlatformSurface.cs +++ b/src/Avalonia.OpenGL/EglGlPlatformSurface.cs @@ -7,8 +7,7 @@ namespace Avalonia.OpenGL public interface IEglWindowGlPlatformSurfaceInfo { IntPtr Handle { get; } - // TODO: Change to PixelSize struct once https://github.com/AvaloniaUI/Avalonia/pull/1889 is merged - System.Drawing.Size PixelSize { get; } + PixelSize Size { get; } double Scaling { get; } } @@ -71,7 +70,7 @@ namespace Avalonia.OpenGL } public IGlDisplay Display => _context.Display; - public System.Drawing.Size PixelSize => _info.PixelSize; + public PixelSize Size => _info.Size; public double Scaling => _info.Scaling; } } diff --git a/src/Avalonia.OpenGL/IGlPlatformSurfaceRenderingSession.cs b/src/Avalonia.OpenGL/IGlPlatformSurfaceRenderingSession.cs index 22641d7b53..4b0de05b77 100644 --- a/src/Avalonia.OpenGL/IGlPlatformSurfaceRenderingSession.cs +++ b/src/Avalonia.OpenGL/IGlPlatformSurfaceRenderingSession.cs @@ -5,8 +5,7 @@ namespace Avalonia.OpenGL public interface IGlPlatformSurfaceRenderingSession : IDisposable { IGlDisplay Display { get; } - // TODO: Change to PixelSize struct once https://github.com/AvaloniaUI/Avalonia/pull/1889 is merged - System.Drawing.Size PixelSize { get; } + PixelSize Size { get; } double Scaling { get; } } -} \ No newline at end of file +} diff --git a/src/Skia/Avalonia.Skia/GlRenderTarget.cs b/src/Skia/Avalonia.Skia/GlRenderTarget.cs index 0435e1060a..a6269473a6 100644 --- a/src/Skia/Avalonia.Skia/GlRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/GlRenderTarget.cs @@ -28,7 +28,7 @@ namespace Avalonia.Skia var gl = disp.GlInterface; gl.GetIntegerv(GL_FRAMEBUFFER_BINDING, out var fb); - var size = session.PixelSize; + var size = session.Size; var scaling = session.Scaling; GRBackendRenderTargetDesc desc = new GRBackendRenderTargetDesc From 43f6eb52ea9eda7332e1f097b3cd1cdfb5bd3330 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 29 Oct 2018 15:44:07 +0000 Subject: [PATCH 2/2] pixel size api impl updated. --- src/Avalonia.Native/GlPlatformFeature.cs | 4 ++-- src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs | 4 ++-- src/Windows/Avalonia.Win32/WindowImpl.cs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Native/GlPlatformFeature.cs b/src/Avalonia.Native/GlPlatformFeature.cs index dbcdd244cd..97785e4a81 100644 --- a/src/Avalonia.Native/GlPlatformFeature.cs +++ b/src/Avalonia.Native/GlPlatformFeature.cs @@ -100,12 +100,12 @@ namespace Avalonia.Native public IGlDisplay Display { get; } - public System.Drawing.Size PixelSize + public PixelSize Size { get { var s = _session.GetPixelSize(); - return new System.Drawing.Size(s.Width, s.Height); + return new PixelSize(s.Width, s.Height); } } diff --git a/src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs b/src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs index 6e8cf5cb18..0273f6a7d8 100644 --- a/src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs +++ b/src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs @@ -510,12 +510,12 @@ namespace Avalonia.Gtk3 : new ImmediateRenderer(root); } - System.Drawing.Size EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.PixelSize + PixelSize EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.Size { get { var cs = ClientSize; - return new System.Drawing.Size((int)Math.Max(1, LastKnownScaleFactor * cs.Width), + return new PixelSize((int)Math.Max(1, LastKnownScaleFactor * cs.Width), (int)Math.Max(1, LastKnownScaleFactor * ClientSize.Height)); } } diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index d78c213299..21986bd2ba 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -933,14 +933,14 @@ namespace Avalonia.Win32 _topmost = value; } - - System.Drawing.Size EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.PixelSize + + PixelSize EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.Size { get { RECT rect; GetClientRect(_hwnd, out rect); - return new System.Drawing.Size( + return new PixelSize( Math.Max(1, rect.right - rect.left), Math.Max(1, rect.bottom - rect.top)); }