| 1 | // Copyright 2013 The Flutter 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 | |
| 5 | #ifndef FLUTTER_SHELL_COMMON_DISPLAY_MANAGER_H_ |
| 6 | #define FLUTTER_SHELL_COMMON_DISPLAY_MANAGER_H_ |
| 7 | |
| 8 | #include <mutex> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include "flutter/shell/common/display.h" |
| 12 | |
| 13 | namespace flutter { |
| 14 | |
| 15 | /// Manages lifecycle of the connected displays. This class is thread-safe. |
| 16 | class DisplayManager { |
| 17 | public: |
| 18 | DisplayManager(); |
| 19 | |
| 20 | ~DisplayManager(); |
| 21 | |
| 22 | /// Returns the display refresh rate of the main display. In cases where there |
| 23 | /// is only one display connected, it will return that. We do not yet support |
| 24 | /// cases where there are multiple displays. |
| 25 | /// |
| 26 | /// When there are no registered displays, it returns |
| 27 | /// `kUnknownDisplayRefreshRate`. |
| 28 | double GetMainDisplayRefreshRate() const; |
| 29 | |
| 30 | /// Handles the display updates. |
| 31 | void HandleDisplayUpdates(std::vector<std::unique_ptr<Display>> displays); |
| 32 | |
| 33 | private: |
| 34 | /// Guards `displays_` vector. |
| 35 | mutable std::mutex displays_mutex_; |
| 36 | std::vector<std::unique_ptr<Display>> displays_; |
| 37 | }; |
| 38 | |
| 39 | } // namespace flutter |
| 40 | |
| 41 | #endif // FLUTTER_SHELL_COMMON_DISPLAY_MANAGER_H_ |
| 42 | |