diff --git a/src/Skia/Avalonia.Skia/SKPaintCache.cs b/src/Skia/Avalonia.Skia/SKPaintCache.cs
index 79f9575591..9d80e3a729 100644
--- a/src/Skia/Avalonia.Skia/SKPaintCache.cs
+++ b/src/Skia/Avalonia.Skia/SKPaintCache.cs
@@ -1,13 +1,11 @@
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Collections.Concurrent;
using SkiaSharp;
namespace Avalonia.Skia
{
+ ///
+ /// Cache for SKPaints.
+ ///
internal static class SKPaintCache
{
private static ConcurrentBag s_cachedPaints;
@@ -17,6 +15,14 @@ namespace Avalonia.Skia
s_cachedPaints = new ConcurrentBag();
}
+ ///
+ /// Gets a SKPaint for usage.
+ ///
+ ///
+ /// If a SKPaint is in the cache, that existing SKPaint will be returned.
+ /// Otherwise a new SKPaint will be created.
+ ///
+ ///
public static SKPaint Get()
{
if (!s_cachedPaints.TryTake(out var paint))
@@ -27,12 +33,24 @@ namespace Avalonia.Skia
return paint;
}
+ ///
+ /// Returns a SKPaint for reuse later.
+ ///
+ ///
+ /// Do not use the paint further.
+ /// Do not return the same paint multiple times as that will break the cache.
+ /// Uses SKPaint.Reset() for reuse later.
+ ///
+ ///
public static void Return(SKPaint paint)
{
paint.Reset();
s_cachedPaints.Add(paint);
}
+ ///
+ /// Clears and disposes all cached paints.
+ ///
public static void Clear()
{
while (s_cachedPaints.TryTake(out var paint))