ash_display_util.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2021 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_CHROMEOS_ASH_DISPLAY_UTIL_H_
  5. #define REMOTING_HOST_CHROMEOS_ASH_DISPLAY_UTIL_H_
  6. #include <cstdint>
  7. #include <vector>
  8. #include "base/callback_forward.h"
  9. #include "third_party/abseil-cpp/absl/types/optional.h"
  10. #include "ui/display/display.h"
  11. class SkBitmap;
  12. namespace remoting {
  13. using DisplayId = int64_t;
  14. // Utility class that abstracts away all display related actions on ChromeOs,
  15. // allowing us to inject a fake instance during unittests.
  16. class AshDisplayUtil {
  17. public:
  18. static AshDisplayUtil& Get();
  19. // The caller is responsible to ensure this given instance lives long enough.
  20. // To unset call this method again with nullptr.
  21. static void SetInstanceForTesting(AshDisplayUtil* instance);
  22. // Convert the scale factor to DPI.
  23. static int ScaleFactorToDpi(float scale_factor);
  24. static int GetDpi(const display::Display& display);
  25. virtual ~AshDisplayUtil();
  26. virtual DisplayId GetPrimaryDisplayId() const = 0;
  27. virtual const std::vector<display::Display>& GetActiveDisplays() const = 0;
  28. virtual const display::Display* GetDisplayForId(
  29. DisplayId display_id) const = 0;
  30. using ScreenshotCallback = base::OnceCallback<void(absl::optional<SkBitmap>)>;
  31. virtual void TakeScreenshotOfDisplay(DisplayId display_id,
  32. ScreenshotCallback callback) = 0;
  33. };
  34. } // namespace remoting
  35. #endif // REMOTING_HOST_CHROMEOS_ASH_DISPLAY_UTIL_H_