Skip to content

Composition-aware geometries and drawing change detection - #21682

Merged
MrJul merged 4 commits into
AvaloniaUI:masterfrom
MrJul:compositor-aware-geometry-2
Jul 3, 2026
Merged

MrJul merged 4 commits into
AvaloniaUI:masterfrom
MrJul:compositor-aware-geometry-2

Conversation

@MrJul

@MrJul MrJul commented Jul 1, 2026

Copy link
Copy Markdown
Member

What does the pull request do?

This PR has 3 parts related to change propagation in geometries and drawings, listed below.
(Each commit can be reviewed independently. I didn't split the PR because drawing changes need the 3 of them to work properly.)

Compositor-aware Geometry

  • Geometry is now a compositor-aware resource: usages of geometries are tracked. Controls that render geometries are automatically re-rendered when the geometries change, as is the case for brushes.
  • The server counterpart of Geometry is ServerCompositionSimpleGeometry, which holds an IGeometryImpl.

DrawingBrush change propagation

  • DrawingBrush now uses the same mechanism as VisualBrush to track the changes to its Drawing property and re-serialize them.
  • ServerCompositionSimpleContentBrush, its server counterpart, now properly observes the changes to its resources, which can include geometries.

Drawing change detection

  • Drawing and DrawingGroup now invalidate themselves when their inner drawings are replaced.
  • DrawingImage and DrawingBrush make use of that to re-serialize the changes to the compositor.

Fixed issues

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0067027-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@TomEdwardsEnscape

Copy link
Copy Markdown
Contributor

Thanks for finally implementing this! It's I think the very first bug that I reported after I started using Avalonia.

kekekeks
kekekeks previously approved these changes Jul 2, 2026

@kekekeks kekekeks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general, but with some notes

Comment thread src/Avalonia.Base/Media/Drawing.cs Resolved
RaiseInvalidated();
}

private void ChildInvalidated(object? sender, EventArgs e)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have some pre-existing protection against reference cycles, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't. Even before that PR, you could have a drawing reference cycle that would result in a stack overflow. This should be handled independently of this PR, imo.

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0067111-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul
MrJul added this pull request to the merge queue Jul 3, 2026
Merged via the queue into AvaloniaUI:master with commit ee767d5 Jul 3, 2026
10 checks passed
@MrJul
MrJul deleted the compositor-aware-geometry-2 branch July 3, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatic geometry invalidation DrawingImage does not update if Drawing properties change

4 participants