using SkiaSharp;
using System.Drawing;
using System.Threading;
using System.Threading.Tasks;
namespace DesktopMagic.Api;
///
/// Provides an abstract base class for creating asynchronous plugins using SkiaSharp rendering.
/// Plugins override and return an
/// of their own size, just like returns a
/// . The returned image is scaled to fit the plugin window while preserving
/// its aspect ratio.
/// All existing , , and code is unaffected.
///
public abstract class SkiaAsyncPlugin : AsyncPlugin
{
///
/// This method is sealed and returns null for async Skia plugins.
/// Override instead.
///
public sealed override Task MainAsync(CancellationToken cancellationToken)
{
return Task.FromResult(null);
}
///
/// Called every milliseconds to render the plugin asynchronously.
/// Return to keep the previously rendered image.
///
/// Token signaled when the host requests cancellation.
/// The rendered image, or to keep the previous frame.
public abstract Task RenderAsync(CancellationToken cancellationToken);
}