15 private readonly
object _gate =
new();
16 private SKBitmap? _buffer;
17 private SKSurface? _surface;
18 private bool _disposed;
20 private sealed record Resolution(
int Width,
int Height);
22 private Resolution? _requestedResolution;
31 CreateSurface(width, height);
53 protected internal override void RequestResize(
int width,
int height)
55 Interlocked.Exchange(ref _requestedResolution,
new(width, height));
72 return _surface!.Canvas;
76 private readonly SKPaint _bitmapPaint =
new SKPaint
79 BlendMode = SKBlendMode.SrcOver
91 get => _bitmapPaint.FilterQuality;
92 set => _bitmapPaint.FilterQuality = value;
108 protected internal override void BeginFrame()
111 if (Interlocked.Exchange(ref _requestedResolution,
null) is { } request)
113 var w = request.Width;
114 var h = request.Height;
123 DisposeSurface_NoLock();
136 var c = _surface!.Canvas;
156 protected internal override void EndFrame()
160 if (_disposed || _surface is
null)
176 protected internal override void DrawTileFrame(Tile tile, RectangleF destRectScreen)
183 Canvas.DrawBitmap(bmp, destRectScreen.ToSKRect(), _bitmapPaint);
200 protected internal override SKImage Snapshot()
204 if (_disposed || _surface is
null)
207 return _surface.Snapshot();
211 private void CreateSurface(
int width,
int height)
213 var info =
new SKImageInfo(
216 SKColorType.Bgra8888,
219 _buffer =
new SKBitmap(info);
220 _surface = SKSurface.Create(info, _buffer.GetPixels(), _buffer.Info.RowBytes);
223 private void DisposeSurface_NoLock()
247 DisposeSurface_NoLock();
virtual Frame CurrentFrame
Gets or sets the current frame. The initial frame supplies the tile's default collision adjustment an...
int Width
Gets the current Backbuffer width in a thread-safe manner.
void UpdateSize(int width, int height)
Updates the stored backbuffer dimensions and raises the SizeChanged event.
int Height
Gets the current Backbuffer height in a thread-safe manner.
static BitmapBackbuffer Create(int width, int height)
Creates a new instance of BitmapBackbuffer with the specified dimensions. This method exists to suppo...
BitmapBackbuffer(int width, int height)
Initializes a new instance of the BitmapBackbuffer class with the specified dimensions.
SKFilterQuality FilterQuality
Gets or sets the filter quality used when drawing bitmaps to the backbuffer.
override void Dispose()
Releases all resources used by the BitmapBackbuffer.
override SKCanvas Canvas
Gets the SKCanvas for drawing operations on this backbuffer.
readonly? SKBitmap SkBitmap
Gets the SkiaSharp bitmap for this frame.