From dabbd7089d67f3c0e29ab6d074dc4c1d9c057800 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Tue, 30 Mar 2021 17:30:48 +0200 Subject: [PATCH] Swap the buffers after a resize (#1668) Swap the buffers after a resize to get the current buffer to be the new, correct size. Fixes #1377, #914, #722 --- native/uwp/build.cake | 10 ++++++---- .../SkiaSharp.Views.UWP/AngleSwapChainPanel.cs | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/native/uwp/build.cake b/native/uwp/build.cake index f56fc9408..bb151ad10 100644 --- a/native/uwp/build.cake +++ b/native/uwp/build.cake @@ -114,14 +114,16 @@ Task("ANGLE") { if (Skip(arch)) return; + var d = CONFIGURATION.ToLower() == "release" ? "" : "debug/"; + RunProcess (vcpkg, $"install angle:{arch}-uwp"); var outDir = OUTPUT_PATH.Combine(arch); EnsureDirectoryExists(outDir); - CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath ($"installed/{arch}-uwp/bin/libEGL.dll"), outDir); - CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath ($"installed/{arch}-uwp/bin/libEGL.pdb"), outDir); - CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath ($"installed/{arch}-uwp/bin/libGLESv2.dll"), outDir); - CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath ($"installed/{arch}-uwp/bin/libGLESv2.pdb"), outDir); + CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath ($"installed/{arch}-uwp/{d}bin/libEGL.dll"), outDir); + CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath ($"installed/{arch}-uwp/{d}bin/libEGL.pdb"), outDir); + CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath ($"installed/{arch}-uwp/{d}bin/libGLESv2.dll"), outDir); + CopyFileToDirectory(VCPKG_PATH.CombineWithFilePath ($"installed/{arch}-uwp/{d}bin/libGLESv2.pdb"), outDir); } }); diff --git a/source/SkiaSharp.Views/SkiaSharp.Views.UWP/AngleSwapChainPanel.cs b/source/SkiaSharp.Views/SkiaSharp.Views.UWP/AngleSwapChainPanel.cs index 1afe7485d..d33a4d34e 100644 --- a/source/SkiaSharp.Views/SkiaSharp.Views.UWP/AngleSwapChainPanel.cs +++ b/source/SkiaSharp.Views/SkiaSharp.Views.UWP/AngleSwapChainPanel.cs @@ -33,6 +33,8 @@ namespace SkiaSharp.Views.UWP private bool enableRenderLoop; + private bool pendingSizeChange = false; + public AngleSwapChainPanel() { glesContext = null; @@ -148,6 +150,8 @@ namespace SkiaSharp.Views.UWP private void OnCompositionChanged(SwapChainPanel sender, object args) { + pendingSizeChange = true; + ContentsScale = CompositionScaleX; DestroyRenderSurface(); @@ -157,6 +161,8 @@ namespace SkiaSharp.Views.UWP private void OnSizeChanged(object sender, SizeChangedEventArgs e) { + pendingSizeChange = true; + EnsureRenderSurface(); Invalidate(); } @@ -189,6 +195,15 @@ namespace SkiaSharp.Views.UWP return; glesContext.MakeCurrent(); + + if (pendingSizeChange) + { + pendingSizeChange = false; + + if (!EnableRenderLoop) + glesContext.SwapBuffers(); + } + glesContext.GetSurfaceDimensions(out var panelWidth, out var panelHeight); glesContext.SetViewportSize(panelWidth, panelHeight);