mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 08:56:15 +02:00
Add SkiaPlugin support and benchmark plugins for SkiaSharp and GDI+
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SkiaSharp" Version="4.148.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using SkiaSharp;
|
||||
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DesktopMagic.Api;
|
||||
|
||||
/// <summary>
|
||||
/// Provides an abstract base class for creating asynchronous plugins using SkiaSharp rendering.
|
||||
/// Plugins override <see cref="MainAsync(SKCanvas, CancellationToken)"/> instead of <see cref="Plugin.Main()"/>.
|
||||
/// All existing <see cref="Plugin"/>, <see cref="AsyncPlugin"/>, and <see cref="SkiaPlugin"/> code is unaffected.
|
||||
/// </summary>
|
||||
public abstract class SkiaAsyncPlugin : AsyncPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// This method is sealed and returns null for async Skia plugins.
|
||||
/// Override <see cref="MainAsync(SKCanvas, CancellationToken)"/> instead.
|
||||
/// </summary>
|
||||
public sealed override Task<Bitmap?> MainAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult<Bitmap?>(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called every <see cref="Plugin.UpdateInterval"/> milliseconds to render the plugin asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="canvas">The SkiaSharp canvas to draw on.</param>
|
||||
/// <param name="cancellationToken">Token signaled when the host requests cancellation.</param>
|
||||
public abstract Task MainAsync(SKCanvas canvas, CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using SkiaSharp;
|
||||
|
||||
using System.Drawing;
|
||||
|
||||
namespace DesktopMagic.Api;
|
||||
|
||||
/// <summary>
|
||||
/// Provides an abstract base class for creating plugins using SkiaSharp rendering.
|
||||
/// Plugins override <see cref="Main(SKCanvas)"/> instead of <see cref="Plugin.Main()"/>.
|
||||
/// All existing <see cref="Plugin"/> and <see cref="AsyncPlugin"/> code is unaffected.
|
||||
/// </summary>
|
||||
public abstract class SkiaPlugin : Plugin
|
||||
{
|
||||
/// <summary>
|
||||
/// This method is sealed and returns null for Skia plugins.
|
||||
/// Override <see cref="Main(SKCanvas)"/> instead.
|
||||
/// </summary>
|
||||
/// <returns>Always null.</returns>
|
||||
public sealed override Bitmap? Main()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called every <see cref="Plugin.UpdateInterval"/> milliseconds to render the plugin.
|
||||
/// </summary>
|
||||
/// <param name="canvas">The SkiaSharp canvas to draw on.</param>
|
||||
public abstract void Main(SKCanvas canvas);
|
||||
}
|
||||
Reference in New Issue
Block a user