8public sealed partial class RenderSurfaceHost<TBackbuffer>
9 where TBackbuffer : BackbufferBase
11 private int _presentationInvalidated = 1;
36 internal override void PresentBackbufferToAdapter()
38 if (RenderSurfaceAdapter is
null)
41 Backbuffer.EndFrame();
43 if (RedrawDirtyRectangleOnly && Interlocked.Exchange(ref _presentationInvalidated, 0) == 0)
44 PresentBackbufferRect();
46 PresentBackbufferAll();
48 Backbuffer.ClearDirtyRectangle();
49 Backbuffer.BeginFrame();
52 internal override void InvalidatePresentation() => Interlocked.Exchange(ref _presentationInvalidated, 1);
54 private void PresentBackbufferAll()
56 if (Backbuffer ==
null)
59 var img = Backbuffer.Snapshot();
61 var src =
new SKRectI(
67 var dst = RenderSurfaceAdapter.Presentation.DestinationRect;
73 private void PresentBackbufferRect()
75 if (Backbuffer ==
null)
78 var dirty = Backbuffer.DirtyRectangle;
83 var bounds =
new Rectangle(
89 var clamped = Rectangle.Intersect(dirty, bounds);
94 var img = Backbuffer.Snapshot();
98 RenderSurfaceAdapter!.Present(
104 RenderSurfaceAdapter.Width,
105 RenderSurfaceAdapter.Height)
106 .ScreenRectToAdapterRect(clamped).ToSKRect()));
Represents the core game engine singleton responsible for managing the main update loop,...
static Engine Instance
Gets the singleton instance of the Engine.
IUiDispatcher? UiDispatcher
Gets the UI dispatcher used for marshalling operations to the UI thread.
bool RedrawDirtyRectangleOnly
Gets or sets a value indicating whether only the dirty (changed) regions of the backbuffer are presen...
void Post(Action action)
Asynchronously posts an action to be executed on the UI thread. This method queues the action and ret...
readonly record struct PresentationTransform(float Scale, SKRect DestinationRect)
Aspect-preserving mapping between logical Backbuffer ScreenPx and adapter pixels.