yuzu/bootmanager: Treat the resolution factor as a u32
Treating it as a u16 can result in a sign-conversion warning when performing arithmetic with it, as u16 promotes to an int when aritmetic is performed on it, not unsigned int. This also makes the interface more uniform, as the layout interface now operates on u32 across the board.
This commit is contained in:
parent
536c9cf006
commit
e32bf646cf
@ -20,7 +20,7 @@ static Common::Rectangle<T> MaxRectangle(Common::Rectangle<T> window_area,
|
|||||||
static_cast<T>(std::round(scale * screen_aspect_ratio))};
|
static_cast<T>(std::round(scale * screen_aspect_ratio))};
|
||||||
}
|
}
|
||||||
|
|
||||||
FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height) {
|
FramebufferLayout DefaultFrameLayout(u32 width, u32 height) {
|
||||||
ASSERT(width > 0);
|
ASSERT(width > 0);
|
||||||
ASSERT(height > 0);
|
ASSERT(height > 0);
|
||||||
// The drawing code needs at least somewhat valid values for both screens
|
// The drawing code needs at least somewhat valid values for both screens
|
||||||
@ -29,22 +29,23 @@ FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height) {
|
|||||||
|
|
||||||
const float emulation_aspect_ratio{static_cast<float>(ScreenUndocked::Height) /
|
const float emulation_aspect_ratio{static_cast<float>(ScreenUndocked::Height) /
|
||||||
ScreenUndocked::Width};
|
ScreenUndocked::Width};
|
||||||
Common::Rectangle<unsigned> screen_window_area{0, 0, width, height};
|
const auto window_aspect_ratio = static_cast<float>(height) / width;
|
||||||
Common::Rectangle<unsigned> screen = MaxRectangle(screen_window_area, emulation_aspect_ratio);
|
|
||||||
|
|
||||||
float window_aspect_ratio = static_cast<float>(height) / width;
|
const Common::Rectangle<u32> screen_window_area{0, 0, width, height};
|
||||||
|
Common::Rectangle<u32> screen = MaxRectangle(screen_window_area, emulation_aspect_ratio);
|
||||||
|
|
||||||
if (window_aspect_ratio < emulation_aspect_ratio) {
|
if (window_aspect_ratio < emulation_aspect_ratio) {
|
||||||
screen = screen.TranslateX((screen_window_area.GetWidth() - screen.GetWidth()) / 2);
|
screen = screen.TranslateX((screen_window_area.GetWidth() - screen.GetWidth()) / 2);
|
||||||
} else {
|
} else {
|
||||||
screen = screen.TranslateY((height - screen.GetHeight()) / 2);
|
screen = screen.TranslateY((height - screen.GetHeight()) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.screen = screen;
|
res.screen = screen;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
FramebufferLayout FrameLayoutFromResolutionScale(u16 res_scale) {
|
FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) {
|
||||||
int width, height;
|
u32 width, height;
|
||||||
|
|
||||||
if (Settings::values.use_docked_mode) {
|
if (Settings::values.use_docked_mode) {
|
||||||
width = ScreenDocked::WidthDocked * res_scale;
|
width = ScreenDocked::WidthDocked * res_scale;
|
||||||
|
@ -8,15 +8,22 @@
|
|||||||
|
|
||||||
namespace Layout {
|
namespace Layout {
|
||||||
|
|
||||||
enum ScreenUndocked : unsigned { Width = 1280, Height = 720 };
|
enum ScreenUndocked : u32 {
|
||||||
enum ScreenDocked : unsigned { WidthDocked = 1920, HeightDocked = 1080 };
|
Width = 1280,
|
||||||
|
Height = 720,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ScreenDocked : u32 {
|
||||||
|
WidthDocked = 1920,
|
||||||
|
HeightDocked = 1080,
|
||||||
|
};
|
||||||
|
|
||||||
/// Describes the layout of the window framebuffer
|
/// Describes the layout of the window framebuffer
|
||||||
struct FramebufferLayout {
|
struct FramebufferLayout {
|
||||||
unsigned width{ScreenUndocked::Width};
|
u32 width{ScreenUndocked::Width};
|
||||||
unsigned height{ScreenUndocked::Height};
|
u32 height{ScreenUndocked::Height};
|
||||||
|
|
||||||
Common::Rectangle<unsigned> screen;
|
Common::Rectangle<u32> screen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ration of pixel size of the screen, compared to the native size of the undocked
|
* Returns the ration of pixel size of the screen, compared to the native size of the undocked
|
||||||
@ -33,12 +40,12 @@ struct FramebufferLayout {
|
|||||||
* @param height Window framebuffer height in pixels
|
* @param height Window framebuffer height in pixels
|
||||||
* @return Newly created FramebufferLayout object with default screen regions initialized
|
* @return Newly created FramebufferLayout object with default screen regions initialized
|
||||||
*/
|
*/
|
||||||
FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height);
|
FramebufferLayout DefaultFrameLayout(u32 width, u32 height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method to get frame layout by resolution scale
|
* Convenience method to get frame layout by resolution scale
|
||||||
* @param res_scale resolution scale factor
|
* @param res_scale resolution scale factor
|
||||||
*/
|
*/
|
||||||
FramebufferLayout FrameLayoutFromResolutionScale(u16 res_scale);
|
FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale);
|
||||||
|
|
||||||
} // namespace Layout
|
} // namespace Layout
|
||||||
|
@ -426,11 +426,12 @@ void GRenderWindow::InitRenderTarget() {
|
|||||||
BackupGeometry();
|
BackupGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRenderWindow::CaptureScreenshot(u16 res_scale, const QString& screenshot_path) {
|
void GRenderWindow::CaptureScreenshot(u32 res_scale, const QString& screenshot_path) {
|
||||||
auto& renderer = Core::System::GetInstance().Renderer();
|
auto& renderer = Core::System::GetInstance().Renderer();
|
||||||
|
|
||||||
if (!res_scale)
|
if (res_scale == 0) {
|
||||||
res_scale = VideoCore::GetResolutionScaleFactor(renderer);
|
res_scale = VideoCore::GetResolutionScaleFactor(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
const Layout::FramebufferLayout layout{Layout::FrameLayoutFromResolutionScale(res_scale)};
|
const Layout::FramebufferLayout layout{Layout::FrameLayoutFromResolutionScale(res_scale)};
|
||||||
screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32);
|
screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32);
|
||||||
|
@ -144,7 +144,7 @@ public:
|
|||||||
|
|
||||||
void InitRenderTarget();
|
void InitRenderTarget();
|
||||||
|
|
||||||
void CaptureScreenshot(u16 res_scale, const QString& screenshot_path);
|
void CaptureScreenshot(u32 res_scale, const QString& screenshot_path);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void moveContext(); // overridden
|
void moveContext(); // overridden
|
||||||
|
Loading…
Reference in New Issue
Block a user