增加桌面投影帧率显示
This commit is contained in:
@@ -34,8 +34,6 @@ namespace SpineViewer.Models
|
|||||||
|
|
||||||
public bool FlipY { get; set; } = true;
|
public bool FlipY { get; set; } = true;
|
||||||
|
|
||||||
public uint MaxFps { get; set; } = 30;
|
|
||||||
|
|
||||||
public float Speed { get; set; } = 1f;
|
public float Speed { get; set; } = 1f;
|
||||||
|
|
||||||
public bool ShowAxis { get; set; } = true;
|
public bool ShowAxis { get; set; } = true;
|
||||||
|
|||||||
@@ -143,7 +143,7 @@
|
|||||||
<s:String x:Key="Str_FullScreenTooltip">Window/Fullscreen; F11</s:String>
|
<s:String x:Key="Str_FullScreenTooltip">Window/Fullscreen; F11</s:String>
|
||||||
|
|
||||||
<!-- 日志框下方附加信息 -->
|
<!-- 日志框下方附加信息 -->
|
||||||
<s:String x:Key="Str_RealTimeFps">Real-time FPS: {0:F1}</s:String>
|
<s:String x:Key="Str_RealTimeFps">Real-time FPS: {0:F1}/{1:F1}</s:String>
|
||||||
|
|
||||||
<!-- 弹窗文本 -->
|
<!-- 弹窗文本 -->
|
||||||
<s:String x:Key="Str_OK">OK</s:String>
|
<s:String x:Key="Str_OK">OK</s:String>
|
||||||
|
|||||||
@@ -143,7 +143,7 @@
|
|||||||
<s:String x:Key="Str_FullScreenTooltip">ウィンドウ/フルスクリーン; F11</s:String>
|
<s:String x:Key="Str_FullScreenTooltip">ウィンドウ/フルスクリーン; F11</s:String>
|
||||||
|
|
||||||
<!-- 日志框下方附加信息 -->
|
<!-- 日志框下方附加信息 -->
|
||||||
<s:String x:Key="Str_RealTimeFps">リアルタイムFPS:{0:F1}</s:String>
|
<s:String x:Key="Str_RealTimeFps">リアルタイムFPS:{0:F1}/{1:F1}</s:String>
|
||||||
|
|
||||||
<!-- 弹窗文本 -->
|
<!-- 弹窗文本 -->
|
||||||
<s:String x:Key="Str_OK">OK</s:String>
|
<s:String x:Key="Str_OK">OK</s:String>
|
||||||
|
|||||||
@@ -143,7 +143,7 @@
|
|||||||
<s:String x:Key="Str_FullScreenTooltip">窗口/全屏; F11</s:String>
|
<s:String x:Key="Str_FullScreenTooltip">窗口/全屏; F11</s:String>
|
||||||
|
|
||||||
<!-- 日志框下方附加信息 -->
|
<!-- 日志框下方附加信息 -->
|
||||||
<s:String x:Key="Str_RealTimeFps">实时帧率:{0:F1}</s:String>
|
<s:String x:Key="Str_RealTimeFps">实时帧率:{0:F1}/{1:F1}</s:String>
|
||||||
|
|
||||||
<!-- 弹窗文本 -->
|
<!-- 弹窗文本 -->
|
||||||
<s:String x:Key="Str_OK">确认</s:String>
|
<s:String x:Key="Str_OK">确认</s:String>
|
||||||
|
|||||||
@@ -175,6 +175,12 @@ namespace SpineViewer.ViewModels.MainWindow
|
|||||||
private float _accumFpsTime;
|
private float _accumFpsTime;
|
||||||
private int _accumFpsCount;
|
private int _accumFpsCount;
|
||||||
|
|
||||||
|
public float WallpaperRealTimeFps => _wallpaperRealTimeFps;
|
||||||
|
private float _wallpaperRealTimeFps;
|
||||||
|
|
||||||
|
private int _accumWallpaperFpsCount;
|
||||||
|
private readonly object _accumWallpaperFpsCountLock = new();
|
||||||
|
|
||||||
public float Speed
|
public float Speed
|
||||||
{
|
{
|
||||||
get => _speed;
|
get => _speed;
|
||||||
@@ -516,14 +522,21 @@ namespace SpineViewer.ViewModels.MainWindow
|
|||||||
private void UpdateLogicFrame(float delta)
|
private void UpdateLogicFrame(float delta)
|
||||||
{
|
{
|
||||||
// 计算实时帧率, 1 秒刷新一次
|
// 计算实时帧率, 1 秒刷新一次
|
||||||
_accumFpsCount++;
|
|
||||||
_accumFpsTime += delta;
|
_accumFpsTime += delta;
|
||||||
if (_accumFpsTime > 1f)
|
if (_accumFpsTime > 1f)
|
||||||
{
|
{
|
||||||
_realTimeFps = _accumFpsCount / _accumFpsTime;
|
_realTimeFps = _accumFpsCount / _accumFpsTime;
|
||||||
_accumFpsTime = 0f;
|
|
||||||
_accumFpsCount = 0;
|
_accumFpsCount = 0;
|
||||||
|
|
||||||
|
lock (_accumWallpaperFpsCountLock)
|
||||||
|
{
|
||||||
|
_wallpaperRealTimeFps = _accumWallpaperFpsCount / _accumFpsTime;
|
||||||
|
_accumWallpaperFpsCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_accumFpsTime = 0f;
|
||||||
OnPropertyChanged(nameof(RealTimeFps));
|
OnPropertyChanged(nameof(RealTimeFps));
|
||||||
|
OnPropertyChanged(nameof(WallpaperRealTimeFps));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 停止更新的时候只是时间不前进, 但是坐标变换还是要更新, 否则无法移动对象
|
// 停止更新的时候只是时间不前进, 但是坐标变换还是要更新, 否则无法移动对象
|
||||||
@@ -634,6 +647,9 @@ namespace SpineViewer.ViewModels.MainWindow
|
|||||||
|
|
||||||
// 显示内容
|
// 显示内容
|
||||||
_renderer.Display();
|
_renderer.Display();
|
||||||
|
|
||||||
|
// 帧数加一
|
||||||
|
_accumFpsCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WallpaperRenderTask()
|
private void WallpaperRenderTask()
|
||||||
@@ -679,6 +695,9 @@ namespace SpineViewer.ViewModels.MainWindow
|
|||||||
|
|
||||||
// 显示渲染
|
// 显示渲染
|
||||||
_wallpaperRenderer.Display();
|
_wallpaperRenderer.Display();
|
||||||
|
|
||||||
|
// 帧数加一
|
||||||
|
lock (_accumWallpaperFpsCountLock) _accumWallpaperFpsCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -707,7 +726,6 @@ namespace SpineViewer.ViewModels.MainWindow
|
|||||||
Rotation = Rotation,
|
Rotation = Rotation,
|
||||||
FlipX = FlipX,
|
FlipX = FlipX,
|
||||||
FlipY = FlipY,
|
FlipY = FlipY,
|
||||||
MaxFps = MaxFps,
|
|
||||||
Speed = Speed,
|
Speed = Speed,
|
||||||
ShowAxis = ShowAxis,
|
ShowAxis = ShowAxis,
|
||||||
BackgroundColor = BackgroundColor,
|
BackgroundColor = BackgroundColor,
|
||||||
@@ -724,7 +742,6 @@ namespace SpineViewer.ViewModels.MainWindow
|
|||||||
Rotation = value.Rotation;
|
Rotation = value.Rotation;
|
||||||
FlipX = value.FlipX;
|
FlipX = value.FlipX;
|
||||||
FlipY = value.FlipY;
|
FlipY = value.FlipY;
|
||||||
MaxFps = value.MaxFps;
|
|
||||||
Speed = value.Speed;
|
Speed = value.Speed;
|
||||||
ShowAxis = value.ShowAxis;
|
ShowAxis = value.ShowAxis;
|
||||||
BackgroundColor = value.BackgroundColor;
|
BackgroundColor = value.BackgroundColor;
|
||||||
|
|||||||
@@ -1052,6 +1052,7 @@
|
|||||||
<TextBlock.Text>
|
<TextBlock.Text>
|
||||||
<MultiBinding Converter="{StaticResource StrFmtCvter}" ConverterParameter="Str_RealTimeFps">
|
<MultiBinding Converter="{StaticResource StrFmtCvter}" ConverterParameter="Str_RealTimeFps">
|
||||||
<Binding Path="RealTimeFps"/>
|
<Binding Path="RealTimeFps"/>
|
||||||
|
<Binding Path="WallpaperRealTimeFps"/>
|
||||||
</MultiBinding>
|
</MultiBinding>
|
||||||
</TextBlock.Text>
|
</TextBlock.Text>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
|
|||||||
Reference in New Issue
Block a user