desktop_resizer.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef REMOTING_HOST_DESKTOP_RESIZER_H_
  5. #define REMOTING_HOST_DESKTOP_RESIZER_H_
  6. #include <list>
  7. #include <memory>
  8. #include "remoting/host/base/screen_resolution.h"
  9. #include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h"
  10. namespace remoting {
  11. // Interface for resizing the desktop displays. These methods take an optional
  12. // |screen_id| parameter to resize an individual monitor. If |screen_id| refers
  13. // to a monitor that no longer exists, the implementation should do nothing, or
  14. // return empty data. If |screen_id| is not provided, the implementation should
  15. // operate on the single monitor if there is only one. If there are several
  16. // monitors, the implementation should fall back to the legacy (per-platform)
  17. // behavior.
  18. class DesktopResizer {
  19. public:
  20. virtual ~DesktopResizer() {}
  21. // Create a platform-specific DesktopResizer instance.
  22. static std::unique_ptr<DesktopResizer> Create();
  23. // Return the current resolution of the monitor.
  24. virtual ScreenResolution GetCurrentResolution(webrtc::ScreenId screen_id) = 0;
  25. // Get the list of supported resolutions for the monitor, which should ideally
  26. // include |preferred|. Implementations will generally do one of the
  27. // following:
  28. // 1. Return the list of resolutions supported by the underlying video
  29. // driver, regardless of |preferred|.
  30. // 2. Return a list containing just |preferred|, perhaps after imposing
  31. // some minimum size constraint. This will typically be the case if
  32. // there are no constraints imposed by the underlying video driver.
  33. // 3. Return an empty list if resize is not supported.
  34. virtual std::list<ScreenResolution> GetSupportedResolutions(
  35. const ScreenResolution& preferred,
  36. webrtc::ScreenId screen_id) = 0;
  37. // Set the resolution of the monitor. |resolution| must be one of the
  38. // resolutions previously returned by |GetSupportedResolutions|. Note that
  39. // implementations should fail gracefully if the specified resolution is no
  40. // longer supported, since monitor configurations may change on the fly.
  41. virtual void SetResolution(const ScreenResolution& resolution,
  42. webrtc::ScreenId screen_id) = 0;
  43. // Restore the original monitor resolution. The caller must provide the
  44. // original resolution of the monitor, as returned by GetCurrentResolution(),
  45. // as a hint. However, implementations are free to ignore this. For example,
  46. // virtual hosts will typically ignore it to avoid unnecessary resizes.
  47. virtual void RestoreResolution(const ScreenResolution& original,
  48. webrtc::ScreenId screen_id) = 0;
  49. };
  50. } // namespace remoting
  51. #endif // REMOTING_HOST_DESKTOP_RESIZER_H_