Browse Source

Merge branch 'master' into x11-mate-clipboard

pull/12002/head
viordash 3 years ago
committed by GitHub
parent
commit
15cfd72d76
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      api/Avalonia.nupkg.xml
  2. 13
      src/Avalonia.Base/Rendering/Composition/CompositionExternalMemory.cs
  3. 8
      src/Avalonia.Base/Rendering/Composition/CompositionInterop.cs
  4. 6
      src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionDrawingSurface.cs
  5. 22
      src/Avalonia.Controls/Utils/StringUtils.cs

10
api/Avalonia.nupkg.xml

@ -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>

13
src/Avalonia.Base/Rendering/Composition/CompositionExternalMemory.cs

@ -1,10 +1,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks; using System.Threading.Tasks;
using Avalonia.Metadata; using Avalonia.Metadata;
using Avalonia.Platform; using Avalonia.Platform;
namespace Avalonia.Rendering.Composition; namespace Avalonia.Rendering.Composition;
[NotClientImplementable]
public interface ICompositionGpuInterop public interface ICompositionGpuInterop
{ {
/// <summary> /// <summary>
@ -84,14 +87,22 @@ public enum CompositionGpuImportedImageSynchronizationCapabilities
/// <summary> /// <summary>
/// An imported GPU object that's usable by composition APIs /// An imported GPU object that's usable by composition APIs
/// </summary> /// </summary>
[NotClientImplementable]
public interface ICompositionGpuImportedObject : IAsyncDisposable public interface ICompositionGpuImportedObject : IAsyncDisposable
{ {
/// <summary> /// <summary>
/// Tracks the import status of the object. Once the task is completed, /// 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 /// 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> /// </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; } Task ImportCompeted { get; }
/// <summary> /// <summary>
/// Indicates if the device context this instance is associated with is no longer available /// Indicates if the device context this instance is associated with is no longer available
/// </summary> /// </summary>

8
src/Avalonia.Base/Rendering/Composition/CompositionInterop.cs

@ -67,18 +67,20 @@ abstract class CompositionGpuImportedObjectBase : ICompositionGpuImportedObject
Context = context; Context = context;
Feature = feature; Feature = feature;
ImportCompeted = Compositor.InvokeServerJobAsync(Import); ImportCompleted = Compositor.InvokeServerJobAsync(Import);
} }
protected abstract void Import(); protected abstract void Import();
public abstract void Dispose(); public abstract void Dispose();
public Task ImportCompeted { get; } public Task ImportCompleted { get; }
public Task ImportCompeted => ImportCompleted;
public bool IsLost => Context.IsLost; public bool IsLost => Context.IsLost;
public ValueTask DisposeAsync() => new(Compositor.InvokeServerJobAsync(() => public ValueTask DisposeAsync() => new(Compositor.InvokeServerJobAsync(() =>
{ {
if (ImportCompeted.Status == TaskStatus.RanToCompletion) if (ImportCompleted.Status == TaskStatus.RanToCompletion)
Dispose(); Dispose();
})); }));
} }

6
src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionDrawingSurface.cs

@ -31,12 +31,12 @@ internal class ServerCompositionDrawingSurface : ServerCompositionSurface, IDisp
throw new PlatformGraphicsContextLostException(); throw new PlatformGraphicsContextLostException();
// This should never happen, but check for it anyway to avoid a deadlock // 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"); throw new InvalidOperationException("The import operation is not completed yet");
// Rethrow the import here exception // Rethrow the import here exception
if (image.ImportCompeted.IsFaulted) if (image.ImportCompleted.IsFaulted)
image.ImportCompeted.GetAwaiter().GetResult(); image.ImportCompleted.GetAwaiter().GetResult();
} }
void Update(IBitmapImpl newImage, IPlatformRenderInterfaceContext context) void Update(IBitmapImpl newImage, IPlatformRenderInterfaceContext context)

22
src/Avalonia.Controls/Utils/StringUtils.cs

@ -76,7 +76,7 @@ namespace Avalonia.Controls.Utils
} }
var codepoint = new Codepoint(text[index]); var codepoint = new Codepoint(text[index]);
if (!codepoint.IsWhiteSpace) if (!codepoint.IsWhiteSpace)
{ {
return false; return false;
@ -85,12 +85,20 @@ namespace Avalonia.Controls.Utils
// preceeded by lwsp. // preceeded by lwsp.
if (index > 0) if (index > 0)
{ {
var nextCodePoint = new Codepoint(text[index + 1]); if (index + 1 < text.Length)
{
var nextCodePoint = new Codepoint(text[index + 1]);
if (nextCodePoint.IsBreakChar) if (nextCodePoint.IsBreakChar)
{
return true;
}
}
else
{ {
return true; return true;
} }
} }
switch (codepoint.GeneralCategory) switch (codepoint.GeneralCategory)
@ -125,7 +133,7 @@ namespace Avalonia.Controls.Utils
} }
cursor = Math.Min(cursor, text.Length); cursor = Math.Min(cursor, text.Length);
int begin; int begin;
int i; int i;
int cr; int cr;
@ -181,7 +189,7 @@ namespace Avalonia.Controls.Utils
{ {
return cursor; return cursor;
} }
if (cr < text.Length && text[cr] == '\r' && cr + 1 < text.Length && text[cr + 1] == '\n') if (cr < text.Length && text[cr] == '\r' && cr + 1 < text.Length && text[cr + 1] == '\n')
{ {
lf = cr + 1; lf = cr + 1;
@ -214,9 +222,9 @@ namespace Avalonia.Controls.Utils
{ {
return i; return i;
} }
var cc = GetCharClass(text[i]); var cc = GetCharClass(text[i]);
// skip over the word, punctuation, or run of whitespace // skip over the word, punctuation, or run of whitespace
while (i < cr && GetCharClass(text[i]) == cc) while (i < cr && GetCharClass(text[i]) == cc)
{ {

Loading…
Cancel
Save