-
Notifications
You must be signed in to change notification settings - Fork 982
Closed
Labels
BUGunexpected behaviorunexpected behavior
Description
Bug Report
Issue:
Very poor performance, only 10-20FPS
Referring to #2419 could solve the performance issue, but I am not sure about the problems encountered on .NET Framework, so it was not ultimately resolved.
#2419 method:
Modify source code
Path: ScottPlot-main\src\ScottPlot5\ScottPlot5\Extensions\SkiaSharpExtensions.cs
Add a static SKTypeface to avoid searching for SKTypeface every time rendering occurs.
Finally build the .dll
//Add
private static SKTypeface? _typeface = null;
public static void ApplyToPaint(this FontStyle fontStyle, SKPaint paint)
{
SKFontStyleWeight weight = fontStyle.Bold ? SKFontStyleWeight.Bold : SKFontStyleWeight.Normal;
SKFontStyleSlant slant = fontStyle.Italic ? SKFontStyleSlant.Italic : SKFontStyleSlant.Upright;
SKFontStyleWidth width = SKFontStyleWidth.Normal;
SKFontStyle skfs = new(weight, width, slant);
//SKTypeface typeface = SKTypeface.FromFamilyName(fontStyle.Name, skfs);
//Add choose one of the two, they are the same
SKTypeface typeface = _typeface ?? (_typeface = SKTypeface.FromFamilyName(fontStyle.Name, skfs));
//SKTypeface typeface = (_typeface == null) ? _typeface = SKTypeface.FromFamilyName(fontStyle.Name, skfs) : _typeface;
paint.Typeface = typeface;
paint.TextSize = fontStyle.Size;
paint.Color = fontStyle.Color.ToSKColor();
paint.IsAntialias = fontStyle.AntiAlias;
}Reproducing:
a code sample
Xaml:
<ScottPlot:AvaPlot Name="AvaPlot1" />
C#:
double[] dataX = { 1, 2, 3, 4, 5 };
double[] dataY = { 1, 4, 9, 16, 25 };
AvaPlot avaPlot1 = this.Find<AvaPlot>("AvaPlot1");
avaPlot1.Plot.Add.Scatter(dataX, dataY);
avaPlot1.Refresh();System Details
- ScottPlot Version: 5.0.6 beta
- Operating System: Ubuntu20.04、Ubuntu22.04、WSL
- Application Type: Avalonia11.0.2
- .NET Version: .NET 6.0、.NET 7.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BUGunexpected behaviorunexpected behavior
