diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest b/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest
index 735a7ed..5e5a7db 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest
@@ -12,7 +12,7 @@
+ Version="1.0.42.0" />
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsLine.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsLine.cs
index f18d92d..4363311 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsLine.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsLine.cs
@@ -64,10 +64,15 @@ namespace BetterLyrics.WinUI3.Models
CanvasTextLayout.HorizontalAlignment = type.ToCanvasHorizontalAlignment();
}
- public void UpdateTextGeometry()
+ public void DisposeTextGeometry()
{
TextGeometry?.Dispose();
TextGeometry = null;
+ }
+
+ public void UpdateTextGeometry()
+ {
+ DisposeTextGeometry();
if (CanvasTextLayout == null)
{
return;
@@ -75,12 +80,17 @@ namespace BetterLyrics.WinUI3.Models
TextGeometry = CanvasGeometry.CreateText(CanvasTextLayout);
}
- public void UpdateFontEffect(ICanvasAnimatedControl control, bool drawStroke, Color strokeColor, int strokeWidth, Color fontColor)
+ public void DisposeFontEffects()
{
BackgroundFontEffect?.Dispose();
BackgroundFontEffect = null;
ForegroundFontEffect?.Dispose();
ForegroundFontEffect = null;
+ }
+
+ public void UpdateFontEffect(ICanvasAnimatedControl control, bool drawStroke, Color strokeColor, int strokeWidth, Color fontColor)
+ {
+ DisposeFontEffects();
if (TextGeometry == null)
{
return;
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel.Draw.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel.Draw.cs
index 30ff708..2a7bb94 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel.Draw.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel.Draw.cs
@@ -258,7 +258,7 @@ namespace BetterLyrics.WinUI3.ViewModels
}
);
- if (line.HighlightOpacityTransition.Value != 0)
+ if (line.HighlightOpacityTransition.Value !=0)
{
// 再叠加高亮行歌词层(前景歌词层)
using var mask = new CanvasCommandList(control.Device);
@@ -431,6 +431,9 @@ namespace BetterLyrics.WinUI3.ViewModels
// Reset scale
ds.Transform = Matrix3x2.Identity;
+
+ line.DisposeFontEffects();
+ line.DisposeTextGeometry();
}
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel.Update.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel.Update.cs
index 2e60102..32cc5e8 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel.Update.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/LyricsRendererViewModel.Update.cs
@@ -6,6 +6,7 @@ using Microsoft.Graphics.Canvas.Text;
using Microsoft.Graphics.Canvas.UI.Xaml;
using Microsoft.UI;
using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -238,7 +239,7 @@ namespace BetterLyrics.WinUI3.ViewModels
UpdateCanvasYScrollOffset(control, false, true);
}
- UpdateLinesProps();
+ UpdateLinesProps(control);
_isLayoutChanged = false;
@@ -288,11 +289,9 @@ namespace BetterLyrics.WinUI3.ViewModels
continue;
}
- line.UpdateTextLayout(control, _lyricsTextFormat, _maxLyricsWidth, _canvasHeight, _isDockMode ? TextAlignmentType.Center : _lyricsAlignmentType);
- line.UpdateTextGeometry();
line.Position = new Vector2(0, y);
+ line.UpdateTextLayout(control, _lyricsTextFormat, _maxLyricsWidth, _canvasHeight, _isDockMode ? TextAlignmentType.Center : _lyricsAlignmentType);
line.UpdateCenterPosition(_maxLyricsWidth, _isDockMode ? TextAlignmentType.Center : _lyricsAlignmentType);
- line.UpdateFontEffect(control, _isDesktopMode, _strokeFontColor, _lyricsFontStrokeWidth, _bgFontColor);
if (line.CanvasTextLayout == null)
{
@@ -501,7 +500,7 @@ namespace BetterLyrics.WinUI3.ViewModels
_isLayoutChanged = true;
}
- private void UpdateLinesProps()
+ private void UpdateLinesProps(ICanvasAnimatedControl control)
{
var currentPlayingLine = _lyricsDataArr
.ElementAtOrDefault(_langIndex)
@@ -515,6 +514,9 @@ namespace BetterLyrics.WinUI3.ViewModels
if (line == null) continue;
+ line.UpdateTextGeometry();
+ line.UpdateFontEffect(control, _isDesktopMode, _strokeFontColor, _lyricsFontStrokeWidth, _bgFontColor);
+
if (_isLayoutChanged || _isVisibleLinesBoundaryChanged || _isPlayingLineChanged)
{
float distanceFromPlayingLine = Math.Abs(line.Position.Y - currentPlayingLine.Position.Y);