mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-27 22:06:24 +02:00
Overlays: fix delta calculation
This commit is contained in:
parent
952be47f3c
commit
076dd9a56a
1 changed files with 11 additions and 8 deletions
|
@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
{
|
{
|
||||||
private readonly GpuContext _context;
|
private readonly GpuContext _context;
|
||||||
private readonly OverlayManager _overlayManager;
|
private readonly OverlayManager _overlayManager;
|
||||||
private DateTime _lastUpdateTime = DateTime.UtcNow;
|
private DateTime? _lastUpdateTime = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Texture presented on the window.
|
/// Texture presented on the window.
|
||||||
|
@ -271,13 +271,16 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Calculate delta time for lifespan updates
|
|
||||||
DateTime currentTime = DateTime.UtcNow;
|
DateTime currentTime = DateTime.UtcNow;
|
||||||
float deltaTime = (float)(currentTime - _lastUpdateTime).TotalSeconds;
|
if (_lastUpdateTime != null)
|
||||||
_lastUpdateTime = currentTime;
|
{
|
||||||
|
// Calculate delta time for lifespan updates
|
||||||
|
float deltaTime = (float)(currentTime - _lastUpdateTime.Value).TotalSeconds;
|
||||||
|
_overlayManager.Update(deltaTime, new SKSize(texture.Info.Width, texture.Info.Height));
|
||||||
|
}
|
||||||
|
|
||||||
// Update overlay animations
|
// Update overlay animations
|
||||||
_overlayManager.Update(deltaTime, new SKSize(texture.Info.Width, texture.Info.Height));
|
_lastUpdateTime = currentTime;
|
||||||
|
|
||||||
// Get texture data from host texture
|
// Get texture data from host texture
|
||||||
using var pinnedData = texture.HostTexture.GetData();
|
using var pinnedData = texture.HostTexture.GetData();
|
||||||
|
@ -301,7 +304,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
// Create SKBitmap from texture data
|
// Create SKBitmap from texture data
|
||||||
var imageInfo = new SKImageInfo(width, height, colorType, SKAlphaType.Premul);
|
var imageInfo = new SKImageInfo(width, height, colorType, SKAlphaType.Premul);
|
||||||
using var bitmap = new SKBitmap(imageInfo);
|
using var bitmap = new SKBitmap(imageInfo);
|
||||||
|
|
||||||
// Copy texture data to bitmap
|
// Copy texture data to bitmap
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
|
@ -313,7 +316,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
|
|
||||||
// Create canvas for drawing overlays
|
// Create canvas for drawing overlays
|
||||||
using var canvas = new SKCanvas(bitmap);
|
using var canvas = new SKCanvas(bitmap);
|
||||||
|
|
||||||
// On Linux with OpenGL, we need to flip the Y-axis because OpenGL uses bottom-left origin
|
// On Linux with OpenGL, we need to flip the Y-axis because OpenGL uses bottom-left origin
|
||||||
// while SkiaSharp uses top-left origin
|
// while SkiaSharp uses top-left origin
|
||||||
if (OperatingSystem.IsLinux())
|
if (OperatingSystem.IsLinux())
|
||||||
|
@ -321,7 +324,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
canvas.Scale(1, -1);
|
canvas.Scale(1, -1);
|
||||||
canvas.Translate(0, -height);
|
canvas.Translate(0, -height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render all overlays
|
// Render all overlays
|
||||||
_overlayManager.Render(canvas);
|
_overlayManager.Render(canvas);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue