Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanKalachik authored and wieslawsoltes committed Mar 14, 2024
1 parent 101c86e commit e4f29f4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
35 changes: 18 additions & 17 deletions src/Avalonia.Svg.Skia/SvgCustomDrawOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,28 @@ public void Dispose()

public void Render(ImmediateDrawingContext context)
{
if (_svg == null)
return;


var leaseFeature = context.TryGetFeature<ISkiaSharpApiLeaseFeature>();
if (leaseFeature is null)
{
return;
}
using var lease = leaseFeature.Lease();
var canvas = lease?.SkCanvas;
if (canvas is null)
{
return;
}
lock (_svg.Locker)
{
if (_svg?.Picture is null)
{
return;
}

var leaseFeature = context.TryGetFeature<ISkiaSharpApiLeaseFeature>();
if (leaseFeature is null)
{
var picture = _svg.Picture;
if (picture is null)
return;
}
using var lease = leaseFeature.Lease();
var canvas = lease?.SkCanvas;
if (canvas is null)
{
return;
}

canvas.Save();
canvas.DrawPicture(_svg.Picture);
canvas.DrawPicture(picture);
canvas.Restore();
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/Svg.Skia/SKSvg.Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,11 @@ private void Reset()
{
Model = null;
Drawable = null;
Picture?.Dispose();
Picture = null;
lock (Locker)
{
Picture?.Dispose();
Picture = null;
}
}

public void Dispose()
Expand Down

0 comments on commit e4f29f4

Please sign in to comment.