Browse Source
Apply optimizations in Avalonia iOS (#20969)
* Apply optimizations on Avalonia iOS
* Updated benchmarks
* More changes
* Removed iOS Benchmarks project
pull/21048/head
Javier Suárez
6 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
11 additions and
19 deletions
-
src/iOS/Avalonia.iOS/DispatcherImpl.cs
-
src/iOS/Avalonia.iOS/InputHandler.cs
-
src/iOS/Avalonia.iOS/TextInputResponder.cs
|
|
|
@ -22,7 +22,8 @@ internal class DispatcherImpl : IDispatcherImplWithExplicitBackgroundProcessing |
|
|
|
private readonly IntPtr _mainLoop; |
|
|
|
private readonly IntPtr _mainQueue; |
|
|
|
private Thread? _loopThread; |
|
|
|
private bool _backgroundProcessingRequested, _signaled; |
|
|
|
private bool _backgroundProcessingRequested; |
|
|
|
private int _signaled; |
|
|
|
|
|
|
|
private unsafe DispatcherImpl() |
|
|
|
{ |
|
|
|
@ -60,15 +61,12 @@ internal class DispatcherImpl : IDispatcherImplWithExplicitBackgroundProcessing |
|
|
|
|
|
|
|
public unsafe void Signal() |
|
|
|
{ |
|
|
|
lock (_sync) |
|
|
|
if (Interlocked.CompareExchange(ref _signaled, 1, 0) != 0) |
|
|
|
{ |
|
|
|
if (_signaled) |
|
|
|
return; |
|
|
|
_signaled = true; |
|
|
|
|
|
|
|
Interop.dispatch_async_f(_mainQueue, IntPtr.Zero, &CheckSignaled); |
|
|
|
Interop.CFRunLoopWakeUp(_mainLoop); |
|
|
|
return; |
|
|
|
} |
|
|
|
Interop.dispatch_async_f(_mainQueue, IntPtr.Zero, &CheckSignaled); |
|
|
|
Interop.CFRunLoopWakeUp(_mainLoop); |
|
|
|
} |
|
|
|
|
|
|
|
public void UpdateTimer(long? dueTimeInMs) |
|
|
|
@ -91,14 +89,7 @@ internal class DispatcherImpl : IDispatcherImplWithExplicitBackgroundProcessing |
|
|
|
|
|
|
|
private void CheckSignaled() |
|
|
|
{ |
|
|
|
bool signaled; |
|
|
|
lock (_sync) |
|
|
|
{ |
|
|
|
signaled = _signaled; |
|
|
|
_signaled = false; |
|
|
|
} |
|
|
|
|
|
|
|
if (signaled) |
|
|
|
if (Interlocked.Exchange(ref _signaled, 0) != 0) |
|
|
|
{ |
|
|
|
Signaled?.Invoke(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -308,7 +308,7 @@ internal sealed class InputHandler |
|
|
|
|
|
|
|
_tl.Input?.Invoke(new RawMouseWheelEventArgs( |
|
|
|
_mouseDevice, |
|
|
|
(ulong)(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()), |
|
|
|
(ulong)Environment.TickCount64, |
|
|
|
Root, |
|
|
|
_cachedScrollLocation ?? new Point(0, 0), |
|
|
|
new Vector(deltaX, deltaY), |
|
|
|
@ -372,7 +372,7 @@ internal sealed class InputHandler |
|
|
|
// until the inertia stops.
|
|
|
|
_tl.Input?.Invoke(new RawMouseWheelEventArgs( |
|
|
|
_mouseDevice, |
|
|
|
(ulong)(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()), |
|
|
|
(ulong)Environment.TickCount64, |
|
|
|
Root, |
|
|
|
_cachedScrollLocation.Value, |
|
|
|
new Vector(_momentumVelocityX, _momentumVelocityY), |
|
|
|
|
|
|
|
@ -84,6 +84,7 @@ partial class AvaloniaView |
|
|
|
private int _inSurroundingTextUpdateEvent; |
|
|
|
private readonly UITextPosition _beginningOfDocument = new AvaloniaTextPosition(0); |
|
|
|
private readonly UITextInputStringTokenizer _tokenizer; |
|
|
|
private readonly NSString _textInputContextIdentifier = new NSString(Guid.NewGuid().ToString()); |
|
|
|
private bool _isInUpdate; |
|
|
|
|
|
|
|
public TextInputMethodClient? Client => _client; |
|
|
|
@ -95,7 +96,7 @@ partial class AvaloniaView |
|
|
|
public override UIEditingInteractionConfiguration EditingInteractionConfiguration => |
|
|
|
UIEditingInteractionConfiguration.Default; |
|
|
|
|
|
|
|
public override NSString TextInputContextIdentifier => new NSString(Guid.NewGuid().ToString()); |
|
|
|
public override NSString TextInputContextIdentifier => _textInputContextIdentifier; |
|
|
|
|
|
|
|
public override UITextInputMode TextInputMode |
|
|
|
{ |
|
|
|
|