framebuffer_layout.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common_types.h"
  6. #include "common/math_util.h"
  7. namespace Layout {
  8. namespace MinimumSize {
  9. constexpr u32 Width = 640;
  10. constexpr u32 Height = 360;
  11. } // namespace MinimumSize
  12. namespace ScreenUndocked {
  13. constexpr u32 Width = 1280;
  14. constexpr u32 Height = 720;
  15. } // namespace ScreenUndocked
  16. namespace ScreenDocked {
  17. constexpr u32 Width = 1920;
  18. constexpr u32 Height = 1080;
  19. } // namespace ScreenDocked
  20. enum class AspectRatio {
  21. Default,
  22. R4_3,
  23. R21_9,
  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