aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2019-02-18 21:12:53 -0300
committerjduncanator <1518948+jduncanator@users.noreply.github.com>2019-02-19 11:12:53 +1100
commit6335753e382eec1cf9037545851f1de2459b94cc (patch)
tree0c1ea5df5cf30ff3f88e1c629f6d602f8e60b61a
parent932224f05112180aa5f52162cbbc3a17c339075f (diff)
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
-rw-r--r--Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs21
-rw-r--r--Ryujinx.HLE/HOS/Services/Vi/ScalingMode.cs22
2 files changed, 24 insertions, 19 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs b/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs
index b272e078..48cf3288 100644
--- a/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs
+++ b/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs
@@ -180,22 +180,31 @@ namespace Ryujinx.HLE.HOS.Services.Vi
public long ConvertScalingMode(ServiceCtx context)
{
- SrcScalingMode scalingMode = (SrcScalingMode)context.RequestData.ReadInt32();
- DstScalingMode? destScalingMode = ConvetScalingModeImpl(scalingMode);
+ SrcScalingMode scalingMode = (SrcScalingMode)context.RequestData.ReadInt32();
- if (!destScalingMode.HasValue)
+ DstScalingMode? convertedScalingMode = ConvertScalingMode(scalingMode);
+
+ if (!convertedScalingMode.HasValue)
{
+ //Scaling mode out of the range of valid values.
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;
}
- private DstScalingMode? ConvetScalingModeImpl(SrcScalingMode srcScalingMode)
+ private DstScalingMode? ConvertScalingMode(SrcScalingMode source)
{
- switch (srcScalingMode)
+ switch (source)
{
case SrcScalingMode.None: return DstScalingMode.None;
case SrcScalingMode.Freeze: return DstScalingMode.Freeze;
diff --git a/Ryujinx.HLE/HOS/Services/Vi/ScalingMode.cs b/Ryujinx.HLE/HOS/Services/Vi/ScalingMode.cs
index 824a27b7..7b555b59 100644
--- a/Ryujinx.HLE/HOS/Services/Vi/ScalingMode.cs
+++ b/Ryujinx.HLE/HOS/Services/Vi/ScalingMode.cs
@@ -1,24 +1,20 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Ryujinx.HLE.HOS.Services.Vi
+namespace Ryujinx.HLE.HOS.Services.Vi
{
enum SrcScalingMode
{
- Freeze = 0,
- ScaleToWindow = 1,
- ScaleAndCrop = 2,
- None = 3,
+ None = 0,
+ Freeze = 1,
+ ScaleToWindow = 2,
+ ScaleAndCrop = 3,
PreserveAspectRatio = 4
}
enum DstScalingMode
{
- None = 0,
- Freeze = 1,
- ScaleToWindow = 2,
- ScaleAndCrop = 3,
+ Freeze = 0,
+ ScaleToWindow = 1,
+ ScaleAndCrop = 2,
+ None = 3,
PreserveAspectRatio = 4
}
}