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

Made clear behavior in RenderTargetBitmap.CreateDrawingContext optional #12793

Merged
merged 9 commits into from
Sep 10, 2023
Merged

Made clear behavior in RenderTargetBitmap.CreateDrawingContext optional #12793

merged 9 commits into from
Sep 10, 2023

Conversation

PMahern
Copy link
Contributor

@PMahern PMahern commented Sep 5, 2023

The original behavior is still preserved so this shouldn't be a breaking change for anyone relying on the clear behavior.

What does the pull request do?

The current behavior in RenderTargetBitmap.CreateDrawingContext clears the image every time a DrawingContext is created. This is actually a breaking change from old behavior, I may have missed it but I didn't see it documented as such anywhere. I simply added another CreateDrawingContext(bool clear) function that clears the bitmap if true is passed in and then call it from CreateDrawingContext() with true passed in.

What is the updated/expected behavior with this PR?

Create a RenderTargetBitmap bound to an Image.
Create multiple DrawingContexts via CreateDrawingContext(false) that each draw in different areas of the image.
Both drawn shapes should remain in the image.

Checklist

  • Added XML documentation to any related classes? (I added some documentation to the CreateDawingContext and CreateEditDrawingContext functions about the difference in behavior)

Fixed issues

Fixes #12792

The original behavior is still preserved so this shouldn't be a breaking change for anyone relying on the clear behavior.
@PMahern
Copy link
Contributor Author

PMahern commented Sep 5, 2023

@dotnet-policy-service agree

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0039249-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-cibuild0039255-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

api/Avalonia.nupkg.xml Outdated Show resolved Hide resolved
… editing the current image data and not clearing it.
…ingcontext' of github.com:PMahern/Avalonia into feature/optional-clear-in-rendertargetbitmap-createdrawingcontext
@PMahern
Copy link
Contributor Author

PMahern commented Sep 8, 2023

Here's some pictures of the difference in behavior. Running the RenderDemo on the RenderTargetBitmap page (which renders a rotating square) shows this after a few seconds using CreateDrawingContext() (this is with no other calls to clear the image, just creating a DrawingContext and drawing to it).
image

Changing it to use CreateEditDrawingContext() allows the renders to accumulate in the same image as the square rotates, I added some color changing over time to try and make the difference more obvious. I did notice there's no longer a Clear function on the DrawingContext, was that the motivation behind the original change?

image

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0039331-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-cibuild0039333-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@PMahern PMahern requested a review from grokys September 8, 2023 23:19
@avaloniaui-team
Copy link
Contributor

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

@maxkatz6 maxkatz6 merged commit 050ae37 into AvaloniaUI:master Sep 10, 2023
@PMahern PMahern deleted the feature/optional-clear-in-rendertargetbitmap-createdrawingcontext branch September 11, 2023 17:38
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.

Make call to clear in RenderTargetBitmap.CreateDrawingContext optional
6 participants