Implement ConvertScalingMode properly

This commit is contained in:
gdkchan 2019-02-18 15:00:08 -03:00
commit 133ca72a01
2 changed files with 23 additions and 20 deletions

View file

@ -180,22 +180,29 @@ 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) if (scalingMode > SrcScalingMode.PreserveAspectRatio)
{ {
//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.ScaleAndCrop &&
scalingMode != SrcScalingMode.PreserveAspectRatio)
{
//Invalid scaling mode specified.
return MakeError(ErrorModule.Vi, 6);
}
context.ResponseData.Write((ulong)ConvetScalingMode(scalingMode));
return 0; return 0;
} }
private DstScalingMode? ConvetScalingModeImpl(SrcScalingMode srcScalingMode) private DstScalingMode ConvetScalingMode(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;
@ -204,7 +211,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi
case SrcScalingMode.PreserveAspectRatio: return DstScalingMode.PreserveAspectRatio; case SrcScalingMode.PreserveAspectRatio: return DstScalingMode.PreserveAspectRatio;
} }
return null; throw new ArgumentException($"Invalid scaling mode \"{source}\" specified.");
} }
public long GetDisplayVSyncEvent(ServiceCtx context) public long GetDisplayVSyncEvent(ServiceCtx context)

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, Freeze = 0,
ScaleToWindow = 1, ScaleToWindow = 1,
ScaleAndCrop = 2, ScaleAndCrop = 2,
None = 3, None = 3,
PreserveAspectRatio = 4 PreserveAspectRatio = 4
} }
enum DstScalingMode enum DstScalingMode
{ {
None = 0, ScaleToWindow = 0,
Freeze = 1, ScaleAndCrop = 1,
ScaleToWindow = 2, None = 2,
ScaleAndCrop = 3, Freeze = 3,
PreserveAspectRatio = 4 PreserveAspectRatio = 4
} }
} }