framebuffer_layout.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. enum ScreenDocked : unsigned { WidthDocked = 1920, HeightDocked = 1080 };
  9. /// Describes the layout of the window framebuffer
  10. struct FramebufferLayout {
  11. unsigned width{ScreenUndocked::Width};
  12. unsigned height{ScreenUndocked::Height};
  13. Common::Rectangle<unsigned> screen;
  14. /**
  15. * Returns the ration of pixel size of the screen, compared to the native size of the undocked
  16. * Switch screen.
  17. */
  18. float GetScalingRatio() const {
  19. return static_cast<float>(screen.GetWidth()) / ScreenUndocked::Width;
  20. }
  21. };
  22. /**
  23. * Factory method for constructing a default FramebufferLayout
  24. * @param width Window framebuffer width in pixels
  25. * @param height Window framebuffer height in pixels
  26. * @return Newly created FramebufferLayout object with default screen regions initialized
  27. */
  28. FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height);
  29. /**
  30. * Convenience method to get frame layout by resolution scale
  31. * @param res_scale resolution scale factor
  32. */
  33. FramebufferLayout FrameLayoutFromResolutionScale(u16 res_scale);
  34. } // namespace Layout