diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/framebuffer_layout.cpp | 6 | ||||
| -rw-r--r-- | src/common/framebuffer_layout.h | 7 | ||||
| -rw-r--r-- | src/common/math_util.h | 4 |
3 files changed, 9 insertions, 8 deletions
diff --git a/src/common/framebuffer_layout.cpp b/src/common/framebuffer_layout.cpp index e8538dcfd..46c008d9c 100644 --- a/src/common/framebuffer_layout.cpp +++ b/src/common/framebuffer_layout.cpp | |||
| @@ -14,8 +14,6 @@ static const float TOP_SCREEN_ASPECT_RATIO = | |||
| 14 | static_cast<float>(VideoCore::kScreenTopHeight) / VideoCore::kScreenTopWidth; | 14 | static_cast<float>(VideoCore::kScreenTopHeight) / VideoCore::kScreenTopWidth; |
| 15 | static const float BOT_SCREEN_ASPECT_RATIO = | 15 | static const float BOT_SCREEN_ASPECT_RATIO = |
| 16 | static_cast<float>(VideoCore::kScreenBottomHeight) / VideoCore::kScreenBottomWidth; | 16 | static_cast<float>(VideoCore::kScreenBottomHeight) / VideoCore::kScreenBottomWidth; |
| 17 | static const float BOT_TO_TOP_SCREEN_RATIO_DIFFERENCE = | ||
| 18 | BOT_SCREEN_ASPECT_RATIO - TOP_SCREEN_ASPECT_RATIO; | ||
| 19 | 17 | ||
| 20 | // Finds the largest size subrectangle contained in window area that is confined to the aspect ratio | 18 | // Finds the largest size subrectangle contained in window area that is confined to the aspect ratio |
| 21 | template <class T> | 19 | template <class T> |
| @@ -23,8 +21,8 @@ static MathUtil::Rectangle<T> maxRectangle(MathUtil::Rectangle<T> window_area, | |||
| 23 | float screen_aspect_ratio) { | 21 | float screen_aspect_ratio) { |
| 24 | float scale = std::min(static_cast<float>(window_area.GetWidth()), | 22 | float scale = std::min(static_cast<float>(window_area.GetWidth()), |
| 25 | window_area.GetHeight() / screen_aspect_ratio); | 23 | window_area.GetHeight() / screen_aspect_ratio); |
| 26 | return MathUtil::Rectangle<T>{0, 0, static_cast<T>(scale), | 24 | return MathUtil::Rectangle<T>{0, 0, static_cast<T>(std::round(scale)), |
| 27 | static_cast<T>(scale * screen_aspect_ratio)}; | 25 | static_cast<T>(std::round(scale * screen_aspect_ratio))}; |
| 28 | } | 26 | } |
| 29 | 27 | ||
| 30 | FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height, bool swapped) { | 28 | FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height, bool swapped) { |
diff --git a/src/common/framebuffer_layout.h b/src/common/framebuffer_layout.h index 7f88c9463..a125646a3 100644 --- a/src/common/framebuffer_layout.h +++ b/src/common/framebuffer_layout.h | |||
| @@ -20,14 +20,16 @@ struct FramebufferLayout { | |||
| 20 | * Factory method for constructing a default FramebufferLayout | 20 | * Factory method for constructing a default FramebufferLayout |
| 21 | * @param width Window framebuffer width in pixels | 21 | * @param width Window framebuffer width in pixels |
| 22 | * @param height Window framebuffer height in pixels | 22 | * @param height Window framebuffer height in pixels |
| 23 | * @param is_swapped if true, the bottom screen will be displayed above the top screen | ||
| 23 | * @return Newly created FramebufferLayout object with default screen regions initialized | 24 | * @return Newly created FramebufferLayout object with default screen regions initialized |
| 24 | */ | 25 | */ |
| 25 | FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height, bool is_swapped); | 26 | FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height, bool is_swapped); |
| 26 | 27 | ||
| 27 | /** | 28 | /** |
| 28 | * Factory method for constructing a FramebufferLayout with only the top screen | 29 | * Factory method for constructing a FramebufferLayout with only the top or bottom screen |
| 29 | * @param width Window framebuffer width in pixels | 30 | * @param width Window framebuffer width in pixels |
| 30 | * @param height Window framebuffer height in pixels | 31 | * @param height Window framebuffer height in pixels |
| 32 | * @param is_swapped if true, the bottom screen will be displayed (and the top won't be displayed) | ||
| 31 | * @return Newly created FramebufferLayout object with default screen regions initialized | 33 | * @return Newly created FramebufferLayout object with default screen regions initialized |
| 32 | */ | 34 | */ |
| 33 | FramebufferLayout SingleFrameLayout(unsigned width, unsigned height, bool is_swapped); | 35 | FramebufferLayout SingleFrameLayout(unsigned width, unsigned height, bool is_swapped); |
| @@ -38,7 +40,8 @@ FramebufferLayout SingleFrameLayout(unsigned width, unsigned height, bool is_swa | |||
| 38 | * This is useful in particular because it matches well with a 1920x1080 resolution monitor | 40 | * This is useful in particular because it matches well with a 1920x1080 resolution monitor |
| 39 | * @param width Window framebuffer width in pixels | 41 | * @param width Window framebuffer width in pixels |
| 40 | * @param height Window framebuffer height in pixels | 42 | * @param height Window framebuffer height in pixels |
| 43 | * @param is_swapped if true, the bottom screen will be the large display | ||
| 41 | * @return Newly created FramebufferLayout object with default screen regions initialized | 44 | * @return Newly created FramebufferLayout object with default screen regions initialized |
| 42 | */ | 45 | */ |
| 43 | FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool is_swapped); | 46 | FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool is_swapped); |
| 44 | } \ No newline at end of file | 47 | } |
diff --git a/src/common/math_util.h b/src/common/math_util.h index 9e630d93d..cdeaeb733 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h | |||
| @@ -45,8 +45,8 @@ struct Rectangle { | |||
| 45 | return Rectangle{left, top + y, right, bottom + y}; | 45 | return Rectangle{left, top + y, right, bottom + y}; |
| 46 | } | 46 | } |
| 47 | Rectangle<T> Scale(const float s) const { | 47 | Rectangle<T> Scale(const float s) const { |
| 48 | return Rectangle{left, top, static_cast<T>((right + left) * s), | 48 | return Rectangle{left, top, static_cast<T>(left + GetWidth() * s), |
| 49 | static_cast<T>((top + bottom) * s)}; | 49 | static_cast<T>(top + GetHeight() * s)}; |
| 50 | } | 50 | } |
| 51 | }; | 51 | }; |
| 52 | 52 | ||