framebuffer_layout.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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/math_util.h"
  6. namespace Layout {
  7. enum ScreenUndocked : unsigned { Width = 1280, Height = 720 };
  8. /// Describes the layout of the window framebuffer
  9. struct FramebufferLayout {
  10. unsigned width{ScreenUndocked::Width};
  11. unsigned height{ScreenUndocked::Height};
  12. MathUtil::Rectangle<unsigned> screen;
  13. /**
  14. * Returns the ration of pixel size of the screen, compared to the native size of the undocked
  15. * Switch screen.
  16. */
  17. float GetScalingRatio() const {
  18. return static_cast<float>(screen.GetWidth()) / ScreenUndocked::Width;
  19. }
  20. };
  21. /**
  22. * Factory method for constructing a default FramebufferLayout
  23. * @param width Window framebuffer width in pixels
  24. * @param height Window framebuffer height in pixels
  25. * @return Newly created FramebufferLayout object with default screen regions initialized
  26. */
  27. FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height);
  28. } // namespace Layout