diff --git a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs index a9a79ff0c5..767be3149d 100644 --- a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs +++ b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs @@ -191,16 +191,7 @@ namespace Avalonia.Skia throw new ArgumentException("Height can't be less than 1", nameof(size)); } - var createInfo = new SurfaceRenderTarget.CreateInfo - { - Width = size.Width, - Height = size.Height, - Dpi = dpi, - DisableTextLcdRendering = false, - DisableManualFbo = true, - }; - - return new SurfaceRenderTarget(createInfo); + return new RenderTargetBitmapImpl(size, dpi); } /// diff --git a/src/Skia/Avalonia.Skia/RenderTargetBitmapImpl.cs b/src/Skia/Avalonia.Skia/RenderTargetBitmapImpl.cs new file mode 100644 index 0000000000..e20755b4e2 --- /dev/null +++ b/src/Skia/Avalonia.Skia/RenderTargetBitmapImpl.cs @@ -0,0 +1,31 @@ +using System.IO; +using Avalonia.Controls.Platform.Surfaces; +using Avalonia.Media.Imaging; +using Avalonia.Platform; +using SkiaSharp; + +namespace Avalonia.Skia; + +internal class RenderTargetBitmapImpl : WriteableBitmapImpl, + IRenderTargetBitmapImpl, + IFramebufferPlatformSurface +{ + private readonly FramebufferRenderTarget _renderTarget; + + public RenderTargetBitmapImpl(PixelSize size, Vector dpi) : base(size, dpi, + SKImageInfo.PlatformColorType == SKColorType.Rgba8888 ? PixelFormats.Rgba8888 : PixelFormat.Bgra8888, + AlphaFormat.Premul) + { + _renderTarget = new FramebufferRenderTarget(this); + } + + public IDrawingContextImpl CreateDrawingContext() => _renderTarget.CreateDrawingContext(); + + public bool IsCorrupted => false; + + public override void Dispose() + { + _renderTarget.Dispose(); + base.Dispose(); + } +} \ No newline at end of file diff --git a/src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs b/src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs index 8ea7434c23..38df7b2933 100644 --- a/src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs +++ b/src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs @@ -131,7 +131,7 @@ namespace Avalonia.Skia } /// - public void Dispose() + public virtual void Dispose() { _bitmap.Dispose(); }