diff --git a/api/Avalonia.Skia.nupkg.xml b/api/Avalonia.Skia.nupkg.xml
index b73745af8e..7a83006bf2 100644
--- a/api/Avalonia.Skia.nupkg.xml
+++ b/api/Avalonia.Skia.nupkg.xml
@@ -1,4 +1,4 @@
-
+
@@ -61,6 +61,18 @@
baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll
current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll
+
+ CP0002
+ M:Avalonia.Skia.ISkiaGpuRenderTarget.get_IsCorrupted
+ baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll
+ current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll
+
+
+ CP0002
+ M:Avalonia.Skia.ISkiaGpuRenderTarget.get_IsReady
+ baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll
+ current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll
+
CP0002
M:Avalonia.Skia.Helpers.DrawingContextHelper.WrapSkiaCanvas(SkiaSharp.SKCanvas,Avalonia.Vector)
@@ -85,6 +97,18 @@
baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll
current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll
+
+ CP0002
+ M:Avalonia.Skia.ISkiaGpuRenderTarget.get_IsCorrupted
+ baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll
+ current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll
+
+
+ CP0002
+ M:Avalonia.Skia.ISkiaGpuRenderTarget.get_IsReady
+ baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll
+ current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll
+
CP0006
M:Avalonia.Skia.ISkiaGpu.TryCreateRenderTarget(System.Collections.Generic.IEnumerable{Avalonia.Platform.Surfaces.IPlatformRenderSurface})
@@ -169,4 +193,4 @@
baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll
current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll
-
+
\ No newline at end of file
diff --git a/api/Avalonia.Win32.nupkg.xml b/api/Avalonia.Win32.nupkg.xml
new file mode 100644
index 0000000000..903595add8
--- /dev/null
+++ b/api/Avalonia.Win32.nupkg.xml
@@ -0,0 +1,16 @@
+
+
+
+
+ CP0002
+ M:Avalonia.Win32.DirectX.IDirect3D11TextureRenderTarget.get_IsCorrupted
+ baseline/Avalonia.Win32/lib/net10.0/Avalonia.Win32.dll
+ current/Avalonia.Win32/lib/net10.0/Avalonia.Win32.dll
+
+
+ CP0002
+ M:Avalonia.Win32.DirectX.IDirect3D11TextureRenderTarget.get_IsCorrupted
+ baseline/Avalonia.Win32/lib/net8.0/Avalonia.Win32.dll
+ current/Avalonia.Win32/lib/net8.0/Avalonia.Win32.dll
+
+
\ No newline at end of file
diff --git a/api/Avalonia.nupkg.xml b/api/Avalonia.nupkg.xml
index 71bdf3714d..f3a9929ca1 100644
--- a/api/Avalonia.nupkg.xml
+++ b/api/Avalonia.nupkg.xml
@@ -1693,12 +1693,30 @@
baseline/Avalonia/lib/net10.0/Avalonia.Base.dll
current/Avalonia/lib/net10.0/Avalonia.Base.dll
+
+ CP0002
+ M:Avalonia.Platform.IRenderTarget.get_IsCorrupted
+ baseline/Avalonia/lib/net10.0/Avalonia.Base.dll
+ current/Avalonia/lib/net10.0/Avalonia.Base.dll
+
+
+ CP0002
+ M:Avalonia.Platform.IRenderTarget.get_IsReady
+ baseline/Avalonia/lib/net10.0/Avalonia.Base.dll
+ current/Avalonia/lib/net10.0/Avalonia.Base.dll
+
CP0002
M:Avalonia.Platform.LockedFramebuffer.#ctor(System.IntPtr,Avalonia.PixelSize,System.Int32,Avalonia.Vector,Avalonia.Platform.PixelFormat,System.Action)
baseline/Avalonia/lib/net10.0/Avalonia.Base.dll
current/Avalonia/lib/net10.0/Avalonia.Base.dll
+
+ CP0002
+ M:Avalonia.Platform.Surfaces.IPlatformRenderSurfaceRenderTarget.get_IsReady
+ baseline/Avalonia/lib/net10.0/Avalonia.Base.dll
+ current/Avalonia/lib/net10.0/Avalonia.Base.dll
+
CP0002
M:Avalonia.Rendering.Composition.ICompositionGpuImportedObject.get_ImportCompeted
@@ -2587,6 +2605,12 @@
baseline/Avalonia/lib/net10.0/Avalonia.OpenGL.dll
current/Avalonia/lib/net10.0/Avalonia.OpenGL.dll
+
+ CP0002
+ M:Avalonia.OpenGL.Surfaces.IGlPlatformSurfaceRenderTarget.get_IsCorrupted
+ baseline/Avalonia/lib/net10.0/Avalonia.OpenGL.dll
+ current/Avalonia/lib/net10.0/Avalonia.OpenGL.dll
+
CP0002
M:Avalonia.Vulkan.IVulkanKhrSurfacePlatformSurfaceFactory.CanRenderToSurface(Avalonia.Vulkan.IVulkanPlatformGraphicsContext,System.Object)
@@ -3367,12 +3391,30 @@
baseline/Avalonia/lib/net8.0/Avalonia.Base.dll
current/Avalonia/lib/net8.0/Avalonia.Base.dll
+
+ CP0002
+ M:Avalonia.Platform.IRenderTarget.get_IsCorrupted
+ baseline/Avalonia/lib/net8.0/Avalonia.Base.dll
+ current/Avalonia/lib/net8.0/Avalonia.Base.dll
+
+
+ CP0002
+ M:Avalonia.Platform.IRenderTarget.get_IsReady
+ baseline/Avalonia/lib/net8.0/Avalonia.Base.dll
+ current/Avalonia/lib/net8.0/Avalonia.Base.dll
+
CP0002
M:Avalonia.Platform.LockedFramebuffer.#ctor(System.IntPtr,Avalonia.PixelSize,System.Int32,Avalonia.Vector,Avalonia.Platform.PixelFormat,System.Action)
baseline/Avalonia/lib/net8.0/Avalonia.Base.dll
current/Avalonia/lib/net8.0/Avalonia.Base.dll
+
+ CP0002
+ M:Avalonia.Platform.Surfaces.IPlatformRenderSurfaceRenderTarget.get_IsReady
+ baseline/Avalonia/lib/net8.0/Avalonia.Base.dll
+ current/Avalonia/lib/net8.0/Avalonia.Base.dll
+
CP0002
M:Avalonia.Rendering.Composition.ICompositionGpuImportedObject.get_ImportCompeted
@@ -4267,6 +4309,12 @@
baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll
current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll
+
+ CP0002
+ M:Avalonia.OpenGL.Surfaces.IGlPlatformSurfaceRenderTarget.get_IsCorrupted
+ baseline/Avalonia/lib/net8.0/Avalonia.OpenGL.dll
+ current/Avalonia/lib/net8.0/Avalonia.OpenGL.dll
+
CP0002
M:Avalonia.Vulkan.IVulkanKhrSurfacePlatformSurfaceFactory.CanRenderToSurface(Avalonia.Vulkan.IVulkanPlatformGraphicsContext,System.Object)
diff --git a/src/Avalonia.Base/Platform/IRenderTarget.cs b/src/Avalonia.Base/Platform/IRenderTarget.cs
index e66d14995e..2e7d56405a 100644
--- a/src/Avalonia.Base/Platform/IRenderTarget.cs
+++ b/src/Avalonia.Base/Platform/IRenderTarget.cs
@@ -12,11 +12,6 @@ namespace Avalonia.Platform
[PrivateApi]
public interface IRenderTarget : IDisposable
{
- ///
- /// Indicates if the render target is no longer usable and needs to be recreated
- ///
- bool IsCorrupted { get; }
-
///
/// Gets the properties of the render target.
///
@@ -33,9 +28,9 @@ namespace Avalonia.Platform
IDrawingContextImpl CreateDrawingContext(RenderTargetSceneInfo sceneInfo, out RenderTargetDrawingContextProperties properties);
///
- /// Indicates if the render target is currently ready to be rendered to
+ /// Gets the current readiness state of the render target.
///
- bool IsReady => true;
+ PlatformRenderTargetState PlatformRenderTargetState => PlatformRenderTargetState.Ready;
public record struct RenderTargetSceneInfo(PixelSize Size, double Scaling);
}
diff --git a/src/Avalonia.Base/Platform/RenderTargetProperties.cs b/src/Avalonia.Base/Platform/RenderTargetProperties.cs
index c4a0948180..de4f3f4345 100644
--- a/src/Avalonia.Base/Platform/RenderTargetProperties.cs
+++ b/src/Avalonia.Base/Platform/RenderTargetProperties.cs
@@ -3,6 +3,36 @@ using Avalonia.Metadata;
namespace Avalonia.Platform;
+///
+/// Describes the current readiness state of a platform render target.
+/// Flows through the entire rendering pipeline from platform to compositor.
+///
+[PrivateApi]
+[SuppressMessage("Performance", "CA1815:Override equals and operator equals on value types", Justification = "Private API, not meant to be compared")]
+public readonly struct PlatformRenderTargetState
+{
+ ///
+ /// Indicates if the render target is currently ready to be rendered to.
+ ///
+ public bool IsReady { get; init; }
+
+ ///
+ /// Indicates if the render target is no longer usable and needs to be recreated
+ ///
+ public bool IsCorrupted { get; init; }
+
+ ///
+ /// A readiness state indicating the target is ready to render.
+ ///
+ public static PlatformRenderTargetState Ready => new() { IsReady = true };
+
+ public static PlatformRenderTargetState NotReadyTryLater => default;
+
+ public static PlatformRenderTargetState Corrupted => new() { IsCorrupted = true, IsReady = true};
+
+ public static PlatformRenderTargetState Disposed => new() { IsCorrupted = true};
+}
+
[PrivateApi]
[SuppressMessage("Performance", "CA1815:Override equals and operator equals on value types", Justification = "Private API, not meant to be compared")]
public struct RenderTargetProperties
diff --git a/src/Avalonia.Base/Platform/Surfaces/IPlatformRenderSurface.cs b/src/Avalonia.Base/Platform/Surfaces/IPlatformRenderSurface.cs
index ff71a700c4..0c085c20b8 100644
--- a/src/Avalonia.Base/Platform/Surfaces/IPlatformRenderSurface.cs
+++ b/src/Avalonia.Base/Platform/Surfaces/IPlatformRenderSurface.cs
@@ -11,5 +11,5 @@ public interface IPlatformRenderSurface
[PrivateApi]
public interface IPlatformRenderSurfaceRenderTarget
{
- bool IsReady => true;
+ PlatformRenderTargetState State => PlatformRenderTargetState.Ready;
}
diff --git a/src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionTarget.cs b/src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionTarget.cs
index e8ae84eb03..fe857ac466 100644
--- a/src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionTarget.cs
+++ b/src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionTarget.cs
@@ -138,7 +138,7 @@ namespace Avalonia.Rendering.Composition.Server
if (Root == null)
return;
- if (_renderTarget?.IsCorrupted == true)
+ if (_renderTarget?.PlatformRenderTargetState.IsCorrupted == true)
{
_layer?.Dispose();
_layer = null;
@@ -178,7 +178,7 @@ namespace Avalonia.Rendering.Composition.Server
if (!_redrawRequested)
return;
- if (!_renderTarget.IsReady)
+ if (!_renderTarget.PlatformRenderTargetState.IsReady)
{
IsWaitingForReadyRenderTarget = IsEnabled;
return;
diff --git a/src/Avalonia.Native/AvaloniaNativeGlPlatformGraphics.cs b/src/Avalonia.Native/AvaloniaNativeGlPlatformGraphics.cs
index 91e4dd2680..9efe33689f 100644
--- a/src/Avalonia.Native/AvaloniaNativeGlPlatformGraphics.cs
+++ b/src/Avalonia.Native/AvaloniaNativeGlPlatformGraphics.cs
@@ -173,7 +173,7 @@ namespace Avalonia.Native
_context = context;
}
- public bool IsCorrupted => false;
+ public PlatformRenderTargetState State => PlatformRenderTargetState.Ready;
public IGlPlatformSurfaceRenderingSession BeginDraw(IRenderTarget.RenderTargetSceneInfo sceneInfo)
{
diff --git a/src/Avalonia.OpenGL/Egl/EglGlPlatformSurfaceBase.cs b/src/Avalonia.OpenGL/Egl/EglGlPlatformSurfaceBase.cs
index ef4ae257bd..8ee06266d8 100644
--- a/src/Avalonia.OpenGL/Egl/EglGlPlatformSurfaceBase.cs
+++ b/src/Avalonia.OpenGL/Egl/EglGlPlatformSurfaceBase.cs
@@ -110,6 +110,9 @@ namespace Avalonia.OpenGL.Egl
public bool IsYFlipped { get; }
}
+ public virtual PlatformRenderTargetState State =>
+ IsCorrupted ? PlatformRenderTargetState.Corrupted : PlatformRenderTargetState.Ready;
+
public virtual bool IsCorrupted => Context.IsLost;
}
}
diff --git a/src/Avalonia.OpenGL/Surfaces/IGlPlatformSurfaceRenderTarget.cs b/src/Avalonia.OpenGL/Surfaces/IGlPlatformSurfaceRenderTarget.cs
index da35de6649..86c733c5fa 100644
--- a/src/Avalonia.OpenGL/Surfaces/IGlPlatformSurfaceRenderTarget.cs
+++ b/src/Avalonia.OpenGL/Surfaces/IGlPlatformSurfaceRenderTarget.cs
@@ -8,7 +8,6 @@ namespace Avalonia.OpenGL.Surfaces
[PrivateApi]
public interface IGlPlatformSurfaceRenderTarget : IDisposable, IPlatformRenderSurfaceRenderTarget
{
- bool IsCorrupted { get; }
IGlPlatformSurfaceRenderingSession BeginDraw(IRenderTarget.RenderTargetSceneInfo sceneInfo);
}
}
diff --git a/src/Avalonia.Vulkan/VulkanKhrSurfaceRenderTarget.cs b/src/Avalonia.Vulkan/VulkanKhrSurfaceRenderTarget.cs
index a24b9eea7a..64aaa5ad30 100644
--- a/src/Avalonia.Vulkan/VulkanKhrSurfaceRenderTarget.cs
+++ b/src/Avalonia.Vulkan/VulkanKhrSurfaceRenderTarget.cs
@@ -1,4 +1,5 @@
using System;
+using Avalonia.Platform;
using Avalonia.Vulkan.Interop;
using Avalonia.Vulkan.UnmanagedInterop;
@@ -26,6 +27,8 @@ internal class VulkanKhrRenderTarget : IVulkanRenderTarget
Format = IsRgba ? VkFormat.VK_FORMAT_R8G8B8A8_UNORM : VkFormat.VK_FORMAT_B8G8R8A8_UNORM;
}
+ public PlatformRenderTargetState State => PlatformRenderTargetState.Ready;
+
private void CreateImage()
{
_image = new VulkanImage(_context, _display.CommandBufferPool, Format, _display.Size);
diff --git a/src/Avalonia.X11/Glx/GlxGlPlatformSurface.cs b/src/Avalonia.X11/Glx/GlxGlPlatformSurface.cs
index 81d7a4e9bc..b91c7ac6c9 100644
--- a/src/Avalonia.X11/Glx/GlxGlPlatformSurface.cs
+++ b/src/Avalonia.X11/Glx/GlxGlPlatformSurface.cs
@@ -39,7 +39,7 @@ namespace Avalonia.X11.Glx
// No-op
}
- public bool IsCorrupted => false;
+ public PlatformRenderTargetState State => PlatformRenderTargetState.Ready;
public IGlPlatformSurfaceRenderingSession BeginDraw(IRenderTarget.RenderTargetSceneInfo sceneInfo)
{
var size = sceneInfo.Size;
diff --git a/src/Headless/Avalonia.Headless/HeadlessPlatformRenderInterface.cs b/src/Headless/Avalonia.Headless/HeadlessPlatformRenderInterface.cs
index b83cf8b526..1c152d0fe4 100644
--- a/src/Headless/Avalonia.Headless/HeadlessPlatformRenderInterface.cs
+++ b/src/Headless/Avalonia.Headless/HeadlessPlatformRenderInterface.cs
@@ -608,8 +608,6 @@ namespace Avalonia.Headless
properties = default;
return new HeadlessDrawingContextStub();
}
-
- public bool IsCorrupted => false;
}
public void Dispose()
diff --git a/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs b/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs
index cf0bf1e49a..dabf1b6bfd 100644
--- a/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs
+++ b/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs
@@ -407,7 +407,7 @@ namespace Avalonia.LinuxFramebuffer.Output
_parent = parent;
}
- public bool IsCorrupted => false;
+ public PlatformRenderTargetState State => PlatformRenderTargetState.Ready;
public void Dispose()
{
diff --git a/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs b/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs
index 5491df93b8..828de2843f 100644
--- a/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs
+++ b/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs
@@ -47,8 +47,8 @@ namespace Avalonia.Skia
IsSuitableForDirectRendering = true
};
-
-
+ public PlatformRenderTargetState PlatformRenderTargetState =>
+ _renderTarget?.State ?? PlatformRenderTargetState.Disposed;
///
public IDrawingContextImpl CreateDrawingContext(IRenderTarget.RenderTargetSceneInfo sceneInfo,
@@ -86,10 +86,7 @@ namespace Avalonia.Skia
return new DrawingContextImpl(createInfo, _preFramebufferCopyHandler, canvas, framebuffer);
}
-
- public bool IsCorrupted => false;
-
- public bool IsReady => _renderTarget is not IPlatformRenderSurfaceRenderTarget prs || prs.IsReady;
+
///
/// Check if two images info are compatible.
diff --git a/src/Skia/Avalonia.Skia/Gpu/ISkiaGpuRenderTarget.cs b/src/Skia/Avalonia.Skia/Gpu/ISkiaGpuRenderTarget.cs
index 65b6b5a8df..bd8061cf98 100644
--- a/src/Skia/Avalonia.Skia/Gpu/ISkiaGpuRenderTarget.cs
+++ b/src/Skia/Avalonia.Skia/Gpu/ISkiaGpuRenderTarget.cs
@@ -15,8 +15,6 @@ namespace Avalonia.Skia
/// A render session instance.
ISkiaGpuRenderSession BeginRenderingSession(IRenderTarget.RenderTargetSceneInfo sceneInfo);
- bool IsCorrupted { get; }
-
- bool IsReady => true;
+ PlatformRenderTargetState State => PlatformRenderTargetState.Ready;
}
}
diff --git a/src/Skia/Avalonia.Skia/Gpu/Metal/SkiaMetalGpu.cs b/src/Skia/Avalonia.Skia/Gpu/Metal/SkiaMetalGpu.cs
index 640b415d6f..402d83fd10 100644
--- a/src/Skia/Avalonia.Skia/Gpu/Metal/SkiaMetalGpu.cs
+++ b/src/Skia/Avalonia.Skia/Gpu/Metal/SkiaMetalGpu.cs
@@ -108,9 +108,7 @@ internal class SkiaMetalGpu : ISkiaGpu
return new SkiaMetalRenderSession(_gpu, surface, session, backendTarget);
}
- public bool IsCorrupted => false;
-
- public bool IsReady => _target?.IsReady ?? false;
+ public PlatformRenderTargetState State => _target?.State ?? PlatformRenderTargetState.Disposed;
}
internal class SkiaMetalRenderSession : ISkiaGpuRenderSession
diff --git a/src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs b/src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs
index f5c164be45..69e2f0563e 100644
--- a/src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs
+++ b/src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs
@@ -21,9 +21,7 @@ namespace Avalonia.Skia
public void Dispose() => _surface.Dispose();
- public bool IsCorrupted => _surface.IsCorrupted;
-
- public bool IsReady => _surface.IsReady;
+ public PlatformRenderTargetState State => _surface.State;
class GlGpuSession : ISkiaGpuRenderSession
{
diff --git a/src/Skia/Avalonia.Skia/Gpu/SkiaGpuRenderTarget.cs b/src/Skia/Avalonia.Skia/Gpu/SkiaGpuRenderTarget.cs
index 13bd946b74..d748018824 100644
--- a/src/Skia/Avalonia.Skia/Gpu/SkiaGpuRenderTarget.cs
+++ b/src/Skia/Avalonia.Skia/Gpu/SkiaGpuRenderTarget.cs
@@ -43,9 +43,8 @@ namespace Avalonia.Skia
return new DrawingContextImpl(nfo, session);
}
-
- public bool IsCorrupted => _renderTarget.IsCorrupted;
- public bool IsReady => _renderTarget.IsReady;
+
+ public PlatformRenderTargetState PlatformRenderTargetState => _renderTarget.State;
public RenderTargetProperties Properties { get; }
diff --git a/src/Skia/Avalonia.Skia/Gpu/Vulkan/VulkanSkiaRenderTarget.cs b/src/Skia/Avalonia.Skia/Gpu/Vulkan/VulkanSkiaRenderTarget.cs
index 6b04fcd8c0..dc229e16e8 100644
--- a/src/Skia/Avalonia.Skia/Gpu/Vulkan/VulkanSkiaRenderTarget.cs
+++ b/src/Skia/Avalonia.Skia/Gpu/Vulkan/VulkanSkiaRenderTarget.cs
@@ -74,9 +74,7 @@ class VulkanSkiaRenderTarget : ISkiaGpuRenderTarget
}
}
- public bool IsCorrupted => false;
-
- public bool IsReady => _target.IsReady;
+ public PlatformRenderTargetState State => _target.State;
internal class VulkanSkiaRenderSession : ISkiaGpuRenderSession
diff --git a/src/Windows/Avalonia.Win32/DComposition/DirectCompositedWindowSurface.cs b/src/Windows/Avalonia.Win32/DComposition/DirectCompositedWindowSurface.cs
index d0651e08ee..9c6f5707bf 100644
--- a/src/Windows/Avalonia.Win32/DComposition/DirectCompositedWindowSurface.cs
+++ b/src/Windows/Avalonia.Win32/DComposition/DirectCompositedWindowSurface.cs
@@ -78,11 +78,11 @@ internal class DirectCompositedWindowRenderTarget : IDirect3D11TextureRenderTarg
_d3dDevice.Dispose();
}
- public bool IsCorrupted => _context.IsLost || _lost;
-
+ public PlatformRenderTargetState State => _context.IsLost || _lost ? PlatformRenderTargetState.Corrupted : PlatformRenderTargetState.Ready;
+
public unsafe IDirect3D11TextureRenderTargetRenderSession BeginDraw()
{
- if (IsCorrupted)
+ if (State.IsCorrupted)
throw new RenderTargetCorruptedException();
var transaction = _window.BeginTransaction();
bool needsEndDraw = false;
diff --git a/src/Windows/Avalonia.Win32/DirectX/IDirect3D11TexturePlatformSurface.cs b/src/Windows/Avalonia.Win32/DirectX/IDirect3D11TexturePlatformSurface.cs
index fb1a6a27e7..ce077d6ce0 100644
--- a/src/Windows/Avalonia.Win32/DirectX/IDirect3D11TexturePlatformSurface.cs
+++ b/src/Windows/Avalonia.Win32/DirectX/IDirect3D11TexturePlatformSurface.cs
@@ -1,5 +1,6 @@
using System;
using Avalonia.OpenGL;
+using Avalonia.OpenGL.Surfaces;
using Avalonia.Platform;
using Avalonia.Platform.Surfaces;
@@ -12,9 +13,8 @@ public interface IDirect3D11TexturePlatformSurface : IPlatformRenderSurface
-public interface IDirect3D11TextureRenderTarget : IDisposable
+public interface IDirect3D11TextureRenderTarget : IPlatformRenderSurfaceRenderTarget, IDisposable
{
- bool IsCorrupted { get; }
IDirect3D11TextureRenderTargetRenderSession BeginDraw();
}
diff --git a/src/Windows/Avalonia.Win32/OpenGl/Angle/AngleD3DTextureFeature.cs b/src/Windows/Avalonia.Win32/OpenGl/Angle/AngleD3DTextureFeature.cs
index 0dc8ec453e..60882fb62e 100644
--- a/src/Windows/Avalonia.Win32/OpenGl/Angle/AngleD3DTextureFeature.cs
+++ b/src/Windows/Avalonia.Win32/OpenGl/Angle/AngleD3DTextureFeature.cs
@@ -83,7 +83,8 @@ internal class AngleD3DTextureFeature : IGlPlatformSurfaceRenderTargetFactory
base.Dispose();
}
- public override bool IsCorrupted => _target.IsCorrupted || base.IsCorrupted;
+ public override PlatformRenderTargetState State =>
+ base.IsCorrupted ? PlatformRenderTargetState.Corrupted : _target.State;
}
public IGlPlatformSurfaceRenderTarget CreateRenderTarget(IGlContext context, IPlatformRenderSurface surface)
diff --git a/src/Windows/Avalonia.Win32/OpenGl/WglGlPlatformSurface.cs b/src/Windows/Avalonia.Win32/OpenGl/WglGlPlatformSurface.cs
index f54ca9b62c..39a7da74ca 100644
--- a/src/Windows/Avalonia.Win32/OpenGl/WglGlPlatformSurface.cs
+++ b/src/Windows/Avalonia.Win32/OpenGl/WglGlPlatformSurface.cs
@@ -37,7 +37,7 @@ namespace Avalonia.Win32.OpenGl
_hdc = context.CreateConfiguredDeviceContext(info.Handle);
}
- public bool IsCorrupted => false;
+ public PlatformRenderTargetState State => PlatformRenderTargetState.Ready;
public void Dispose()
{
diff --git a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs
index 2addbc6524..96e5fae00b 100644
--- a/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs
+++ b/src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs
@@ -114,11 +114,12 @@ namespace Avalonia.Win32.WinRT.Composition
_d3dDevice.Dispose();
}
- public bool IsCorrupted => _context.IsLost || _lost;
+ public PlatformRenderTargetState State =>
+ _context.IsLost || _lost ? PlatformRenderTargetState.Corrupted : PlatformRenderTargetState.Ready;
public unsafe IDirect3D11TextureRenderTargetRenderSession BeginDraw()
{
- if (IsCorrupted)
+ if (State.IsCorrupted)
throw new RenderTargetCorruptedException();
var transaction = _window.BeginTransaction();
bool needsEndDraw = false;