-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Walper
committed
Nov 24, 2023
1 parent
71d236f
commit a47e871
Showing
9 changed files
with
256 additions
and
161 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using Avalonia; | ||
using Avalonia.Media; | ||
using Avalonia.Platform; | ||
using Avalonia.Rendering.SceneGraph; | ||
using Avalonia.Skia; | ||
using SkiaSharp; | ||
|
||
namespace SimpleExecutor.Models; | ||
|
||
internal sealed class SkiaCanvasDrawOperation : ICustomDrawOperation | ||
{ | ||
public Action<SKCanvas, SKSurface>? OnRender; | ||
|
||
public bool Equals(ICustomDrawOperation? other) | ||
{ | ||
return other == this; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
// do nothing | ||
} | ||
|
||
public bool HitTest(Point p) | ||
{ | ||
return true; | ||
} | ||
|
||
public void Render(ImmediateDrawingContext context) | ||
{ | ||
var leaseFeature = context.TryGetFeature<ISkiaSharpApiLeaseFeature>(); | ||
if (leaseFeature == null) | ||
return; | ||
|
||
using var lease = leaseFeature.Lease(); | ||
var canvas = lease.SkCanvas; | ||
|
||
Render(canvas, lease.SkSurface!); | ||
} | ||
|
||
public Rect Bounds { get; set; } | ||
|
||
private void Render(SKCanvas canvas, SKSurface surface) | ||
{ | ||
OnRender?.Invoke(canvas, surface); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.