mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-09-20 17:51:13 +02:00
Update SkiaSharp to 3.119.2
* Update deprecated SkiaSharp code
This commit is contained in:
@@ -46,8 +46,8 @@
|
|||||||
<PackageVersion Include="Silk.NET.Vulkan" Version="2.23.0" />
|
<PackageVersion Include="Silk.NET.Vulkan" Version="2.23.0" />
|
||||||
<PackageVersion Include="Silk.NET.Vulkan.Extensions.EXT" Version="2.23.0" />
|
<PackageVersion Include="Silk.NET.Vulkan.Extensions.EXT" Version="2.23.0" />
|
||||||
<PackageVersion Include="Silk.NET.Vulkan.Extensions.KHR" Version="2.23.0" />
|
<PackageVersion Include="Silk.NET.Vulkan.Extensions.KHR" Version="2.23.0" />
|
||||||
<PackageVersion Include="SkiaSharp" Version="2.88.9" />
|
<PackageVersion Include="SkiaSharp" Version="3.119.2" />
|
||||||
<PackageVersion Include="SkiaSharp.NativeAssets.Linux" Version="2.88.9" />
|
<PackageVersion Include="SkiaSharp.NativeAssets.Linux" Version="3.119.2" />
|
||||||
<PackageVersion Include="SPB" Version="0.0.4-build32" />
|
<PackageVersion Include="SPB" Version="0.0.4-build32" />
|
||||||
<PackageVersion Include="System.IO.Hashing" Version="10.0.3" />
|
<PackageVersion Include="System.IO.Hashing" Version="10.0.3" />
|
||||||
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.1.4-a40db6c" />
|
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.1.4-a40db6c" />
|
||||||
|
|||||||
@@ -23,15 +23,15 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
|
|
||||||
private readonly Lock _bufferLock = new();
|
private readonly Lock _bufferLock = new();
|
||||||
|
|
||||||
private RenderingSurfaceInfo _surfaceInfo = null;
|
private RenderingSurfaceInfo _surfaceInfo;
|
||||||
private SKImageInfo _imageInfo;
|
private SKImageInfo _imageInfo;
|
||||||
private SKSurface _surface = null;
|
private SKSurface _surface;
|
||||||
private byte[] _bufferData = null;
|
private byte[] _bufferData;
|
||||||
|
|
||||||
private readonly SKBitmap _ryujinxLogo = null;
|
private readonly SKBitmap _ryujinxLogo;
|
||||||
private readonly SKBitmap _padAcceptIcon = null;
|
private readonly SKBitmap _padAcceptIcon;
|
||||||
private readonly SKBitmap _padCancelIcon = null;
|
private readonly SKBitmap _padCancelIcon;
|
||||||
private readonly SKBitmap _keyModeIcon = null;
|
private readonly SKBitmap _keyModeIcon;
|
||||||
|
|
||||||
private readonly float _textBoxOutlineWidth;
|
private readonly float _textBoxOutlineWidth;
|
||||||
private readonly float _padPressedPenWidth;
|
private readonly float _padPressedPenWidth;
|
||||||
@@ -181,7 +181,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
|
|
||||||
if (newHeight != 0 && newWidth != 0)
|
if (newHeight != 0 && newWidth != 0)
|
||||||
{
|
{
|
||||||
var resized = bitmap.Resize(new SKImageInfo(newWidth, newHeight), SKFilterQuality.High);
|
var resized = bitmap.Resize(new SKImageInfo(newWidth, newHeight), new SKSamplingOptions(SKFilterMode.Linear));
|
||||||
if (resized != null)
|
if (resized != null)
|
||||||
{
|
{
|
||||||
bitmap.Dispose();
|
bitmap.Dispose();
|
||||||
@@ -219,14 +219,16 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
using var paint = new SKPaint(_messageFont)
|
using var font = new SKFont();
|
||||||
{
|
font.Edging = SKFontEdging.Alias;
|
||||||
Color = _textNormalColor,
|
font.Typeface = SKTypeface.Default;
|
||||||
IsAntialias = true
|
|
||||||
};
|
using var paint = new SKPaint();
|
||||||
|
paint.Color = _textNormalColor;
|
||||||
|
paint.IsAntialias = true;
|
||||||
|
|
||||||
var canvas = _surface.Canvas;
|
var canvas = _surface.Canvas;
|
||||||
var messageRectangle = MeasureString(MessageText, paint);
|
var messageRectangle = MeasureString(MessageText, font);
|
||||||
float messagePositionX = (_panelRectangle.Width - messageRectangle.Width) / 2 - messageRectangle.Left;
|
float messagePositionX = (_panelRectangle.Width - messageRectangle.Width) / 2 - messageRectangle.Left;
|
||||||
float messagePositionY = _messagePositionY - messageRectangle.Top;
|
float messagePositionY = _messagePositionY - messageRectangle.Top;
|
||||||
var messagePosition = new SKPoint(messagePositionX, messagePositionY);
|
var messagePosition = new SKPoint(messagePositionX, messagePositionY);
|
||||||
@@ -234,7 +236,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
|
|
||||||
canvas.DrawRect(messageBoundRectangle, _panelBrush);
|
canvas.DrawRect(messageBoundRectangle, _panelBrush);
|
||||||
|
|
||||||
canvas.DrawText(MessageText, messagePosition.X, messagePosition.Y + _messageFont.Metrics.XHeight + _messageFont.Metrics.Descent, paint);
|
canvas.DrawText(MessageText, messagePosition.X, messagePosition.Y + _messageFont.Metrics.XHeight + _messageFont.Metrics.Descent, SKTextAlign.Left, _messageFont, paint);
|
||||||
|
|
||||||
if (!state.TypingEnabled)
|
if (!state.TypingEnabled)
|
||||||
{
|
{
|
||||||
@@ -302,33 +304,34 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
|
|
||||||
_logoPosition = new SKPoint(logoPositionX, logoPositionY);
|
_logoPosition = new SKPoint(logoPositionX, logoPositionY);
|
||||||
}
|
}
|
||||||
private static SKRect MeasureString(string text, SKPaint paint)
|
|
||||||
|
private static SKRect MeasureString(string text, SKFont font)
|
||||||
{
|
{
|
||||||
SKRect bounds = SKRect.Empty;
|
SKRect bounds;
|
||||||
|
|
||||||
if (text == "")
|
if (text == "")
|
||||||
{
|
{
|
||||||
paint.MeasureText(" ", ref bounds);
|
font.MeasureText(" ", out bounds);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
paint.MeasureText(text, ref bounds);
|
font.MeasureText(text, out bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SKRect MeasureString(ReadOnlySpan<char> text, SKPaint paint)
|
private static SKRect MeasureString(ReadOnlySpan<char> text, SKFont font)
|
||||||
{
|
{
|
||||||
SKRect bounds = SKRect.Empty;
|
SKRect bounds;
|
||||||
|
|
||||||
if (text == "")
|
if (text is "")
|
||||||
{
|
{
|
||||||
paint.MeasureText(" ", ref bounds);
|
font.MeasureText(" ", out bounds);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
paint.MeasureText(text, ref bounds);
|
font.MeasureText(text, out bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bounds;
|
return bounds;
|
||||||
@@ -336,12 +339,14 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
|
|
||||||
private void DrawTextBox(SKCanvas canvas, SoftwareKeyboardUIState state)
|
private void DrawTextBox(SKCanvas canvas, SoftwareKeyboardUIState state)
|
||||||
{
|
{
|
||||||
using var textPaint = new SKPaint(_labelsTextFont)
|
using var textFont = new SKFont();
|
||||||
{
|
textFont.Edging = SKFontEdging.Alias;
|
||||||
IsAntialias = true,
|
textFont.Typeface = SKTypeface.Default;
|
||||||
Color = _textNormalColor
|
|
||||||
};
|
using var textPaint = new SKPaint();
|
||||||
var inputTextRectangle = MeasureString(state.InputText, textPaint);
|
textPaint.IsAntialias = true;
|
||||||
|
textPaint.Color = _textNormalColor;
|
||||||
|
var inputTextRectangle = MeasureString(state.InputText, textFont);
|
||||||
|
|
||||||
float boxWidth = (int)(Math.Max(300, inputTextRectangle.Width + inputTextRectangle.Left + 8));
|
float boxWidth = (int)(Math.Max(300, inputTextRectangle.Width + inputTextRectangle.Left + 8));
|
||||||
float boxHeight = 32;
|
float boxHeight = 32;
|
||||||
@@ -361,7 +366,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
float inputTextY = boxY + 5;
|
float inputTextY = boxY + 5;
|
||||||
|
|
||||||
var inputTextPosition = new SKPoint(inputTextX, inputTextY);
|
var inputTextPosition = new SKPoint(inputTextX, inputTextY);
|
||||||
canvas.DrawText(state.InputText, inputTextPosition.X, inputTextPosition.Y + (_labelsTextFont.Metrics.XHeight + _labelsTextFont.Metrics.Descent), textPaint);
|
canvas.DrawText(state.InputText, inputTextPosition.X, inputTextPosition.Y + (_labelsTextFont.Metrics.XHeight + _labelsTextFont.Metrics.Descent), SKTextAlign.Left, _labelsTextFont, textPaint);
|
||||||
|
|
||||||
// Draw the cursor on top of the text and redraw the text with a different color if necessary.
|
// Draw the cursor on top of the text and redraw the text with a different color if necessary.
|
||||||
|
|
||||||
@@ -387,8 +392,8 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
ReadOnlySpan<char> textUntilBegin = state.InputText.AsSpan(0, state.CursorBegin);
|
ReadOnlySpan<char> textUntilBegin = state.InputText.AsSpan(0, state.CursorBegin);
|
||||||
ReadOnlySpan<char> textUntilEnd = state.InputText.AsSpan(0, state.CursorEnd);
|
ReadOnlySpan<char> textUntilEnd = state.InputText.AsSpan(0, state.CursorEnd);
|
||||||
|
|
||||||
var selectionBeginRectangle = MeasureString(textUntilBegin, textPaint);
|
var selectionBeginRectangle = MeasureString(textUntilBegin, textFont);
|
||||||
var selectionEndRectangle = MeasureString(textUntilEnd, textPaint);
|
var selectionEndRectangle = MeasureString(textUntilEnd, textFont);
|
||||||
|
|
||||||
cursorVisible = true;
|
cursorVisible = true;
|
||||||
cursorPositionXLeft = inputTextX + selectionBeginRectangle.Width + selectionBeginRectangle.Left;
|
cursorPositionXLeft = inputTextX + selectionBeginRectangle.Width + selectionBeginRectangle.Left;
|
||||||
@@ -406,7 +411,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
|
|
||||||
int cursorBegin = Math.Min(state.InputText.Length, state.CursorBegin);
|
int cursorBegin = Math.Min(state.InputText.Length, state.CursorBegin);
|
||||||
ReadOnlySpan<char> textUntilCursor = state.InputText.AsSpan(0, cursorBegin);
|
ReadOnlySpan<char> textUntilCursor = state.InputText.AsSpan(0, cursorBegin);
|
||||||
var cursorTextRectangle = MeasureString(textUntilCursor, textPaint);
|
var cursorTextRectangle = MeasureString(textUntilCursor, textFont);
|
||||||
|
|
||||||
cursorVisible = true;
|
cursorVisible = true;
|
||||||
cursorPositionXLeft = inputTextX + cursorTextRectangle.Width + cursorTextRectangle.Left;
|
cursorPositionXLeft = inputTextX + cursorTextRectangle.Width + cursorTextRectangle.Left;
|
||||||
@@ -418,7 +423,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
if (state.CursorBegin < state.InputText.Length)
|
if (state.CursorBegin < state.InputText.Length)
|
||||||
{
|
{
|
||||||
textUntilCursor = state.InputText.AsSpan(0, cursorBegin + 1);
|
textUntilCursor = state.InputText.AsSpan(0, cursorBegin + 1);
|
||||||
cursorTextRectangle = MeasureString(textUntilCursor, textPaint);
|
cursorTextRectangle = MeasureString(textUntilCursor, textFont);
|
||||||
cursorPositionXRight = inputTextX + cursorTextRectangle.Width + cursorTextRectangle.Left;
|
cursorPositionXRight = inputTextX + cursorTextRectangle.Width + cursorTextRectangle.Left;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -461,13 +466,11 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
var textOverCanvas = textOverCursor.Canvas;
|
var textOverCanvas = textOverCursor.Canvas;
|
||||||
var textRelativePosition = new SKPoint(inputTextPosition.X - cursorRectangle.Left, inputTextPosition.Y - cursorRectangle.Top);
|
var textRelativePosition = new SKPoint(inputTextPosition.X - cursorRectangle.Left, inputTextPosition.Y - cursorRectangle.Top);
|
||||||
|
|
||||||
using var cursorPaint = new SKPaint(_inputTextFont)
|
using var cursorPaint = new SKPaint();
|
||||||
{
|
cursorPaint.Color = cursorTextColor;
|
||||||
Color = cursorTextColor,
|
cursorPaint.IsAntialias = true;
|
||||||
IsAntialias = true
|
|
||||||
};
|
|
||||||
|
|
||||||
textOverCanvas.DrawText(state.InputText, textRelativePosition.X, textRelativePosition.Y + _inputTextFont.Metrics.XHeight + _inputTextFont.Metrics.Descent, cursorPaint);
|
textOverCanvas.DrawText(state.InputText, textRelativePosition.X, textRelativePosition.Y + _inputTextFont.Metrics.XHeight + _inputTextFont.Metrics.Descent, SKTextAlign.Left, _inputTextFont, cursorPaint);
|
||||||
|
|
||||||
var cursorPosition = new SKPoint((int)cursorRectangle.Left, (int)cursorRectangle.Top);
|
var cursorPosition = new SKPoint((int)cursorRectangle.Left, (int)cursorRectangle.Top);
|
||||||
textOverCursor.Flush();
|
textOverCursor.Flush();
|
||||||
@@ -492,13 +495,15 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
float iconWidth = icon.Width;
|
float iconWidth = icon.Width;
|
||||||
float iconHeight = icon.Height;
|
float iconHeight = icon.Height;
|
||||||
|
|
||||||
using var paint = new SKPaint(_labelsTextFont)
|
using var font = new SKFont();
|
||||||
{
|
font.Edging = SKFontEdging.Alias;
|
||||||
Color = _textNormalColor,
|
font.Typeface = SKTypeface.Default;
|
||||||
IsAntialias = true
|
|
||||||
};
|
|
||||||
|
|
||||||
var labelRectangle = MeasureString(label, paint);
|
using var paint = new SKPaint();
|
||||||
|
paint.Color = _textNormalColor;
|
||||||
|
paint.IsAntialias = true;
|
||||||
|
|
||||||
|
var labelRectangle = MeasureString(label, font);
|
||||||
|
|
||||||
float labelPositionX = iconWidth + 8 - labelRectangle.Left;
|
float labelPositionX = iconWidth + 8 - labelRectangle.Left;
|
||||||
float labelPositionY = 3;
|
float labelPositionY = 3;
|
||||||
@@ -525,7 +530,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
|
|
||||||
canvas.DrawRect(boundRectangle, _panelBrush);
|
canvas.DrawRect(boundRectangle, _panelBrush);
|
||||||
canvas.DrawBitmap(icon, iconPosition);
|
canvas.DrawBitmap(icon, iconPosition);
|
||||||
canvas.DrawText(label, labelPosition.X, labelPosition.Y + _labelsTextFont.Metrics.XHeight + _labelsTextFont.Metrics.Descent, paint);
|
canvas.DrawText(label, labelPosition.X, labelPosition.Y + _labelsTextFont.Metrics.XHeight + _labelsTextFont.Metrics.Descent, SKTextAlign.Left, _labelsTextFont, paint);
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
@@ -545,12 +550,14 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
|
|
||||||
private void DrawControllerToggle(SKCanvas canvas, SKPoint point)
|
private void DrawControllerToggle(SKCanvas canvas, SKPoint point)
|
||||||
{
|
{
|
||||||
using var paint = new SKPaint(_labelsTextFont)
|
using var font = new SKFont();
|
||||||
{
|
font.Edging = SKFontEdging.Alias;
|
||||||
IsAntialias = true,
|
font.Typeface = SKTypeface.Default;
|
||||||
Color = _textNormalColor
|
|
||||||
};
|
using var paint = new SKPaint();
|
||||||
var labelRectangle = MeasureString(ControllerToggleText, paint);
|
paint.IsAntialias = true;
|
||||||
|
paint.Color = _textNormalColor;
|
||||||
|
var labelRectangle = MeasureString(ControllerToggleText, font);
|
||||||
|
|
||||||
// Use relative positions so we can center the entire drawing later.
|
// Use relative positions so we can center the entire drawing later.
|
||||||
|
|
||||||
@@ -578,7 +585,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
|||||||
var overlayPosition = new SKPoint((int)keyX, (int)keyY);
|
var overlayPosition = new SKPoint((int)keyX, (int)keyY);
|
||||||
|
|
||||||
canvas.DrawBitmap(_keyModeIcon, overlayPosition);
|
canvas.DrawBitmap(_keyModeIcon, overlayPosition);
|
||||||
canvas.DrawText(ControllerToggleText, labelPosition.X, labelPosition.Y + _labelsTextFont.Metrics.XHeight, paint);
|
canvas.DrawText(ControllerToggleText, labelPosition.X, labelPosition.Y + _labelsTextFont.Metrics.XHeight, SKTextAlign.Left, _labelsTextFont, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe void CopyImageToBuffer()
|
public unsafe void CopyImageToBuffer()
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Ryujinx.UI.Common.Helper
|
|||||||
|
|
||||||
MemoryStream iconDataStream = new(iconData);
|
MemoryStream iconDataStream = new(iconData);
|
||||||
using var image = SKBitmap.Decode(iconDataStream);
|
using var image = SKBitmap.Decode(iconDataStream);
|
||||||
image.Resize(new SKImageInfo(128, 128), SKFilterQuality.High);
|
image.Resize(new SKImageInfo(128, 128), new SKSamplingOptions(SKFilterMode.Linear));
|
||||||
SaveBitmapAsIcon(image, iconPath);
|
SaveBitmapAsIcon(image, iconPath);
|
||||||
|
|
||||||
var shortcut = Shortcut.CreateShortcut(basePath, GetArgsString(applicationFilePath, applicationId), iconPath, 0);
|
var shortcut = Shortcut.CreateShortcut(basePath, GetArgsString(applicationFilePath, applicationId), iconPath, 0);
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ namespace Ryujinx.Ava.UI.Views.User
|
|||||||
{
|
{
|
||||||
using var bitmap = SKBitmap.Decode(buffer);
|
using var bitmap = SKBitmap.Decode(buffer);
|
||||||
|
|
||||||
var resizedBitmap = bitmap.Resize(new SKImageInfo(256, 256), SKFilterQuality.High);
|
var resizedBitmap = bitmap.Resize(new SKImageInfo(256, 256), new SKSamplingOptions(SKFilterMode.Linear));
|
||||||
|
|
||||||
using var streamJpg = new MemoryStream();
|
using var streamJpg = new MemoryStream();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user