Browse Source
Merge pull request #12117 from jgcodes2020/importcompleted-typo-fix
Rename ImportCompeted into ImportCompleted
pull/12200/head
Max Katz
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
30 additions and
7 deletions
-
api/Avalonia.nupkg.xml
-
src/Avalonia.Base/Rendering/Composition/CompositionExternalMemory.cs
-
src/Avalonia.Base/Rendering/Composition/CompositionInterop.cs
-
src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionDrawingSurface.cs
|
|
|
@ -0,0 +1,10 @@ |
|
|
|
<?xml version="1.0" encoding="utf-8"?> |
|
|
|
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids --> |
|
|
|
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
|
|
|
<Suppression> |
|
|
|
<DiagnosticId>CP0006</DiagnosticId> |
|
|
|
<Target>P:Avalonia.Rendering.Composition.ICompositionGpuImportedObject.ImportCompleted</Target> |
|
|
|
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left> |
|
|
|
<Right>target/netstandard2.0/Avalonia.Base.dll</Right> |
|
|
|
</Suppression> |
|
|
|
</Suppressions> |
|
|
|
@ -1,10 +1,13 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Avalonia.Metadata; |
|
|
|
using Avalonia.Platform; |
|
|
|
|
|
|
|
namespace Avalonia.Rendering.Composition; |
|
|
|
|
|
|
|
[NotClientImplementable] |
|
|
|
public interface ICompositionGpuInterop |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
@ -84,14 +87,22 @@ public enum CompositionGpuImportedImageSynchronizationCapabilities |
|
|
|
/// <summary>
|
|
|
|
/// An imported GPU object that's usable by composition APIs
|
|
|
|
/// </summary>
|
|
|
|
[NotClientImplementable] |
|
|
|
public interface ICompositionGpuImportedObject : IAsyncDisposable |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Tracks the import status of the object. Once the task is completed,
|
|
|
|
/// the user code is allowed to free the resource owner in case when a non-owning
|
|
|
|
/// sharing handle was used
|
|
|
|
/// sharing handle was used.
|
|
|
|
/// </summary>
|
|
|
|
Task ImportCompleted { get; } |
|
|
|
|
|
|
|
/// <inheritdoc cref="ImportCompleted"/>
|
|
|
|
/// <seealso cref="ImportCompleted">ImportCompleted (recommended replacement)</seealso>
|
|
|
|
[Obsolete("Please use ICompositionGpuImportedObject.ImportCompleted instead")] |
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)] |
|
|
|
Task ImportCompeted { get; } |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Indicates if the device context this instance is associated with is no longer available
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
@ -67,18 +67,20 @@ abstract class CompositionGpuImportedObjectBase : ICompositionGpuImportedObject |
|
|
|
Context = context; |
|
|
|
Feature = feature; |
|
|
|
|
|
|
|
ImportCompeted = Compositor.InvokeServerJobAsync(Import); |
|
|
|
ImportCompleted = Compositor.InvokeServerJobAsync(Import); |
|
|
|
} |
|
|
|
|
|
|
|
protected abstract void Import(); |
|
|
|
public abstract void Dispose(); |
|
|
|
|
|
|
|
public Task ImportCompeted { get; } |
|
|
|
public Task ImportCompleted { get; } |
|
|
|
|
|
|
|
public Task ImportCompeted => ImportCompleted; |
|
|
|
public bool IsLost => Context.IsLost; |
|
|
|
|
|
|
|
public ValueTask DisposeAsync() => new(Compositor.InvokeServerJobAsync(() => |
|
|
|
{ |
|
|
|
if (ImportCompeted.Status == TaskStatus.RanToCompletion) |
|
|
|
if (ImportCompleted.Status == TaskStatus.RanToCompletion) |
|
|
|
Dispose(); |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
|
@ -31,12 +31,12 @@ internal class ServerCompositionDrawingSurface : ServerCompositionSurface, IDisp |
|
|
|
throw new PlatformGraphicsContextLostException(); |
|
|
|
|
|
|
|
// This should never happen, but check for it anyway to avoid a deadlock
|
|
|
|
if (!image.ImportCompeted.IsCompleted) |
|
|
|
if (!image.ImportCompleted.IsCompleted) |
|
|
|
throw new InvalidOperationException("The import operation is not completed yet"); |
|
|
|
|
|
|
|
// Rethrow the import here exception
|
|
|
|
if (image.ImportCompeted.IsFaulted) |
|
|
|
image.ImportCompeted.GetAwaiter().GetResult(); |
|
|
|
if (image.ImportCompleted.IsFaulted) |
|
|
|
image.ImportCompleted.GetAwaiter().GetResult(); |
|
|
|
} |
|
|
|
|
|
|
|
void Update(IBitmapImpl newImage, IPlatformRenderInterfaceContext context) |
|
|
|
|