framebuffer_layout.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include "common/common_types.h"
  5. #include "common/math_util.h"
  6. namespace Layout {
  7. namespace MinimumSize {
  8. constexpr u32 Width = 640;
  9. constexpr u32 Height = 360;
  10. } // namespace MinimumSize
  11. namespace ScreenUndocked {
  12. constexpr u32 Width = 1280;
  13. constexpr u32 Height = 720;
  14. } // namespace ScreenUndocked
  15. namespace ScreenDocked {
  16. constexpr u32 Width = 1920;
  17. constexpr u32 Height = 1080;
  18. } // namespace ScreenDocked
  19. enum class AspectRatio {
  20. Default,
  21. R4_3,
  22. R21_9,
  23. R16_10,
  24. StretchToWindow,
  25. };
  26. /// Describes the layout of the window framebuffer
  27. struct FramebufferLayout {
  28. u32 width{ScreenUndocked::Width};
  29. u32 height{ScreenUndocked::Height};
  30. Common::Rectangle<u32> screen;
  31. bool is_srgb{};
  32. };
  33. /**
  34. * Factory method for constructing a default FramebufferLayout
  35. * @param width Window framebuffer width in pixels
  36. * @param height Window framebuffer height in pixels
  37. * @return Newly created FramebufferLayout object with default screen regions initialized
  38. */
  39. FramebufferLayout DefaultFrameLayout(u32 width, u32 height);
  40. /**
  41. * Convenience method to get frame layout by resolution scale
  42. * @param res_scale resolution scale factor
  43. */
  44. FramebufferLayout FrameLayoutFromResolutionScale(f32 res_scale);
  45. /**
  46. * Convenience method to determine emulation aspect ratio
  47. * @param aspect Represents the index of aspect ratio stored in Settings::values.aspect_ratio
  48. * @param window_aspect_ratio Current window aspect ratio
  49. * @return Emulation render window aspect ratio
  50. */
  51. float EmulationAspectRatio(AspectRatio aspect, float window_aspect_ratio);
  52. } // namespace Layout