framebuffer_layout.cpp mini refactor (#7300)

* framebuffer_layout.cpp: simplify FrameLayoutFromResolutionScale

- upright_screen seems to only be swapped width and height calculation, so it is replaced with std::swap
- Get rid of call to GetCardboardSettings, The FrameLayoutFromResolutionScale function is used for Screenshots and Video Dumping where we dont need 3D effects

* framebuffer_layout.cpp: Combine SideFrameLayout and MobileLandscapeFrameLayout into variants of LargeFrameLayout

* framebuffer_layout.{cpp,h}: rename maxRectangle to MaxRectangle, plus

minor documentation update

* clang-format
This commit is contained in:
SachinVin
2024-01-02 14:22:03 +05:30
committed by GitHub
parent 7dd9174d31
commit 9b147d3f9c
3 changed files with 194 additions and 270 deletions

View File

@ -20,6 +20,31 @@ enum class DisplayOrientation {
PortraitFlipped, // 3DS rotated 270 degrees counter-clockwise
};
/// Describes the vertical alignment of the top and bottom screens in LargeFrameLayout
/// Top
/// +-------------+-----+
/// | | |
/// | +-----+
/// | |
/// +-------------+
/// Middle
/// +-------------+
/// | +-----+
/// | | |
/// | +-----+
/// +-------------+
/// Bottom
/// +-------------+
/// | |
/// | +-----+
/// | | |
/// +-------------+-----+
enum class VerticalAlignment {
Top,
Middle,
Bottom,
};
/// Describes the horizontal coordinates for the right eye screen when using Cardboard VR
struct CardboardSettings {
u32 top_screen_right_eye;
@ -43,7 +68,7 @@ struct FramebufferLayout {
CardboardSettings cardboard;
/**
* Returns the ration of pixel size of the top screen, compared to the native size of the 3DS
* Returns the ratio of pixel size of the top screen, compared to the native size of the 3DS
* screen.
*/
u32 GetScalingRatio() const;
@ -54,6 +79,7 @@ struct FramebufferLayout {
* @param width Window framebuffer width in pixels
* @param height Window framebuffer height in pixels
* @param is_swapped if true, the bottom screen will be displayed above the top screen
* @param upright if true, the screens will be rotated 90 degrees anti-clockwise
* @return Newly created FramebufferLayout object with default screen regions initialized
*/
FramebufferLayout DefaultFrameLayout(u32 width, u32 height, bool is_swapped, bool upright);
@ -67,25 +93,12 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height, bool is_swapped, boo
*/
FramebufferLayout MobilePortraitFrameLayout(u32 width, u32 height, bool is_swapped);
/**
* Factory method for constructing a Frame with the a 4x size Top screen with a 1x size bottom
* screen on the right
* This is useful in particular because it matches well with a 1920x1080 resolution monitor
* @param width Window framebuffer width in pixels
* @param height Window framebuffer height in pixels
* @param is_swapped if true, the bottom screen will be the large display
* @param scale_factor Scale factor to use for bottom screen with respect to top screen
* @param center_vertical When true, centers the top and bottom screens vertically
* @return Newly created FramebufferLayout object with default screen regions initialized
*/
FramebufferLayout MobileLandscapeFrameLayout(u32 width, u32 height, bool is_swapped,
float scale_factor, bool center_vertical);
/**
* Factory method for constructing a FramebufferLayout with only the top or bottom screen
* @param width Window framebuffer width in pixels
* @param height Window framebuffer height in pixels
* @param is_swapped if true, the bottom screen will be displayed (and the top won't be displayed)
* @param upright if true, the screens will be rotated 90 degrees anti-clockwise
* @return Newly created FramebufferLayout object with default screen regions initialized
*/
FramebufferLayout SingleFrameLayout(u32 width, u32 height, bool is_swapped, bool upright);
@ -97,32 +110,25 @@ FramebufferLayout SingleFrameLayout(u32 width, u32 height, bool is_swapped, bool
* @param width Window framebuffer width in pixels
* @param height Window framebuffer height in pixels
* @param is_swapped if true, the bottom screen will be the large display
* @param upright if true, the screens will be rotated 90 degrees anti-clockwise
* @param scale_factor The ratio between the large screen with respect to the smaller screen
* @param vertical_alignment The vertical alignment of the smaller screen relative to the larger
* screen
* @return Newly created FramebufferLayout object with default screen regions initialized
*/
FramebufferLayout LargeFrameLayout(u32 width, u32 height, bool is_swapped, bool upright,
float scale_factor);
float scale_factor, VerticalAlignment vertical_alignment);
/**
* Factory method for constructing a frame with 2.5 times bigger top screen on the right,
* and 1x top and bottom screen on the left
* @param width Window framebuffer width in pixels
* @param height Window framebuffer height in pixels
* @param is_swapped if true, the bottom screen will be the large display
* @param upright if true, the screens will be rotated 90 degrees anti-clockwise
* @return Newly created FramebufferLayout object with default screen regions initialized
*/
FramebufferLayout HybridScreenLayout(u32 width, u32 height, bool swapped, bool upright);
/**
* Factory method for constructing a Frame with the Top screen and bottom
* screen side by side
* This is useful for devices with small screens, like the GPDWin
* @param width Window framebuffer width in pixels
* @param height Window framebuffer height in pixels
* @param is_swapped if true, the bottom screen will be the left display
* @return Newly created FramebufferLayout object with default screen regions initialized
*/
FramebufferLayout SideFrameLayout(u32 width, u32 height, bool is_swapped, bool upright);
/**
* Factory method for constructing a Frame with the Top screen and bottom
* screen on separate windows