1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-10 23:46:40 +00:00

Implement ConvertScalingMode properly (#596)

* Implement ConvertScalingMode properly

* Fix up the naming

* Only values 2 and 4 are allowed

* Return a nullable enum from ConvetScalingMode

* Fix typo on method name

* Use convertedScalingMode
This commit is contained in:
gdkchan 2019-02-18 21:12:53 -03:00 committed by jduncanator
parent 932224f051
commit 6335753e38
2 changed files with 24 additions and 19 deletions

View file

@ -180,22 +180,31 @@ namespace Ryujinx.HLE.HOS.Services.Vi
public long ConvertScalingMode(ServiceCtx context) public long ConvertScalingMode(ServiceCtx context)
{ {
SrcScalingMode scalingMode = (SrcScalingMode)context.RequestData.ReadInt32(); SrcScalingMode scalingMode = (SrcScalingMode)context.RequestData.ReadInt32();
DstScalingMode? destScalingMode = ConvetScalingModeImpl(scalingMode);
if (!destScalingMode.HasValue) DstScalingMode? convertedScalingMode = ConvertScalingMode(scalingMode);
if (!convertedScalingMode.HasValue)
{ {
//Scaling mode out of the range of valid values.
return MakeError(ErrorModule.Vi, 1); return MakeError(ErrorModule.Vi, 1);
} }
context.ResponseData.Write((ulong)destScalingMode); if (scalingMode != SrcScalingMode.ScaleToWindow &&
scalingMode != SrcScalingMode.PreserveAspectRatio)
{
//Invalid scaling mode specified.
return MakeError(ErrorModule.Vi, 6);
}
context.ResponseData.Write((ulong)convertedScalingMode);
return 0; return 0;
} }
private DstScalingMode? ConvetScalingModeImpl(SrcScalingMode srcScalingMode) private DstScalingMode? ConvertScalingMode(SrcScalingMode source)
{ {
switch (srcScalingMode) switch (source)
{ {
case SrcScalingMode.None: return DstScalingMode.None; case SrcScalingMode.None: return DstScalingMode.None;
case SrcScalingMode.Freeze: return DstScalingMode.Freeze; case SrcScalingMode.Freeze: return DstScalingMode.Freeze;

View file

@ -1,24 +1,20 @@
using System; namespace Ryujinx.HLE.HOS.Services.Vi
using System.Collections.Generic;
using System.Text;
namespace Ryujinx.HLE.HOS.Services.Vi
{ {
enum SrcScalingMode enum SrcScalingMode
{ {
Freeze = 0, None = 0,
ScaleToWindow = 1, Freeze = 1,
ScaleAndCrop = 2, ScaleToWindow = 2,
None = 3, ScaleAndCrop = 3,
PreserveAspectRatio = 4 PreserveAspectRatio = 4
} }
enum DstScalingMode enum DstScalingMode
{ {
None = 0, Freeze = 0,
Freeze = 1, ScaleToWindow = 1,
ScaleToWindow = 2, ScaleAndCrop = 2,
ScaleAndCrop = 3, None = 3,
PreserveAspectRatio = 4 PreserveAspectRatio = 4
} }
} }