Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions source/SkiaSharp.Views/SkiaSharp.Views.UWP/AngleSwapChainPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ public class AngleSwapChainPanel : SwapChainPanel

private bool enableRenderLoop;

private double lastCompositionScaleX = 0.0;
private double lastCompositionScaleY = 0.0;

private bool pendingSizeChange = false;

public AngleSwapChainPanel()
{
lastCompositionScaleX = CompositionScaleX;
lastCompositionScaleY = CompositionScaleY;

glesContext = null;

renderLoopWorker = null;
Expand Down Expand Up @@ -150,6 +156,15 @@ private static void OnVisibilityChanged(DependencyObject d, DependencyPropertyCh

private void OnCompositionChanged(SwapChainPanel sender, object args)
{
if (lastCompositionScaleX == CompositionScaleX &&
lastCompositionScaleY == CompositionScaleY)
{
return;
}

lastCompositionScaleX = CompositionScaleX;
lastCompositionScaleY = CompositionScaleY;

pendingSizeChange = true;

ContentsScale = CompositionScaleX;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml.Controls;
using System.Collections.Generic;

using SkiaSharp.Views.UWP.Interop;

Expand All @@ -14,20 +15,21 @@ namespace SkiaSharp.Views.GlesInterop
{
internal class GlesContext : IDisposable
{
private static EGLDisplay eglDisplay = Egl.EGL_NO_DISPLAY;

private bool isDisposed = false;

private EGLDisplay eglDisplay;
private EGLContext eglContext;
private EGLSurface eglSurface;
private EGLConfig eglConfig;

public GlesContext()
{
eglConfig = Egl.EGL_NO_CONFIG;
eglDisplay = Egl.EGL_NO_DISPLAY;
eglContext = Egl.EGL_NO_CONTEXT;
eglSurface = Egl.EGL_NO_SURFACE;

InitializeDisplay();
Initialize();
}

Expand Down Expand Up @@ -139,24 +141,10 @@ public void Reset()
Initialize();
}

private void Initialize()
private void InitializeDisplay()
{
int[] configAttributes = new[]
{
Egl.EGL_RED_SIZE, 8,
Egl.EGL_GREEN_SIZE, 8,
Egl.EGL_BLUE_SIZE, 8,
Egl.EGL_ALPHA_SIZE, 8,
Egl.EGL_DEPTH_SIZE, 8,
Egl.EGL_STENCIL_SIZE, 8,
Egl.EGL_NONE
};

int[] contextAttributes = new[]
{
Egl.EGL_CONTEXT_CLIENT_VERSION, 2,
Egl.EGL_NONE
};
if (eglDisplay != Egl.EGL_NO_DISPLAY)
return;

int[] defaultDisplayAttributes = new[]
{
Expand Down Expand Up @@ -242,6 +230,26 @@ private void Initialize()
}
}
}
}

public void Initialize()
{
int[] configAttributes = new[]
{
Egl.EGL_RED_SIZE, 8,
Egl.EGL_GREEN_SIZE, 8,
Egl.EGL_BLUE_SIZE, 8,
Egl.EGL_ALPHA_SIZE, 8,
Egl.EGL_DEPTH_SIZE, 8,
Egl.EGL_STENCIL_SIZE, 8,
Egl.EGL_NONE
};

int[] contextAttributes = new[]
{
Egl.EGL_CONTEXT_CLIENT_VERSION, 2,
Egl.EGL_NONE
};

EGLDisplay[] configs = new EGLDisplay[1];
if ((Egl.eglChooseConfig(eglDisplay, configAttributes, configs, configs.Length, out int numConfigs) == Egl.EGL_FALSE) || (numConfigs == 0))
Expand All @@ -264,12 +272,6 @@ private void Cleanup()
Egl.eglDestroyContext(eglDisplay, eglContext);
eglContext = Egl.EGL_NO_CONTEXT;
}

if (eglDisplay != Egl.EGL_NO_DISPLAY)
{
Egl.eglTerminate(eglDisplay);
eglDisplay = Egl.EGL_NO_DISPLAY;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected override void OnDestroyingContext()

glInfo = default;

context?.AbandonContext(true);
context?.AbandonContext(false);
context?.Dispose();
context = null;

Expand Down