Merge multiple interfaces related to rendering (#20557)

* Merge ISkiaGpuWithPlatformGraphicsContext into ISkiaGpu

* Merge ISkiaGpuRenderTarget2 into ISkiaGpuRenderTarget

* Merge IRenderTarget2 into IRenderTarget

* Update API suppressions

* Update API suppressions
This commit is contained in:
Julien Lebosquain
2026-02-09 08:20:22 +00:00
committed by GitHub
parent 61f8103726
commit 7d0c2264f5
29 changed files with 348 additions and 125 deletions
+72
View File
@@ -1,6 +1,78 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids --> <!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Skia.ISkiaGpuRenderTarget2</Target>
<Left>baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Left>
<Right>current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Skia.ISkiaGpuWithPlatformGraphicsContext</Target>
<Left>baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Left>
<Right>current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Skia.ISkiaGpuRenderTarget2</Target>
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left>
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Skia.ISkiaGpuWithPlatformGraphicsContext</Target>
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left>
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Avalonia.Skia.ISkiaGpuRenderTarget.BeginRenderingSession</Target>
<Left>baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Left>
<Right>current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Avalonia.Skia.ISkiaGpuRenderTarget.BeginRenderingSession</Target>
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left>
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>M:Avalonia.Skia.ISkiaGpu.TryGetGrContext</Target>
<Left>baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Left>
<Right>current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>M:Avalonia.Skia.ISkiaGpuRenderTarget.BeginRenderingSession(System.Nullable{Avalonia.PixelSize})</Target>
<Left>baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Left>
<Right>current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>P:Avalonia.Skia.ISkiaGpu.PlatformGraphicsContext</Target>
<Left>baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Left>
<Right>current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>M:Avalonia.Skia.ISkiaGpu.TryGetGrContext</Target>
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left>
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>M:Avalonia.Skia.ISkiaGpuRenderTarget.BeginRenderingSession(System.Nullable{Avalonia.PixelSize})</Target>
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left>
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>P:Avalonia.Skia.ISkiaGpu.PlatformGraphicsContext</Target>
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left>
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0008</DiagnosticId> <DiagnosticId>CP0008</DiagnosticId>
<Target>T:Avalonia.Skia.ISkiaGpu</Target> <Target>T:Avalonia.Skia.ISkiaGpu</Target>
+156
View File
@@ -79,6 +79,18 @@
<Left>baseline/Avalonia/lib/net10.0/Avalonia.Base.dll</Left> <Left>baseline/Avalonia/lib/net10.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.Base.dll</Right> <Right>current/Avalonia/lib/net10.0/Avalonia.Base.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Platform.IRenderTarget2</Target>
<Left>baseline/Avalonia/lib/net10.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Platform.IRenderTargetWithProperties</Target>
<Left>baseline/Avalonia/lib/net10.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0001</DiagnosticId> <DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Platform.OptionalFeatureProviderExtensions</Target> <Target>T:Avalonia.Platform.OptionalFeatureProviderExtensions</Target>
@@ -199,6 +211,18 @@
<Left>baseline/Avalonia/lib/net10.0/Avalonia.Markup.Xaml.dll</Left> <Left>baseline/Avalonia/lib/net10.0/Avalonia.Markup.Xaml.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.Markup.Xaml.dll</Right> <Right>current/Avalonia/lib/net10.0/Avalonia.Markup.Xaml.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.OpenGL.Surfaces.IGlPlatformSurfaceRenderTarget2</Target>
<Left>baseline/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.OpenGL.Surfaces.IGlPlatformSurfaceRenderTargetWithCorruptionInfo</Target>
<Left>baseline/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0001</DiagnosticId> <DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Media.Fonts.FontFamilyLoader</Target> <Target>T:Avalonia.Media.Fonts.FontFamilyLoader</Target>
@@ -283,6 +307,18 @@
<Left>baseline/Avalonia/lib/net8.0/Avalonia.Base.dll</Left> <Left>baseline/Avalonia/lib/net8.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.Base.dll</Right> <Right>current/Avalonia/lib/net8.0/Avalonia.Base.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Platform.IRenderTarget2</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Platform.IRenderTargetWithProperties</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0001</DiagnosticId> <DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Platform.OptionalFeatureProviderExtensions</Target> <Target>T:Avalonia.Platform.OptionalFeatureProviderExtensions</Target>
@@ -403,6 +439,18 @@
<Left>baseline/Avalonia/lib/net8.0/Avalonia.Markup.Xaml.dll</Left> <Left>baseline/Avalonia/lib/net8.0/Avalonia.Markup.Xaml.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.Markup.Xaml.dll</Right> <Right>current/Avalonia/lib/net8.0/Avalonia.Markup.Xaml.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.OpenGL.Surfaces.IGlPlatformSurfaceRenderTarget2</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.OpenGL.Surfaces.IGlPlatformSurfaceRenderTargetWithCorruptionInfo</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0001</DiagnosticId> <DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Media.Fonts.FontFamilyLoader</Target> <Target>T:Avalonia.Media.Fonts.FontFamilyLoader</Target>
@@ -1261,6 +1309,24 @@
<Left>baseline/Avalonia/lib/net10.0/Avalonia.Markup.Xaml.dll</Left> <Left>baseline/Avalonia/lib/net10.0/Avalonia.Markup.Xaml.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.Markup.Xaml.dll</Right> <Right>current/Avalonia/lib/net10.0/Avalonia.Markup.Xaml.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Avalonia.OpenGL.Egl.EglPlatformSurfaceRenderTargetBase.BeginDraw</Target>
<Left>baseline/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Avalonia.OpenGL.Egl.EglPlatformSurfaceRenderTargetBase.BeginDrawCore</Target>
<Left>baseline/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Avalonia.OpenGL.Surfaces.IGlPlatformSurfaceRenderTarget.BeginDraw</Target>
<Left>baseline/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0002</DiagnosticId> <DiagnosticId>CP0002</DiagnosticId>
<Target>F:Avalonia.Media.Fonts.FontCollectionBase._glyphTypefaceCache</Target> <Target>F:Avalonia.Media.Fonts.FontCollectionBase._glyphTypefaceCache</Target>
@@ -2149,6 +2215,24 @@
<Left>baseline/Avalonia/lib/net8.0/Avalonia.Markup.Xaml.dll</Left> <Left>baseline/Avalonia/lib/net8.0/Avalonia.Markup.Xaml.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.Markup.Xaml.dll</Right> <Right>current/Avalonia/lib/net8.0/Avalonia.Markup.Xaml.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Avalonia.OpenGL.Egl.EglPlatformSurfaceRenderTargetBase.BeginDraw</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Avalonia.OpenGL.Egl.EglPlatformSurfaceRenderTargetBase.BeginDrawCore</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Avalonia.OpenGL.Surfaces.IGlPlatformSurfaceRenderTarget.BeginDraw</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0002</DiagnosticId> <DiagnosticId>CP0002</DiagnosticId>
<Target>F:Avalonia.Media.Fonts.FontCollectionBase._glyphTypefaceCache</Target> <Target>F:Avalonia.Media.Fonts.FontCollectionBase._glyphTypefaceCache</Target>
@@ -2191,6 +2275,18 @@
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left> <Left>baseline/netstandard2.0/Avalonia.Base.dll</Left>
<Right>target/netstandard2.0/Avalonia.Base.dll</Right> <Right>target/netstandard2.0/Avalonia.Base.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0005</DiagnosticId>
<Target>M:Avalonia.OpenGL.Egl.EglPlatformSurfaceRenderTargetBase.BeginDrawCore(System.Nullable{Avalonia.PixelSize})</Target>
<Left>baseline/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0005</DiagnosticId>
<Target>M:Avalonia.OpenGL.Egl.EglPlatformSurfaceRenderTargetBase.BeginDrawCore(System.Nullable{Avalonia.PixelSize})</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0006</DiagnosticId> <DiagnosticId>CP0006</DiagnosticId>
<Target>M:Avalonia.Input.IKeyboardNavigationHandler.Move(Avalonia.Input.IInputElement,Avalonia.Input.NavigationDirection,Avalonia.Input.KeyModifiers,System.Nullable{Avalonia.Input.KeyDeviceType})</Target> <Target>M:Avalonia.Input.IKeyboardNavigationHandler.Move(Avalonia.Input.IInputElement,Avalonia.Input.NavigationDirection,Avalonia.Input.KeyModifiers,System.Nullable{Avalonia.Input.KeyDeviceType})</Target>
@@ -2251,6 +2347,12 @@
<Left>baseline/Avalonia/lib/net10.0/Avalonia.Base.dll</Left> <Left>baseline/Avalonia/lib/net10.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.Base.dll</Right> <Right>current/Avalonia/lib/net10.0/Avalonia.Base.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>M:Avalonia.Platform.IRenderTarget.CreateDrawingContext(Avalonia.PixelSize,Avalonia.Platform.RenderTargetDrawingContextProperties@)</Target>
<Left>baseline/Avalonia/lib/net10.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0006</DiagnosticId> <DiagnosticId>CP0006</DiagnosticId>
<Target>P:Avalonia.Platform.ILockedFramebuffer.AlphaFormat</Target> <Target>P:Avalonia.Platform.ILockedFramebuffer.AlphaFormat</Target>
@@ -2269,6 +2371,24 @@
<Left>baseline/Avalonia/lib/net10.0/Avalonia.Base.dll</Left> <Left>baseline/Avalonia/lib/net10.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.Base.dll</Right> <Right>current/Avalonia/lib/net10.0/Avalonia.Base.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>P:Avalonia.Platform.IRenderTarget.Properties</Target>
<Left>baseline/Avalonia/lib/net10.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>M:Avalonia.OpenGL.Surfaces.IGlPlatformSurfaceRenderTarget.BeginDraw(System.Nullable{Avalonia.PixelSize})</Target>
<Left>baseline/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>P:Avalonia.OpenGL.Surfaces.IGlPlatformSurfaceRenderTarget.IsCorrupted</Target>
<Left>baseline/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0006</DiagnosticId> <DiagnosticId>CP0006</DiagnosticId>
<Target>M:Avalonia.Input.Platform.IClipboard.SetDataAsync(Avalonia.Input.IAsyncDataTransfer)</Target> <Target>M:Avalonia.Input.Platform.IClipboard.SetDataAsync(Avalonia.Input.IAsyncDataTransfer)</Target>
@@ -2419,6 +2539,12 @@
<Left>baseline/Avalonia/lib/net8.0/Avalonia.Base.dll</Left> <Left>baseline/Avalonia/lib/net8.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.Base.dll</Right> <Right>current/Avalonia/lib/net8.0/Avalonia.Base.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>M:Avalonia.Platform.IRenderTarget.CreateDrawingContext(Avalonia.PixelSize,Avalonia.Platform.RenderTargetDrawingContextProperties@)</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0006</DiagnosticId> <DiagnosticId>CP0006</DiagnosticId>
<Target>M:Avalonia.Platform.Storage.IStorageProvider.SaveFilePickerWithResultAsync(Avalonia.Platform.Storage.FilePickerSaveOptions)</Target> <Target>M:Avalonia.Platform.Storage.IStorageProvider.SaveFilePickerWithResultAsync(Avalonia.Platform.Storage.FilePickerSaveOptions)</Target>
@@ -2443,6 +2569,12 @@
<Left>baseline/Avalonia/lib/net8.0/Avalonia.Base.dll</Left> <Left>baseline/Avalonia/lib/net8.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.Base.dll</Right> <Right>current/Avalonia/lib/net8.0/Avalonia.Base.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>P:Avalonia.Platform.IRenderTarget.Properties</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.Base.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0006</DiagnosticId> <DiagnosticId>CP0006</DiagnosticId>
<Target>M:Avalonia.OpenGL.IGlExternalSemaphore.SignalTimelineSemaphore(Avalonia.OpenGL.IGlExternalImageTexture,System.UInt64)</Target> <Target>M:Avalonia.OpenGL.IGlExternalSemaphore.SignalTimelineSemaphore(Avalonia.OpenGL.IGlExternalImageTexture,System.UInt64)</Target>
@@ -2455,12 +2587,24 @@
<Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left> <Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right> <Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>M:Avalonia.OpenGL.Surfaces.IGlPlatformSurfaceRenderTarget.BeginDraw(System.Nullable{Avalonia.PixelSize})</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0006</DiagnosticId> <DiagnosticId>CP0006</DiagnosticId>
<Target>P:Avalonia.OpenGL.IGlExternalImageTexture.TextureType</Target> <Target>P:Avalonia.OpenGL.IGlExternalImageTexture.TextureType</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left> <Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right> <Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>P:Avalonia.OpenGL.Surfaces.IGlPlatformSurfaceRenderTarget.IsCorrupted</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0006</DiagnosticId> <DiagnosticId>CP0006</DiagnosticId>
<Target>M:Avalonia.Input.Platform.IClipboard.SetDataAsync(Avalonia.Input.IAsyncDataTransfer)</Target> <Target>M:Avalonia.Input.Platform.IClipboard.SetDataAsync(Avalonia.Input.IAsyncDataTransfer)</Target>
@@ -2629,6 +2773,12 @@
<Left>baseline/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Left> <Left>baseline/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Right> <Right>current/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Avalonia.OpenGL.Egl.EglPlatformSurfaceRenderTargetBase</Target>
<Left>baseline/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net10.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0008</DiagnosticId> <DiagnosticId>CP0008</DiagnosticId>
<Target>T:Avalonia.OpenGL.IGlContext</Target> <Target>T:Avalonia.OpenGL.IGlContext</Target>
@@ -2743,6 +2893,12 @@
<Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left> <Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right> <Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right>
</Suppression> </Suppression>
<Suppression>
<DiagnosticId>CP0008</DiagnosticId>
<Target>T:Avalonia.OpenGL.Egl.EglPlatformSurfaceRenderTargetBase</Target>
<Left>baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Left>
<Right>current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll</Right>
</Suppression>
<Suppression> <Suppression>
<DiagnosticId>CP0008</DiagnosticId> <DiagnosticId>CP0008</DiagnosticId>
<Target>T:Avalonia.OpenGL.IGlContext</Target> <Target>T:Avalonia.OpenGL.IGlContext</Target>
+12 -35
View File
@@ -1,6 +1,5 @@
using System; using System;
using Avalonia.Metadata; using Avalonia.Metadata;
using Avalonia.Rendering;
namespace Avalonia.Platform namespace Avalonia.Platform
{ {
@@ -13,51 +12,29 @@ namespace Avalonia.Platform
[PrivateApi] [PrivateApi]
public interface IRenderTarget : IDisposable public interface IRenderTarget : IDisposable
{ {
/// <summary>
/// Indicates if the render target is no longer usable and needs to be recreated
/// </summary>
bool IsCorrupted { get; }
/// <summary>
/// Gets the properties of the render target.
/// </summary>
RenderTargetProperties Properties { get; }
/// <summary> /// <summary>
/// Creates an <see cref="IDrawingContextImpl"/> for a rendering session. /// Creates an <see cref="IDrawingContextImpl"/> for a rendering session.
/// </summary> /// </summary>
/// <param name="useScaledDrawing">Apply DPI reported by the render target as a hidden transform matrix</param> /// <param name="useScaledDrawing">Apply DPI reported by the render target as a hidden transform matrix</param>
IDrawingContextImpl CreateDrawingContext(bool useScaledDrawing); IDrawingContextImpl CreateDrawingContext(bool useScaledDrawing);
/// <summary>
/// Indicates if the render target is no longer usable and needs to be recreated
/// </summary>
public bool IsCorrupted { get; }
}
[PrivateApi, Obsolete("Use IRenderTarget2", true)]
// TODO12: Remove
public interface IRenderTargetWithProperties : IRenderTarget
{
RenderTargetProperties Properties { get; }
}
[PrivateApi]
// TODO12: Merge into IRenderTarget
public interface IRenderTarget2 : IRenderTarget
{
RenderTargetProperties Properties { get; }
/// <summary> /// <summary>
/// Creates an <see cref="IDrawingContextImpl"/> for a rendering session. /// Creates an <see cref="IDrawingContextImpl"/> for a rendering session.
/// </summary> /// </summary>
/// <param name="expectedPixelSize">The pixel size of the surface</param> /// <param name="expectedPixelSize">The pixel size of the surface</param>
/// <param name="properties">Returns various properties about the returned drawing context</param> /// <param name="properties">Returns various properties about the returned drawing context</param>
IDrawingContextImpl CreateDrawingContext(PixelSize expectedPixelSize, IDrawingContextImpl CreateDrawingContext(
PixelSize expectedPixelSize,
out RenderTargetDrawingContextProperties properties); out RenderTargetDrawingContextProperties properties);
} }
internal static class RenderTargetExtensions
{
public static IDrawingContextImpl CreateDrawingContextWithProperties(
this IRenderTarget renderTarget,
PixelSize expectedPixelSize,
out RenderTargetDrawingContextProperties properties)
{
if (renderTarget is IRenderTarget2 target)
return target.CreateDrawingContext(expectedPixelSize, out properties);
properties = default;
return renderTarget.CreateDrawingContext(false);
}
}
} }
@@ -160,16 +160,13 @@ namespace Avalonia.Rendering.Composition.Server
if (!_redrawRequested) if (!_redrawRequested)
return; return;
var renderTargetWithProperties = _renderTarget as IRenderTarget2;
var needLayer = _overlays.RequireLayer // Check if we don't need overlays var needLayer = _overlays.RequireLayer // Check if we don't need overlays
// Check if render target can be rendered to directly and preserves the previous frame // Check if render target can be rendered to directly and preserves the previous frame
|| !(renderTargetWithProperties?.Properties.RetainsPreviousFrameContents == true || !(_renderTarget.Properties.RetainsPreviousFrameContents
&& renderTargetWithProperties?.Properties.IsSuitableForDirectRendering == true); && _renderTarget.Properties.IsSuitableForDirectRendering);
using (var renderTargetContext = _renderTarget.CreateDrawingContextWithProperties( using (var renderTargetContext = _renderTarget.CreateDrawingContext(
this.PixelSize, out var properties)) this.PixelSize, out var properties))
using (var renderTiming = Diagnostic.BeginCompositorRenderPass()) using (var renderTiming = Diagnostic.BeginCompositorRenderPass())
{ {
@@ -173,8 +173,11 @@ namespace Avalonia.Native
_context = context; _context = context;
} }
public IGlPlatformSurfaceRenderingSession BeginDraw() public bool IsCorrupted => false;
public IGlPlatformSurfaceRenderingSession BeginDraw(PixelSize? expectedPixelSize)
{ {
// TODO: use expectedPixelSize
ObjectDisposedException.ThrowIf(_target is null, this); ObjectDisposedException.ThrowIf(_target is null, this);
return new GlPlatformSurfaceRenderingSession(_context, _target.BeginDrawing()); return new GlPlatformSurfaceRenderingSession(_context, _target.BeginDrawing());
} }
@@ -54,8 +54,9 @@ namespace Avalonia.OpenGL.Egl
public override void Dispose() => _glSurface?.Dispose(); public override void Dispose() => _glSurface?.Dispose();
public override IGlPlatformSurfaceRenderingSession BeginDrawCore() public override IGlPlatformSurfaceRenderingSession BeginDrawCore(PixelSize? expectedPixelSize)
{ {
// TODO: use expectedPixelSize
if (_info.Size != _currentSize if (_info.Size != _currentSize
|| _handle != _info.Handle || _handle != _info.Handle
|| _glSurface == null) || _glSurface == null)
@@ -8,7 +8,7 @@ namespace Avalonia.OpenGL.Egl
public abstract IGlPlatformSurfaceRenderTarget CreateGlRenderTarget(IGlContext context); public abstract IGlPlatformSurfaceRenderTarget CreateGlRenderTarget(IGlContext context);
} }
public abstract class EglPlatformSurfaceRenderTargetBase : IGlPlatformSurfaceRenderTargetWithCorruptionInfo public abstract class EglPlatformSurfaceRenderTargetBase : IGlPlatformSurfaceRenderTarget
{ {
protected EglContext Context { get; } protected EglContext Context { get; }
@@ -22,17 +22,17 @@ namespace Avalonia.OpenGL.Egl
} }
public IGlPlatformSurfaceRenderingSession BeginDraw() public IGlPlatformSurfaceRenderingSession BeginDraw(PixelSize? expectedPixelSize)
{ {
if (Context.IsLost) if (Context.IsLost)
throw new RenderTargetCorruptedException(); throw new RenderTargetCorruptedException();
return BeginDrawCore(); return BeginDrawCore(expectedPixelSize);
} }
private protected virtual bool SkipWaits => false; private protected virtual bool SkipWaits => false;
public abstract IGlPlatformSurfaceRenderingSession BeginDrawCore(); public abstract IGlPlatformSurfaceRenderingSession BeginDrawCore(PixelSize? expectedPixelSize);
protected IGlPlatformSurfaceRenderingSession BeginDraw(EglSurface surface, protected IGlPlatformSurfaceRenderingSession BeginDraw(EglSurface surface,
PixelSize size, double scaling, Action? onFinish = null, bool isYFlipped = false) PixelSize size, double scaling, Action? onFinish = null, bool isYFlipped = false)
@@ -1,22 +1,11 @@
using System; using System;
using Avalonia.Metadata;
namespace Avalonia.OpenGL.Surfaces namespace Avalonia.OpenGL.Surfaces
{ {
public interface IGlPlatformSurfaceRenderTarget : IDisposable public interface IGlPlatformSurfaceRenderTarget : IDisposable
{
IGlPlatformSurfaceRenderingSession BeginDraw();
}
public interface IGlPlatformSurfaceRenderTargetWithCorruptionInfo : IGlPlatformSurfaceRenderTarget
{ {
bool IsCorrupted { get; } bool IsCorrupted { get; }
}
[PrivateApi] IGlPlatformSurfaceRenderingSession BeginDraw(PixelSize? expectedPixelSize);
public interface IGlPlatformSurfaceRenderTarget2 : IGlPlatformSurfaceRenderTargetWithCorruptionInfo
{
IGlPlatformSurfaceRenderingSession BeginDraw(PixelSize expectedPixelSize);
} }
} }
+3 -4
View File
@@ -21,7 +21,7 @@ namespace Avalonia.X11.Glx
return new RenderTarget((GlxContext)context, _info); return new RenderTarget((GlxContext)context, _info);
} }
private class RenderTarget : IGlPlatformSurfaceRenderTarget2 private class RenderTarget : IGlPlatformSurfaceRenderTarget
{ {
private readonly GlxContext _context; private readonly GlxContext _context;
private readonly EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo _info; private readonly EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo _info;
@@ -39,9 +39,8 @@ namespace Avalonia.X11.Glx
} }
public bool IsCorrupted => false; public bool IsCorrupted => false;
public IGlPlatformSurfaceRenderingSession BeginDraw(PixelSize size) => BeginDrawCore(size);
public IGlPlatformSurfaceRenderingSession BeginDraw() => BeginDrawCore(null); public IGlPlatformSurfaceRenderingSession BeginDraw(PixelSize? expectedSize)
public IGlPlatformSurfaceRenderingSession BeginDrawCore(PixelSize? expectedSize)
{ {
var size = expectedSize ?? _info.Size; var size = expectedSize ?? _info.Size;
if (expectedSize.HasValue) if (expectedSize.HasValue)
@@ -65,14 +65,17 @@ partial class BrowserWebGlRenderTarget : BrowserRenderTarget, IGlPlatformSurface
{ {
_target = target; _target = target;
} }
public bool IsCorrupted => false;
public void Dispose() public void Dispose()
{ {
// No-op // No-op
} }
public IGlPlatformSurfaceRenderingSession BeginDraw() public IGlPlatformSurfaceRenderingSession BeginDraw(PixelSize? expectedPixelSize)
{ {
// TODO: use expectedPixelSize
var s = _target._sizeGetter(); var s = _target._sizeGetter();
_target.UpdateSize(s.Size); _target.UpdateSize(s.Size);
var restoreContext = _target.GlContext.EnsureCurrent(); var restoreContext = _target.GlContext.EnsureCurrent();
@@ -400,11 +400,20 @@ namespace Avalonia.Headless
} }
public IDrawingContextImpl CreateDrawingContext(bool _) public IDrawingContextImpl CreateDrawingContext(bool useScaledDrawing)
{ {
return new HeadlessDrawingContextStub(); return new HeadlessDrawingContextStub();
} }
public IDrawingContextImpl CreateDrawingContext(PixelSize expectedPixelSize,
out RenderTargetDrawingContextProperties properties)
{
properties = default;
return new HeadlessDrawingContextStub();
}
public RenderTargetProperties Properties => default;
public bool IsCorrupted => false; public bool IsCorrupted => false;
public void Blit(IDrawingContextImpl context) public void Blit(IDrawingContextImpl context)
@@ -582,16 +591,25 @@ namespace Avalonia.Headless
private class HeadlessRenderTarget : IRenderTarget private class HeadlessRenderTarget : IRenderTarget
{ {
public RenderTargetProperties Properties => default;
public void Dispose() public void Dispose()
{ {
} }
public IDrawingContextImpl CreateDrawingContext(bool _) public IDrawingContextImpl CreateDrawingContext(bool useScaledDrawing)
{ {
return new HeadlessDrawingContextStub(); return new HeadlessDrawingContextStub();
} }
public IDrawingContextImpl CreateDrawingContext(PixelSize expectedPixelSize,
out RenderTargetDrawingContextProperties properties)
{
properties = default;
return new HeadlessDrawingContextStub();
}
public bool IsCorrupted => false; public bool IsCorrupted => false;
} }
@@ -377,7 +377,7 @@ namespace Avalonia.LinuxFramebuffer.Output
{ {
//Go through two cycles of buffer swapping (there are render artifacts otherwise) //Go through two cycles of buffer swapping (there are render artifacts otherwise)
for (var c = 0; c < 2; c++) for (var c = 0; c < 2; c++)
using (CreateGlRenderTarget().BeginDraw()) using (CreateGlRenderTarget().BeginDraw(PixelSize))
{ {
_deferredContext.GlInterface.ClearColor(initialBufferSwappingColorR, initialBufferSwappingColorG, _deferredContext.GlInterface.ClearColor(initialBufferSwappingColorR, initialBufferSwappingColorG,
initialBufferSwappingColorB, initialBufferSwappingColorA); initialBufferSwappingColorB, initialBufferSwappingColorA);
@@ -406,6 +406,9 @@ namespace Avalonia.LinuxFramebuffer.Output
{ {
_parent = parent; _parent = parent;
} }
public bool IsCorrupted => false;
public void Dispose() public void Dispose()
{ {
// We are wrapping GBM buffer chain associated with CRTC, and don't free it on a whim // We are wrapping GBM buffer chain associated with CRTC, and don't free it on a whim
@@ -508,7 +511,7 @@ namespace Avalonia.LinuxFramebuffer.Output
public bool IsYFlipped => false; public bool IsYFlipped => false;
} }
public IGlPlatformSurfaceRenderingSession BeginDraw() public IGlPlatformSurfaceRenderingSession BeginDraw(PixelSize? expectedPixelSize)
{ {
var clearContext = _parent._deferredContext.MakeCurrent(_parent._eglSurface); var clearContext = _parent._deferredContext.MakeCurrent(_parent._eglSurface);
var gl = _parent._deferredContext.GlInterface; var gl = _parent._deferredContext.GlInterface;
+1 -2
View File
@@ -170,8 +170,7 @@ namespace Avalonia.Skia
public ISkiaSharpPlatformGraphicsApiLease? TryLeasePlatformGraphicsApi() public ISkiaSharpPlatformGraphicsApiLease? TryLeasePlatformGraphicsApi()
{ {
CheckLease(); CheckLease();
if (_context._gpu is ISkiaGpuWithPlatformGraphicsContext gpu && if (_context._gpu?.PlatformGraphicsContext is { } context)
gpu.PlatformGraphicsContext is { } context)
return new PlatformApiLease(this, context); return new PlatformApiLease(this, context);
return null; return null;
} }
@@ -10,7 +10,7 @@ namespace Avalonia.Skia
/// <summary> /// <summary>
/// Skia render target that renders to a framebuffer surface. No gpu acceleration available. /// Skia render target that renders to a framebuffer surface. No gpu acceleration available.
/// </summary> /// </summary>
internal class FramebufferRenderTarget : IRenderTarget2 internal class FramebufferRenderTarget : IRenderTarget
{ {
private SKImageInfo _currentImageInfo; private SKImageInfo _currentImageInfo;
private IntPtr _currentFramebufferAddress; private IntPtr _currentFramebufferAddress;
+9 -7
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Avalonia.Metadata;
using Avalonia.Platform; using Avalonia.Platform;
using SkiaSharp; using SkiaSharp;
@@ -13,6 +12,11 @@ namespace Avalonia.Skia
/// </summary> /// </summary>
public interface ISkiaGpu : IPlatformGraphicsContext public interface ISkiaGpu : IPlatformGraphicsContext
{ {
/// <summary>
/// Gets the platform graphics context.
/// </summary>
IPlatformGraphicsContext? PlatformGraphicsContext { get; }
/// <summary> /// <summary>
/// Attempts to create custom render target from given surfaces. /// Attempts to create custom render target from given surfaces.
/// </summary> /// </summary>
@@ -26,13 +30,11 @@ namespace Avalonia.Skia
/// <param name="size">size in pixels.</param> /// <param name="size">size in pixels.</param>
/// <param name="session">An optional custom render session.</param> /// <param name="session">An optional custom render session.</param>
ISkiaSurface? TryCreateSurface(PixelSize size, ISkiaGpuRenderSession? session); ISkiaSurface? TryCreateSurface(PixelSize size, ISkiaGpuRenderSession? session);
}
//TODO12: Merge into ISkiaGpu /// <summary>
[Unstable] /// Tries to get a <see cref="GRContext"/>.
public interface ISkiaGpuWithPlatformGraphicsContext : ISkiaGpu /// </summary>
{ /// <returns>A <see cref="GRContext"/>.</returns>
IPlatformGraphicsContext? PlatformGraphicsContext { get; }
IScopedResource<GRContext>? TryGetGrContext(); IScopedResource<GRContext>? TryGetGrContext();
} }
@@ -1,6 +1,4 @@
using System; using System;
using Avalonia.Metadata;
using SkiaSharp;
namespace Avalonia.Skia namespace Avalonia.Skia
{ {
@@ -12,16 +10,10 @@ namespace Avalonia.Skia
/// <summary> /// <summary>
/// Start rendering to this render target. /// Start rendering to this render target.
/// </summary> /// </summary>
/// <returns></returns> /// <param name="expectedPixelSize">The expected size.</param>
ISkiaGpuRenderSession BeginRenderingSession(); /// <returns>A render session instance.</returns>
ISkiaGpuRenderSession BeginRenderingSession(PixelSize? expectedPixelSize);
bool IsCorrupted { get; } bool IsCorrupted { get; }
} }
[PrivateApi]
//TODO12: Merge with ISkiaGpuRenderTarget
public interface ISkiaGpuRenderTarget2 : ISkiaGpuRenderTarget
{
ISkiaGpuRenderSession BeginRenderingSession(PixelSize pixelSize);
}
} }
@@ -6,7 +6,7 @@ using SkiaSharp;
namespace Avalonia.Skia.Metal; namespace Avalonia.Skia.Metal;
internal class SkiaMetalGpu : ISkiaGpu, ISkiaGpuWithPlatformGraphicsContext internal class SkiaMetalGpu : ISkiaGpu
{ {
private GRContext? _context; private GRContext? _context;
private readonly IMetalDevice _device; private readonly IMetalDevice _device;
@@ -80,8 +80,9 @@ internal class SkiaMetalGpu : ISkiaGpu, ISkiaGpuWithPlatformGraphicsContext
_target = null; _target = null;
} }
public ISkiaGpuRenderSession BeginRenderingSession() public ISkiaGpuRenderSession BeginRenderingSession(PixelSize? expectedPixelSize)
{ {
// TODO: use expectedPixelSize
var session = (_target ?? throw new ObjectDisposedException(nameof(SkiaMetalRenderTarget))).BeginRendering(); var session = (_target ?? throw new ObjectDisposedException(nameof(SkiaMetalRenderTarget))).BeginRendering();
var backendTarget = new GRBackendRenderTarget(session.Size.Width, session.Size.Height, var backendTarget = new GRBackendRenderTarget(session.Size.Width, session.Size.Height,
new GRMtlTextureInfo(session.Texture)); new GRMtlTextureInfo(session.Texture));
@@ -1,15 +1,12 @@
using System; using System;
using Avalonia.Reactive;
using Avalonia.OpenGL; using Avalonia.OpenGL;
using Avalonia.OpenGL.Surfaces; using Avalonia.OpenGL.Surfaces;
using Avalonia.Platform;
using Avalonia.Rendering;
using SkiaSharp; using SkiaSharp;
using static Avalonia.OpenGL.GlConsts; using static Avalonia.OpenGL.GlConsts;
namespace Avalonia.Skia namespace Avalonia.Skia
{ {
internal class GlRenderTarget : ISkiaGpuRenderTarget2 internal class GlRenderTarget : ISkiaGpuRenderTarget
{ {
private readonly GRContext _grContext; private readonly GRContext _grContext;
private IGlPlatformSurfaceRenderTarget _surface; private IGlPlatformSurfaceRenderTarget _surface;
@@ -23,7 +20,7 @@ namespace Avalonia.Skia
public void Dispose() => _surface.Dispose(); public void Dispose() => _surface.Dispose();
public bool IsCorrupted => (_surface as IGlPlatformSurfaceRenderTargetWithCorruptionInfo)?.IsCorrupted == true; public bool IsCorrupted => _surface.IsCorrupted;
class GlGpuSession : ISkiaGpuRenderSession class GlGpuSession : ISkiaGpuRenderSession
{ {
@@ -58,16 +55,10 @@ namespace Avalonia.Skia
public SKSurface SkSurface => _surface; public SKSurface SkSurface => _surface;
public double ScaleFactor => _glSession.Scaling; public double ScaleFactor => _glSession.Scaling;
} }
public ISkiaGpuRenderSession BeginRenderingSession(PixelSize size) => BeginRenderingSessionCore(size);
public ISkiaGpuRenderSession BeginRenderingSession() => BeginRenderingSessionCore(null);
ISkiaGpuRenderSession BeginRenderingSessionCore(PixelSize? expectedSize) public ISkiaGpuRenderSession BeginRenderingSession(PixelSize? expectedPixelSize)
{ {
var glSession = var glSession = _surface.BeginDraw(expectedPixelSize);
expectedSize != null && _surface is IGlPlatformSurfaceRenderTarget2 surface2
? surface2.BeginDraw(expectedSize.Value)
: _surface.BeginDraw();
bool success = false; bool success = false;
try try
@@ -10,8 +10,7 @@ using static Avalonia.OpenGL.GlConsts;
namespace Avalonia.Skia namespace Avalonia.Skia
{ {
internal class GlSkiaGpu : ISkiaGpu, IOpenGlTextureSharingRenderInterfaceContextFeature, internal class GlSkiaGpu : ISkiaGpu, IOpenGlTextureSharingRenderInterfaceContextFeature
ISkiaGpuWithPlatformGraphicsContext
{ {
private readonly GRContext _grContext; private readonly GRContext _grContext;
private readonly IGlContext _glContext; private readonly IGlContext _glContext;
@@ -5,7 +5,7 @@ namespace Avalonia.Skia
/// <summary> /// <summary>
/// Adapts <see cref="ISkiaGpuRenderTarget"/> to be used within our rendering pipeline. /// Adapts <see cref="ISkiaGpuRenderTarget"/> to be used within our rendering pipeline.
/// </summary> /// </summary>
internal class SkiaGpuRenderTarget : IRenderTarget2 internal class SkiaGpuRenderTarget : IRenderTarget
{ {
private readonly ISkiaGpu _skiaGpu; private readonly ISkiaGpu _skiaGpu;
private readonly ISkiaGpuRenderTarget _renderTarget; private readonly ISkiaGpuRenderTarget _renderTarget;
@@ -34,10 +34,7 @@ namespace Avalonia.Skia
out RenderTargetDrawingContextProperties properties) out RenderTargetDrawingContextProperties properties)
{ {
properties = default; properties = default;
var session = var session = _renderTarget.BeginRenderingSession(expectedPixelSize);
expectedPixelSize.HasValue && _renderTarget is ISkiaGpuRenderTarget2 target2
? target2.BeginRenderingSession(expectedPixelSize.Value)
: _renderTarget.BeginRenderingSession();
var nfo = new DrawingContextImpl.CreateInfo var nfo = new DrawingContextImpl.CreateInfo
{ {
@@ -2,12 +2,11 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Avalonia.Vulkan; using Avalonia.Vulkan;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Rendering;
using SkiaSharp; using SkiaSharp;
namespace Avalonia.Skia.Vulkan; namespace Avalonia.Skia.Vulkan;
internal class VulkanSkiaGpu : ISkiaGpuWithPlatformGraphicsContext internal class VulkanSkiaGpu : ISkiaGpu
{ {
private readonly VulkanSkiaExternalObjectsFeature? _externalObjects; private readonly VulkanSkiaExternalObjectsFeature? _externalObjects;
public IVulkanPlatformGraphicsContext Vulkan { get; private set; } public IVulkanPlatformGraphicsContext Vulkan { get; private set; }
@@ -21,8 +21,9 @@ class VulkanSkiaRenderTarget : ISkiaGpuRenderTarget
_target.Dispose(); _target.Dispose();
} }
public ISkiaGpuRenderSession BeginRenderingSession() public ISkiaGpuRenderSession BeginRenderingSession(PixelSize? expectedPixelSize)
{ {
// TODO: use expectedPixelSize
var session = _target.BeginDraw(); var session = _target.BeginDraw();
bool success = false; bool success = false;
try try
@@ -1,6 +1,4 @@
using System.IO;
using Avalonia.Controls.Platform.Surfaces; using Avalonia.Controls.Platform.Surfaces;
using Avalonia.Media.Imaging;
using Avalonia.Platform; using Avalonia.Platform;
using SkiaSharp; using SkiaSharp;
@@ -19,9 +17,18 @@ internal class RenderTargetBitmapImpl : WriteableBitmapImpl,
_renderTarget = new FramebufferRenderTarget(this); _renderTarget = new FramebufferRenderTarget(this);
} }
public RenderTargetProperties Properties => default;
IDrawingContextImpl IRenderTarget.CreateDrawingContext(bool useScaledDrawing) => IDrawingContextImpl IRenderTarget.CreateDrawingContext(bool useScaledDrawing) =>
_renderTarget.CreateDrawingContext(useScaledDrawing); _renderTarget.CreateDrawingContext(useScaledDrawing);
IDrawingContextImpl IRenderTarget.CreateDrawingContext(PixelSize expectedPixelSize,
out RenderTargetDrawingContextProperties properties)
{
properties = default;
return _renderTarget.CreateDrawingContext(false);
}
public bool IsCorrupted => false; public bool IsCorrupted => false;
public override void Dispose() public override void Dispose()
@@ -31,4 +38,4 @@ internal class RenderTargetBitmapImpl : WriteableBitmapImpl,
} }
public IFramebufferRenderTarget CreateFramebufferRenderTarget() => new FuncFramebufferRenderTarget(Lock); public IFramebufferRenderTarget CreateFramebufferRenderTarget() => new FuncFramebufferRenderTarget(Lock);
} }
+2 -3
View File
@@ -5,7 +5,6 @@ using System.Linq;
using Avalonia.Controls.Platform.Surfaces; using Avalonia.Controls.Platform.Surfaces;
using Avalonia.OpenGL; using Avalonia.OpenGL;
using Avalonia.Platform; using Avalonia.Platform;
using SkiaSharp;
namespace Avalonia.Skia; namespace Avalonia.Skia;
@@ -29,7 +28,7 @@ internal class SkiaContext : IPlatformRenderInterfaceContext
// TODO12: extend ISkiaGpu with PublicFeatures instead // TODO12: extend ISkiaGpu with PublicFeatures instead
TryFeature<IOpenGlTextureSharingRenderInterfaceContextFeature>(); TryFeature<IOpenGlTextureSharingRenderInterfaceContextFeature>();
TryFeature<IExternalObjectsRenderInterfaceContextFeature>(); TryFeature<IExternalObjectsRenderInterfaceContextFeature>();
using (var gr = (_gpu as ISkiaGpuWithPlatformGraphicsContext)?.TryGetGrContext()) using (var gr = gpu.TryGetGrContext())
{ {
var renderTargetSize = gr?.Value.MaxRenderTargetSize; var renderTargetSize = gr?.Value.MaxRenderTargetSize;
if (renderTargetSize.HasValue) if (renderTargetSize.HasValue)
@@ -74,7 +73,7 @@ internal class SkiaContext : IPlatformRenderInterfaceContext
public IDrawingContextLayerImpl CreateOffscreenRenderTarget(PixelSize pixelSize, Vector scaling, public IDrawingContextLayerImpl CreateOffscreenRenderTarget(PixelSize pixelSize, Vector scaling,
bool enableTextAntialiasing) bool enableTextAntialiasing)
{ {
using (var gr = (_gpu as ISkiaGpuWithPlatformGraphicsContext)?.TryGetGrContext()) using (var gr = _gpu?.TryGetGrContext())
{ {
var createInfo = new SurfaceRenderTarget.CreateInfo var createInfo = new SurfaceRenderTarget.CreateInfo
{ {
@@ -72,6 +72,8 @@ namespace Avalonia.Skia
_canvas = canvas; _canvas = canvas;
} }
public RenderTargetProperties Properties => default;
/// <summary> /// <summary>
/// Create backing Skia surface. /// Create backing Skia surface.
/// </summary> /// </summary>
@@ -114,6 +116,13 @@ namespace Avalonia.Skia
return new DrawingContextImpl(createInfo, Disposable.Create(() => Version++)); return new DrawingContextImpl(createInfo, Disposable.Create(() => Version++));
} }
public IDrawingContextImpl CreateDrawingContext(PixelSize expectedPixelSize,
out RenderTargetDrawingContextProperties properties)
{
properties = default;
return CreateDrawingContext(false);
}
public bool IsCorrupted => _gpu?.IsLost == true; public bool IsCorrupted => _gpu?.IsLost == true;
/// <inheritdoc /> /// <inheritdoc />
@@ -76,8 +76,9 @@ namespace Avalonia.Win32.DirectX
} }
/// <inheritdoc /> /// <inheritdoc />
public override IGlPlatformSurfaceRenderingSession BeginDrawCore() public override IGlPlatformSurfaceRenderingSession BeginDrawCore(PixelSize? expectedPixelSize)
{ {
// TODO: use expectedPixelSize
if (_swapChain is null) if (_swapChain is null)
{ {
throw new InvalidOperationException("No chain to draw on"); throw new InvalidOperationException("No chain to draw on");
@@ -27,8 +27,9 @@ internal class AngleD3DTextureFeature : IGlPlatformSurfaceRenderTargetFactory
_target = target; _target = target;
} }
public override IGlPlatformSurfaceRenderingSession BeginDrawCore() public override IGlPlatformSurfaceRenderingSession BeginDrawCore(PixelSize? expectedPixelSize)
{ {
// TODO: use expectedPixelSize
var success = false; var success = false;
var contextLock = Context.EnsureCurrent(); var contextLock = Context.EnsureCurrent();
IDirect3D11TextureRenderTargetRenderSession? session = null; IDirect3D11TextureRenderTargetRenderSession? session = null;
@@ -28,6 +28,7 @@ namespace Avalonia.Win32.OpenGl
private readonly WglContext _context; private readonly WglContext _context;
private readonly EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo _info; private readonly EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo _info;
private IntPtr _hdc; private IntPtr _hdc;
public RenderTarget(WglContext context, EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo info) public RenderTarget(WglContext context, EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo info)
{ {
_context = context; _context = context;
@@ -35,13 +36,16 @@ namespace Avalonia.Win32.OpenGl
_hdc = context.CreateConfiguredDeviceContext(info.Handle); _hdc = context.CreateConfiguredDeviceContext(info.Handle);
} }
public bool IsCorrupted => false;
public void Dispose() public void Dispose()
{ {
WglGdiResourceManager.ReleaseDC(_info.Handle, _hdc); WglGdiResourceManager.ReleaseDC(_info.Handle, _hdc);
} }
public IGlPlatformSurfaceRenderingSession BeginDraw() public IGlPlatformSurfaceRenderingSession BeginDraw(PixelSize? expectedPixelSize)
{ {
// TODO: use expectedPixelSize
var oldContext = _context.MakeCurrent(_hdc); var oldContext = _context.MakeCurrent(_hdc);
// Reset to default FBO first // Reset to default FBO first
@@ -61,6 +61,8 @@ namespace Avalonia.iOS.Eagl
_fbo = fbo; _fbo = fbo;
} }
public bool IsCorrupted => false;
public void Dispose() public void Dispose()
{ {
CheckThread(); CheckThread();
@@ -68,8 +70,9 @@ namespace Avalonia.iOS.Eagl
_fbo.Dispose(); _fbo.Dispose();
} }
public IGlPlatformSurfaceRenderingSession BeginDraw() public IGlPlatformSurfaceRenderingSession BeginDraw(PixelSize? expectedPixelSize)
{ {
// TODO: use expectedPixelSize
CheckThread(); CheckThread();
var restoreContext = _ctx.MakeCurrent(); var restoreContext = _ctx.MakeCurrent();
_fbo.Bind(); _fbo.Bind();