Files
Progrart/Progrart.Core/RenderContext.cs

47 lines
893 B
C#
Raw Normal View History

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-14 00:25:51 +11:00
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;
public SKCanvas canvas { get; }
public PrimitiveDrawingCore(int W, int H)
{
info = new SKImageInfo(W, H);
surface = SKSurface.Create(info);
canvas = surface.Canvas;
}
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-14 00:25:51 +11:00
[Serializable]
public class RenderConfig
{
public int Scale;
}
}