diff --git a/app/src/main/cpp/skyline/services/visrv/IApplicationDisplayService.cpp b/app/src/main/cpp/skyline/services/visrv/IApplicationDisplayService.cpp index 86562a74..66cd8c24 100644 --- a/app/src/main/cpp/skyline/services/visrv/IApplicationDisplayService.cpp +++ b/app/src/main/cpp/skyline/services/visrv/IApplicationDisplayService.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MPL-2.0 // Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) +// Copyright © 2019 Ryujinx Team and Contributors #include #include @@ -85,4 +86,27 @@ namespace skyline::service::visrv { response.copyHandles.push_back(handle); return {}; } + + Result IApplicationDisplayService::ConvertScalingMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + u32 inScalingMode{request.Pop()}; + + std::array scalingModeLut{ + ScalingMode::None, + ScalingMode::Freeze, + ScalingMode::ScaleToLayer, + ScalingMode::ScaleAndCrop, + ScalingMode::PreserveAspectRatio, + }; + + if (scalingModeLut.size() <= inScalingMode) + return result::InvalidArgument; + + auto scalingMode{scalingModeLut[inScalingMode]}; + if (scalingMode != ScalingMode::ScaleToLayer && scalingMode != ScalingMode::PreserveAspectRatio) + return result::IllegalOperation; + + response.Push(scalingMode); + + return {}; + } } diff --git a/app/src/main/cpp/skyline/services/visrv/IApplicationDisplayService.h b/app/src/main/cpp/skyline/services/visrv/IApplicationDisplayService.h index da567c8e..090a7e99 100644 --- a/app/src/main/cpp/skyline/services/visrv/IApplicationDisplayService.h +++ b/app/src/main/cpp/skyline/services/visrv/IApplicationDisplayService.h @@ -15,6 +15,17 @@ namespace skyline::service::visrv { private: PrivilegeLevel level; + /** + * @brief Specifies the method to scale up the layer content to its bounds + */ + enum class ScalingMode { + Freeze = 0, + ScaleToLayer = 1, + ScaleAndCrop = 2, + None = 3, + PreserveAspectRatio = 4, + }; + public: IApplicationDisplayService(const DeviceState &state, ServiceManager &manager, PrivilegeLevel level); @@ -72,6 +83,11 @@ namespace skyline::service::visrv { */ Result SetLayerScalingMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + /** + * @brief Converts an arbitrary scaling mode to a VI scaling mode + */ + Result ConvertScalingMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + /** * @brief Returns a handle to a KEvent which is triggered every time a frame is drawn * @url https://switchbrew.org/wiki/Display_services#GetDisplayVsyncEvent diff --git a/app/src/main/cpp/skyline/services/visrv/results.h b/app/src/main/cpp/skyline/services/visrv/results.h index 9dcd28fd..17f051c5 100644 --- a/app/src/main/cpp/skyline/services/visrv/results.h +++ b/app/src/main/cpp/skyline/services/visrv/results.h @@ -6,5 +6,6 @@ #include namespace skyline::service::visrv::result { + constexpr Result InvalidArgument(114, 1); constexpr Result IllegalOperation(114, 6); }