2025-12-24 22:08:37 +11:00
|
|
|
|
using SkiaSharp;
|
2025-12-14 00:25:51 +11:00
|
|
|
|
|
|
|
|
|
|
namespace Progrart.Core
|
|
|
|
|
|
{
|
2025-12-24 22:08:37 +11:00
|
|
|
|
public class RenderContext
|
|
|
|
|
|
{
|
|
|
|
|
|
public PrimitiveDrawingCore DrawingCore { get; }
|
2025-12-14 00:25:51 +11:00
|
|
|
|
|
2025-12-24 22:08:37 +11:00
|
|
|
|
public SKCanvas canvas { get => DrawingCore.canvas; }
|
|
|
|
|
|
public RenderContext(PrimitiveDrawingCore core)
|
2025-12-14 00:25:51 +11:00
|
|
|
|
{
|
2025-12-24 22:08:37 +11:00
|
|
|
|
this.DrawingCore = core;
|
|
|
|
|
|
}
|
2025-12-25 23:00:26 +11:00
|
|
|
|
public SKPoint TranslatePoint(float x, float y)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new SKPoint(x * DrawingCore.Width, y * DrawingCore.Height);
|
|
|
|
|
|
}
|
2025-12-24 22:08:37 +11:00
|
|
|
|
public RenderContext(int W, int H)
|
|
|
|
|
|
{
|
|
|
|
|
|
DrawingCore = new PrimitiveDrawingCore(W, H);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public class PrimitiveDrawingCore : IDisposable
|
|
|
|
|
|
{
|
|
|
|
|
|
internal bool isDisposed = false;
|
|
|
|
|
|
SKSurface surface;
|
|
|
|
|
|
SKImageInfo info;
|
2025-12-25 23:00:26 +11:00
|
|
|
|
public readonly int Width;
|
|
|
|
|
|
public readonly int Height;
|
2025-12-24 22:08:37 +11:00
|
|
|
|
public SKCanvas canvas { get; }
|
|
|
|
|
|
public PrimitiveDrawingCore(int W, int H)
|
|
|
|
|
|
{
|
2025-12-25 23:00:26 +11:00
|
|
|
|
Width = W;
|
|
|
|
|
|
Height = H;
|
2025-12-24 22:08:37 +11:00
|
|
|
|
info = new SKImageInfo(W, H);
|
|
|
|
|
|
surface = SKSurface.Create(info);
|
|
|
|
|
|
canvas = surface.Canvas;
|
2025-12-26 22:49:47 +11:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public SKData ToData()
|
|
|
|
|
|
{
|
|
|
|
|
|
return surface.Snapshot().Encode(SKEncodedImageFormat.Png, 100);
|
2025-12-24 22:08:37 +11:00
|
|
|
|
}
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (isDisposed) return;
|
|
|
|
|
|
//GC.SuppressFinalize(this);
|
|
|
|
|
|
isDisposed = true;
|
|
|
|
|
|
surface.Dispose();
|
2025-12-14 00:25:51 +11:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-24 22:08:37 +11:00
|
|
|
|
|
2025-12-25 23:00:26 +11:00
|
|
|
|
public class ExecuteArguments
|
|
|
|
|
|
{
|
|
|
|
|
|
public Dictionary<string, string> data = new Dictionary<string, string>();
|
|
|
|
|
|
}
|
2025-12-14 00:25:51 +11:00
|
|
|
|
[Serializable]
|
|
|
|
|
|
public class RenderConfig
|
|
|
|
|
|
{
|
|
|
|
|
|
public int Scale;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|