Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced Clipping and Rendered Visuals Tracking in ServerCompositionVisual #12568

Merged
merged 7 commits into from
Aug 18, 2023

Conversation

stepangovorko
Copy link
Contributor

What does the pull request do?

This PR enhances the clipping calculation within the ServerCompositionVisual by taking Clip.Bounds into account. The primary goal is to ensure that visuals, which are not within a dirty rect, are not re-rendered when different ClipToBounds and Clip geometry parameters are set.

What is the current behavior?

Currently, ServerCompositionVisual.Render method do nothing if boundaries of the visual do not intersect with DirtyRect. This approach effectively minimizes the areas of the scene redrawn, especially when a single element is invalidated. However, this optimization is only effective when ClipToBounds=true. While having ClipToBounds=false but setting an explicit Clip is valid, it's not considered in the current implementation.

What is the updated/expected behavior with this PR?

After this PR, the ServerCompositionVisual will also consider changes to the Clip property, allowing it to recalculate when the clip is altered. This ensures accurate rendering even when ClipToBounds=false but an explicit Clip is set.

How was the solution implemented (if it's not obvious)?

  1. Clip.Bounds was considered in the clipping calculation within ServerCompositionVisual.
  2. Added unit tests under CompositorInvalidationClippingTests to verify the correct rendering of visuals not in the dirty rect with different ClipToBounds and Clip geometry parameters.
  3. For test purpuses a counter for rendered visuals in ServerCompositionVisual was introduced.

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

In addition, the ServerCompositionVisual now tracks changes to the clip property, allowing for re-calculation when the clip is altered.
…d added relevant unit tests in CompositorInvalidationClippingTests. The new tests ensure that visuals that are not in dirty rect are rendered correctly with different ClipToBounds and Clip geometry parameters.
@maxkatz6 maxkatz6 requested a review from kekekeks August 17, 2023 08:08
@avaloniaui-team
Copy link
Contributor

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

@@ -2,5 +2,7 @@ namespace Avalonia.Rendering.Composition;

internal interface ICompositionTargetDebugEvents
{
public int RenderedVisuals { get; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove public

@kekekeks
Copy link
Member

Please address that "remove public" comment. Otherwize LGTM

@stepangovorko
Copy link
Contributor Author

@dotnet-policy-service agree company="JetBrains GmbH"

@avaloniaui-team
Copy link
Contributor

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

@avaloniaui-team
Copy link
Contributor

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

@kekekeks kekekeks added this pull request to the merge queue Aug 18, 2023
Merged via the queue into AvaloniaUI:master with commit c59e63e Aug 18, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants