diff --git a/src/Uno.UI/UI/Xaml/Documents/InlineCollection.skia.cs b/src/Uno.UI/UI/Xaml/Documents/InlineCollection.skia.cs index 306c78218d19..b543cb3ed2b5 100644 --- a/src/Uno.UI/UI/Xaml/Documents/InlineCollection.skia.cs +++ b/src/Uno.UI/UI/Xaml/Documents/InlineCollection.skia.cs @@ -16,6 +16,8 @@ namespace Windows.UI.Xaml.Documents { partial class InlineCollection { + private static SKTextBlobBuilder _textBlobBuilder = new(); + private readonly List _renderLines = new(); private bool _invalidationPending; @@ -375,8 +377,7 @@ internal void Draw(in DrawingSession session) } } - using var textBlobBuilder = new SKTextBlobBuilder(); - var run = textBlobBuilder.AllocatePositionedRun(fontInfo.SKFont, segmentSpan.GlyphsLength); + var run = _textBlobBuilder.AllocatePositionedRun(fontInfo.SKFont, segmentSpan.GlyphsLength); var glyphs = run.GetGlyphSpan(); var positions = run.GetPositionSpan(); @@ -427,7 +428,7 @@ internal void Draw(in DrawingSession session) } } - using var textBlob = textBlobBuilder.Build(); + using var textBlob = _textBlobBuilder.Build(); canvas.DrawText(textBlob, 0, y + baselineOffsetY, paint); x += justifySpaceOffset * segmentSpan.TrailingSpaces;