framebuffer_layout.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. StretchToWindow,
  24. };
  25. /// Describes the layout of the window framebuffer
  26. struct FramebufferLayout {
  27. u32 width{ScreenUndocked::Width};
  28. u32 height{ScreenUndocked::Height};
  29. Common::Rectangle<u32> screen;
  30. bool is_srgb{};
  31. };
  32. /**
  33. * Factory method for constructing a default FramebufferLayout
  34. * @param width Window framebuffer width in pixels
  35. * @param height Window framebuffer height in pixels
  36. * @return Newly created FramebufferLayout object with default screen regions initialized
  37. */
  38. FramebufferLayout DefaultFrameLayout(u32 width, u32 height);
  39. /**
  40. * Convenience method to get frame layout by resolution scale
  41. * @param res_scale resolution scale factor
  42. */
  43. FramebufferLayout FrameLayoutFromResolutionScale(f32 res_scale);
  44. /**
  45. * Convenience method to determine emulation aspect ratio
  46. * @param aspect Represents the index of aspect ratio stored in Settings::values.aspect_ratio
  47. * @param window_aspect_ratio Current window aspect ratio
  48. * @return Emulation render window aspect ratio
  49. */
  50. float EmulationAspectRatio(AspectRatio aspect, float window_aspect_ratio);
  51. } // namespace Layout