|
|
|
@ -33,6 +33,7 @@ namespace Avalonia.Rendering.Composition |
|
|
|
internal IEasing DefaultEasing { get; } |
|
|
|
private List<Action>? _invokeOnNextCommit; |
|
|
|
private readonly Stack<List<Action>> _invokeListPool = new(); |
|
|
|
private Task? _lastBatchCompleted; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a new compositor on a specified render loop that would use a particular GPU
|
|
|
|
@ -86,7 +87,7 @@ namespace Avalonia.Rendering.Composition |
|
|
|
if (_invokeOnNextCommit != null) |
|
|
|
ScheduleCommitCallbacks(batch.Completed); |
|
|
|
|
|
|
|
return batch.Completed; |
|
|
|
return _lastBatchCompleted = batch.Completed; |
|
|
|
} |
|
|
|
|
|
|
|
async void ScheduleCommitCallbacks(Task task) |
|
|
|
@ -139,5 +140,15 @@ namespace Avalonia.Rendering.Composition |
|
|
|
_invokeOnNextCommit ??= _invokeListPool.Count > 0 ? _invokeListPool.Pop() : new(); |
|
|
|
_invokeOnNextCommit.Add(action); |
|
|
|
} |
|
|
|
|
|
|
|
public void InvokeWhenReadyForNextCommit(Action action) |
|
|
|
{ |
|
|
|
if (_lastBatchCompleted == null || _lastBatchCompleted.IsCompleted) |
|
|
|
Dispatcher.UIThread.Post(action, DispatcherPriority.Composition); |
|
|
|
else |
|
|
|
_lastBatchCompleted.ContinueWith( |
|
|
|
static (_, state) => Dispatcher.UIThread.Post((Action)state!, DispatcherPriority.Composition), |
|
|
|
action); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|