Skip to content

Commit

Permalink
perf: Use a single static SKTextBlobBuilder for inlines rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Oct 31, 2023
1 parent 16f9aa9 commit 69fc349
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Uno.UI/UI/Xaml/Documents/InlineCollection.skia.cs
Expand Up @@ -16,6 +16,8 @@ namespace Windows.UI.Xaml.Documents
{
partial class InlineCollection
{
private static SKTextBlobBuilder _textBlobBuilder = new();

private readonly List<RenderLine> _renderLines = new();

private bool _invalidationPending;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 69fc349

Please sign in to comment.