Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
BlazorGpuRenderSurfaceAdapter.cs
2using SkiaSharp;
3
5
15public sealed class BlazorGpuRenderSurfaceAdapter : RenderSurfaceAdapterBase, IDisposable
16{
17 private Action? _afterFrameRenderHandler;
18 private int _pendingFrame;
19 private bool _disposed;
20
24 internal BlazorGpuRenderSurfaceAdapter()
25 : base(1, 1, initialSizeAvailable: false)
26 {
27 }
28
32 internal void AttachToEngine()
33 {
34 if (_afterFrameRenderHandler is not null)
35 return;
36
37 _afterFrameRenderHandler = () =>
38 {
39 if (!_disposed)
40 Interlocked.Exchange(ref _pendingFrame, 1);
41 };
42
43 Engine.Instance.AfterFrameRender += _afterFrameRenderHandler;
44 }
45
50 internal bool ConsumeFrameRequest() =>
51 !_disposed && Interlocked.Exchange(ref _pendingFrame, 0) != 0;
52
58 internal void BeginPaint(int width, int height)
59 {
60 if (!_disposed)
61 SetDestinationSize(width, height);
62 }
63
71 public override void Present(SKImage bufferImage, SKRectI bufferRect, SKRect destRect)
72 {
73 bufferImage.Dispose();
74 }
75
77 public void Dispose()
78 {
79 if (_disposed)
80 return;
81
82 _disposed = true;
83 Interlocked.Exchange(ref _pendingFrame, 0);
84
85 if (_afterFrameRenderHandler is not null)
86 {
87 Engine.Instance.AfterFrameRender -= _afterFrameRenderHandler;
88 _afterFrameRenderHandler = null;
89 }
90 }
91}
override void Present(SKImage bufferImage, SKRectI bufferRect, SKRect destRect)
Not used by the WebGL path. GPU rendering and presentation both occur in the SKGLView paint callback.
void Dispose()
Releases the engine frame-request subscription.
void SetDestinationSize(int destWidth, int destHeight)
Sets the destination size of the render surface and raises the Resized event if the dimensions have c...
RenderSurfaceAdapterBase(int destWidth, int destHeight)
Initializes a new instance of the RenderSurfaceAdapterBase class with the specified dimensions.