mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-11-08 07:08:36 +01:00
Pause plugins when covered by other window
This commit is contained in:
@@ -8,14 +8,17 @@ 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()"/>.
|
||||
/// Plugins override <see cref="RenderAsync(CancellationToken)"/> and return an <see cref="SKImage"/>
|
||||
/// of their own size, just like <see cref="AsyncPlugin.MainAsync(CancellationToken)"/> returns a
|
||||
/// <see cref="Bitmap"/>. The returned image is scaled to fit the plugin window while preserving
|
||||
/// its aspect ratio.
|
||||
/// 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.
|
||||
/// Override <see cref="RenderAsync(CancellationToken)"/> instead.
|
||||
/// </summary>
|
||||
public sealed override Task<Bitmap?> MainAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -24,8 +27,9 @@ public abstract class SkiaAsyncPlugin : AsyncPlugin
|
||||
|
||||
/// <summary>
|
||||
/// Called every <see cref="Plugin.UpdateInterval"/> milliseconds to render the plugin asynchronously.
|
||||
/// Return <see langword="null"/> to keep the previously rendered image.
|
||||
/// </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);
|
||||
/// <returns>The rendered image, or <see langword="null"/> to keep the previous frame.</returns>
|
||||
public abstract Task<SKImage?> RenderAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user