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
6 changes: 6 additions & 0 deletions api/Avalonia.nupkg.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
PMahern marked this conversation as resolved.
Show resolved Hide resolved
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Avalonia.Media.Imaging.RenderTargetBitmap.CreateDrawingContext</Target>
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left>
<Right>target/netstandard2.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0006</DiagnosticId>
<Target>P:Avalonia.Rendering.Composition.ICompositionGpuImportedObject.ImportCompleted</Target>
Expand Down
10 changes: 8 additions & 2 deletions src/Avalonia.Base/Media/Imaging/RenderTargetBitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,16 @@ private static IRenderTargetBitmapImpl CreateImpl(PixelSize size, Vector dpi)
return factory.CreateRenderTargetBitmap(size, dpi);
}

public DrawingContext CreateDrawingContext()
/// <summary>
/// Creates a <see cref="DrawingContext"/> for drawing to the <see cref="RenderTargetBitmap"/>.
/// </summary>
/// <param name="clear">Indicates if the image should be cleared.</param>
/// <returns>The drawing context.</returns>
public DrawingContext CreateDrawingContext(bool clear = true)
PMahern marked this conversation as resolved.
Show resolved Hide resolved
{
var platform = PlatformImpl.Item.CreateDrawingContext();
platform.Clear(Colors.Transparent);
if(clear)
platform.Clear(Colors.Transparent);
return new PlatformDrawingContext(platform);
}

Expand Down