209 Commits

Author SHA1 Message Date
Nikita Tsukanov 697cba7193 Composition system SP1 (#20497)
* baseline benchmark

* Composition system SP1

* Allow reusing the same BitmapCache object for multiple visuals

* Fix warnings

* Address review

* API suppressions

---------

Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
2026-02-06 11:15:47 +00:00
Julien Lebosquain 656d691940 Move ConstructorArgumentAttribute and remove BindingMode from ReflectionBinding constructor (#20589)
* Move ConstructorArgumentAttribute to Avalonia.Base assembly

* Move IOptionalFeatureProvider to Avalonia namespace

* Remove BindingMode from ReflectionBinding constructor

* Update API suppressions
2026-02-04 03:14:54 +00:00
Benedikt Stebner e8424283fe Universal GlyphTypeface implementation (#19852)
* Introduce a universal IGlyphTypeface implementation that does not rely on any platform implementation

* Revert changes

* Fix Android

* Make the test happy

* Fix build

* Update baseline

* Fix naming

* Fix headless

* Move interfaces to dedicated files
Make GlyphTypeface.GlyphCount an integer

* Fix GlyphCount

* Make IGlyphTypeface NotClientImplementable

* Make sure we cache platform typefaces by their desired name, style, weight and stretch

* Update baseline

* Only use IGlyphTypeface

* Fix Android

* Try to clear the buffer before we encode somethimg

* Add needed test font

* Add more unit tests

* Reduce allocations

* Remove Direct2D1 test files

* More tests

* More complete table implementations

* More adjustments

* Use batch APIs

* Handle invalid timestamps

* Update baseline

* Introduce a CharacterToGlyphMap struct for faster access

* Remove AggressiveInlining

* Remove AggressiveInlining

* Make the head table optional for legacy fonts

* Remove Load method. Fix TextBlockTests

* Fix nullables

* Remove redundant folder

* Update Api baseline

* revert diff helper changes

* revert changes

* Use bare minimum font for Headless platform and introduce a test font manager that uses the Inter font for testing.

* Add missing font file for Headless platform

---------

Co-authored-by: Gillibald <stebner@avaloniaui.net>
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
2026-01-09 15:07:28 +00:00
Youssef Victor c9e210eb70 Update to xunit.v3 (#20331)
* Update to xunit.v3

* Little more progress

* More fixes

* Keep VSTest supported

* Adjust Nuke

* Few fixes

* Fix for xunit 2

* Fix GetData override

* Adjust

* Use MTP for xunit 2

* Fix test

* Better fix

* --no-progress

* Few more fixes

* no progress

* Fix test

* Better fix

* TRX

* Move to Directory.Build.props

* Unify on MTP v2

* Update

* Update to stable

* 1.0.1

* 1.0.2

* Fix some warnings

* Fix more warnings

* Fix more warnings
2026-01-08 20:46:44 +00:00
Steven Kirk f2fc8d02f4 Move IBinding to BindingBase and tidy up some binding APIs (#19589)
* Update ncrunch config.

* Tidy up reflection and multi-binding APIs:

- Move `BindingBase` and `MultiBinding` into Avalonia.Base
- `BindingBase` becomes a true base class for all bindings, and contains only the `Instance` method
- Properties common between reflection and compiled bindings are moved into `StandardBindingBase`
- `Binding` is moved to Avalonia.Base and renamed to `ReflectionBinding`
- A compatibility shim for `Binding` remains in Avalonia.Markup
- Remove `IBinding` and `IBinding2`
- Remove `ITreeDataTemplate's usage of `InstancedBinding`
- Remove `NativeMenuBarPresenter`s usage of `InstancedBinding`
- Remove `InstancedBinding` as it is now unused

This required an update to the DataGrid submodule: cell data validation has been temporarily removed as this used `InstancedBinding`.

* `Instance()` => `CreateInstance()`.

The use of "Instance" as a verb is quite unusual apparently ;)

* Seal classes where appropriate.

* Seal classes where appropriate.

* Remove `StandardBindingBase`.

Simply duplicate the members in reflection and compiled binding classes.

* Delete deleted submodule directory.

* Add missing attribute.

Fixes compile error.

* Fix reference to removed class.

* Update suppressions.
2026-01-08 17:33:14 +00:00
Julien Lebosquain ce0a1c6b3e Update dependencies (#20139)
* Update dependencies

* Partially revert appium upgrades

* Fix integration tests
2025-12-17 15:23:32 +01:00
Dan Walmsley 4ff49db604 Optimization: Add an optimized path for notifying property changes for inherited va… (#18223)
* Add an optimized path for notifying property changes for inherited values

Avoids many allocations of event args.

* fix unit tests with hack to prove concept.

* update docs and remove value tuple that could cause allocation.

* add a benchmark for inherited property change notifications.
2025-03-28 18:10:48 +00:00
Julien Lebosquain aac83dcd53 Layout performance improvements (#18315) 2025-03-28 18:05:26 +00:00
Julien Lebosquain edceb96f34 Improve AvaloniaObject.GetValue performance (#15342)
* Improve AvaloniaProperty.GetValue performance

* Remove unneeded MethodImpl on Optional.GetValueOrDefault

* Use ReferenceEqualityComparer instead of TypeEqualityComparer

---------

Co-authored-by: Jumar Macato <16554748+jmacato@users.noreply.github.com>
2024-04-23 12:30:51 +00:00
Max Katz 326ef7c9fd Add .NET 8 target (Avalonia 11.1) (#14535)
* Add .NET 8 target to packable projects

* Update test projects

* Update sample projects to target .NET 8

* Update main Avalonia package to target .NET 8 as well

* Remove MSBuildEnableWorkloadResolver hack and some minor change

* Use net8.0 in nuke build as well

* Pin 8.0.0 SDK

* Adjust API validation

* Pin a valid version

* Remove net461 target from Avalonia package

* Remove unused net6.0 target from Avalonia.Designer.HostApp

* Adjust API diff

* Update ControlCatalog.Android.csproj

* Remove MSBuildEnableWorkloadResolver

* Fix Browser issues on .NET 8

* Fix .NET 8 error

* Fix merge conflicts

* Replace explicit TFMs in .csproj files with a centralized registry

* Fix merge conflict

* Fix AvsLegacyWindowsTargetFrameworks and add hacks for the tests

* Update XCode project CommandLineArgument

---------

Co-authored-by: Nikita Tsukanov <keks9n@gmail.com>
2024-03-05 13:37:26 -08:00
Steven Kirk 3b1eb338e6 Binding System refactor (#13970)
* Update ncrunch config.

* WIP: Benchmarks

* Initial refactor of binding infrastructure.

- `ExpressionObserver` has been removed and its functionality merged with `BindingExpression`
- `BindingExpression` handles all types of `BindingMode` itself; doesn't require `BindingOperations.Apply` to set up a separate observable for `TwoWay/`OneWayToSource` bindings
  - This allows us to fix some long-standing issues with `OneWayToSource` bindings
- Expression nodes have been refactored
  - No longer split between `Avalonia.Base` and `Avalonia.Markup`
  - Categorize them according to whether they use reflection or not

A few tests are failing around binding warnings: this is because the next step here is to fix binding warnings.

* Make default binding Source = UnsetProperty.

Null is a theoretically valid value for `Source`; setting it to null shouldn't mean "use the data context".

* Move logging to BindingExpression.

As `BindingExpression` now has enough information to decide when it's appropriate to log an error/warning or not.

Fixes #5762
Fixes #9422

* Add compatibility hack for older compiled bindings.

Previously, `CompiledBindingPathBuilder` didn't have a `TemplatedParent` method and instead the XAML compiler rewrite templated parent bindings to be a `$self.TemplateParent` property binding. resulting in extraneous logs.

Add a constructor with an  `apiVersion`  to `CompiledBindingPathBuilder` which will be used by newer versions of the XAML compiler, and if a usage is detected using an `apiVersion` of 0, then upgrade `$self.TemplatedParent` to use a `TemplatedParentPathElement`.

* Log errors from property accessors.

* Don't log errors for named control bindings...

...on elements which aren't yet rooted.

* Log errors for failed conversions.

* Use consistent wording for binding warnings.

"Could not convert" instead of "Cannot convert".

* Log warnings for converter exceptions.

* Don't convert new TargetTypeConverters each time.

* Added failing test for implicit conversion.

* Support cast operators in compiled bindings.

A bit of a hack as we'd ideally not be using reflection when using compiled bindings.

* This shouldn't be a public API.

Should only be used for tests.

* Make enum/int conversion work.

* Check for SetValue equality after conversion.

And also use "identity equals" where value types and strings use `object.Equals` and reference types use `object.ReferenceEquals`.

* Added ConverterCulture back to bindings.

* Fix merge error.

Removed deleted files from csproj that were re-added due to indentation changes.

* Use BindingExpression directly in ValueStoe.

* Introduce BindingExpressionBase.

And `UntypedBindingExpressionBase`.

* Make TemplateBinding a BindingExpression.

* Make DynamicResource use a BindingExpression.

* WIP: Start exposing a BindingExpression API.

* Finish exposing a BindingExpression API.

* Fix OneTimeBinding.

* Remove unneeded classes/methods.

* Don't call obsolete API.

* Make BindingExpressionBase the public API.

This matches WPF's API.

* Added BindingExpressionBase.UpdateTarget.

* Initial implementation of UpdateSourceTrigger.

* Don't use weak references for values.

If they're boxed values, they can get collected.

* No need for virtual/generic methods here now.

* Reintroduce support for binding anchors.

Turns out these were needed by animations, just our animation system has no unit tests so I missed that fact earlier. Add a basic animation unit test that fails without anchor support, and add binding anchors back in. Currently a private API as I suspect this feature shouldn't be needed outside the framework.

* Include new property in clone.

And add real-life example of `UpdateSourceTrigger=LostFocus` to BindingDemo.

* Fix merge error.

* Updated BindingExpression tests.

- Make them run for both compiled and reflection bindings (found a bunch of tests that fail with compiled bindings)
- Make them not depend on converting the `BindingExpression` to an observable and instead test the end result of the binding on an `AvaloniaObject`

* Fix compiled binding indexer tests.

* Use data validation plugins in PropertyAccessorNode.

Added a warning suppression for now: we may need a separate `DataValidators` list for AOT-friendly plugins.

* Don't separate plugins by reflection.

`DataAnnotationsValidationPlugin` is public and so it can't be moved. No point in moving the others if this one will be in the wrong place.

* Remove unneeded methods.

* Make reflection binding tests use a string.

Convert the `System.Linq.Expression` to a string and then use this, as reflection bindings will always be instanced with a string path.

* Added TODO12 plan for IBinding2.

* Use more specific exception.

* Fix nits from code review.

* Make expression nodes sealed where possible.

* Unsubscribe on Stop, don't re-subscribe.

D'oh.

* Tweak ExpressionNode lists.

Saves a few K in benchmarks and it's a cleaner API.

* Add a pooled option in BindingExpressionGrammar.

Micro-optimization.

* Avoid allocations when enumerating binding plugins.

* Add IBinding2 support to observable bind overloads.

In the case of `TemplateBinding`, the `IObservable<object?>` bind overload is selected by C#. Add an explicit check for an `IBinding2` here to use the more performant code-path.

* Remove disposed binding from ImmediateBindingFrame.

* Added TemplateBinding benchmarks.

* Remove duplicate items.

Seems to have been caused by a merge error.

* Fix exception when closing color picker.

And add tests.

* Don't skip converter when binding to self.

* Don't pass UnsetValue to converters.

This follows WPF behavior.

* Log element name if present.

More useful than just logging the control hash code.

* Respect binding priority.

* Throw on mismatched binding priorities.

We don't want to respect the binding priority in this case as it breaks `TemplateBindings` when the default `LocalValue` priority is passed. Instead make sure that the priority parameter matches that of the expression.

This reverts commit a72765d70514506d94b39ba33a3d91e11cd6dcd4.

* Convert to target type in TemplateBinding.

* Short-circuit target type conversion for same types.
2024-01-29 08:08:26 +00:00
Max Katz 4c0873eb9a Fix build 2023-06-28 15:05:41 -04:00
Steven Kirk 04c50f8bf2 Make style selector internals internal. 2023-05-18 13:34:42 +02:00
Steven Kirk 5b7d5a33ae Fix benchmarks compile error, 2023-05-15 14:04:27 +02:00
Max Katz 2701d686a9 Merge branch 'nunit-headless-intergration' into unify-test-mocks
# Conflicts:
#	tests/Avalonia.UnitTests/TestServices.cs
2023-05-01 02:40:42 -04:00
Max Katz 810558140f Introduce static AssetLoader 2023-04-29 23:25:05 -04:00
Max Katz 4aa6035ec3 Reuse text and geometry related headless mocks in Avalonia unit tests and benchmarks 2023-04-27 23:16:02 -04:00
Max Katz a507e92b31 Fix theme-dependend markup extensions not knowing current theme context 2023-04-24 02:00:30 -04:00
Nikita Tsukanov 312f1250e2 Don't use AvaloniaObject in IPlatformRenderInterface 2023-03-30 00:29:48 +06:00
Nikita Tsukanov 0f4ed2a4b9 Updated tests to use IDispatcherImpl 2023-03-20 15:15:53 +06:00
Nikita Tsukanov 17492be5b6 Removed RunLoop from IPlatformThreadingInterface 2023-03-20 13:26:16 +06:00
Dariusz Komosinski d9d208b935 Add benchmark for Or selector and avoid extra virtual calls getting list count. 2023-03-05 17:49:45 +01:00
Benedikt Stebner 147db08f90 Introduce GlyphRun.Bounds 2023-03-02 12:34:34 +01:00
Nikita Tsukanov ae1fcfed51 Refactored DrawingContext and VisualBrush, added DrawingBrush (#10419)
Refactored DrawingContext and VisualBrush, added DrawingBrush
2023-02-23 08:07:51 +00:00
Benedikt Stebner f5caa61051 [SKIA] UseOpacitySaveLayer feature switch (#9964)
* [SKIA] Introduce UseOpacitySaveLayer feature switch

* Only maintain _currentOpacity when OpacitySaveLayer is disabled
2023-02-20 20:10:23 +03:00
José Pedro f8af158a38 Updated packages used by tests. 2023-02-05 01:23:04 +00:00
Max Katz 6a4c8d2603 Merge branch 'master' into themeresource 2023-01-31 16:16:59 -05:00
Max Katz 9ad3386547 Merge branch 'master' into themeresource 2023-01-31 14:49:30 -05:00
Benedikt Stebner 5bb1ca286b Merge branch 'master' into textlayout-wrapping-perf 2023-01-31 20:35:59 +01:00
Benedikt Stebner bfed891713 Merge branch 'master' into textlayout-wrapping-perf 2023-01-31 18:15:58 +01:00
Julien Lebosquain 5e13c5b59a Implemented layout and render time graph overlays 2023-01-31 15:40:17 +01:00
Nikita Tsukanov abf8819947 Implemented pixel format transcoding for Bitmap and WriteableBitmap 2023-01-29 11:59:09 +06:00
Max Katz 6cb4ee0a73 Merge branch 'master' into themeresource 2023-01-27 15:56:24 -05:00
Benedikt Stebner 94686510ef Merge branch 'master' into textlayout-wrapping-perf 2023-01-25 09:32:43 +01:00
Julien Lebosquain 5ffd961742 Perf: improved text wrapping 2023-01-24 16:34:00 +01:00
Benedikt Stebner cb884c6e9e Reintroduce customizable GlyphRun.BaselineOrigin
Reintroduce Brush IBrush inheritance
2023-01-24 10:40:53 +01:00
Julien Lebosquain 7a1f74a3d3 Benchmarks: option to use Skia for text layout 2023-01-22 15:39:40 +01:00
Julien Lebosquain 10a3b79d12 Perf: various misc text layout optimizations 2023-01-22 15:18:42 +01:00
Nikita Tsukanov 6277be5cfa Merge branch 'master' into feature/gpu-external-memory 2023-01-21 11:51:21 +03:00
Nikita Tsukanov ba13f293b3 Merge branch 'master' into feature/gpu-external-memory 2023-01-21 01:26:17 +03:00
Benedikt Stebner 07c11c75e7 Use IGlyphRunImpl in the IDrawingContextImpl 2023-01-20 20:28:54 +01:00
Julien Lebosquain 89a78f557b Don't keep the text layout buffers around if they're too large 2023-01-19 18:39:25 +01:00
Nikita Tsukanov 2b4cd42196 Merge branch 'master' into feature/gpu-external-memory 2023-01-19 08:37:28 +03:00
Nikita Tsukanov d714f37fce Implemented interop with externally managed GPU memory 2023-01-19 11:29:46 +06:00
Julien Lebosquain fd0720fc56 Updated text layout benchmark with trimming/wrapping 2023-01-19 04:27:58 +01:00
Julien Lebosquain 4144be11fe Pass GlyphInfo directly to GlyphRun 2023-01-19 04:27:56 +01:00
Max Katz a0d22499cd Fix benchmarks build 2023-01-18 02:39:11 -05:00
Max Katz be22b361c8 Add theme variants specific tests 2023-01-18 02:13:09 -05:00
Benedikt Stebner e84193bdca Merge branch 'master' into ShapedBufferPooling 2023-01-11 19:44:17 +01:00
Benedikt Stebner 74bbfd8509 Support intercepts for all location but TextDecorationLocation.Strikethrough 2023-01-11 15:35:07 +01:00