forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
display_manager.h
59 lines (46 loc) · 1.92 KB
/
display_manager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_SHELL_COMMON_DISPLAY_MANAGER_H_
#define FLUTTER_SHELL_COMMON_DISPLAY_MANAGER_H_
#include <mutex>
#include <vector>
#include "flutter/shell/common/display.h"
namespace flutter {
/// The update type parameter that is passed to
/// `DisplayManager::HandleDisplayUpdates`.
enum class DisplayUpdateType {
/// `flutter::Display`s that were active during start-up. A display is
/// considered active if:
/// 1. The frame buffer hardware is connected.
/// 2. The display is drawable, e.g. it isn't being mirrored from another
/// connected display or sleeping.
kStartup
};
/// Manages lifecycle of the connected displays. This class is thread-safe.
class DisplayManager {
public:
DisplayManager();
~DisplayManager();
/// Returns the display refresh rate of the main display. In cases where there
/// is only one display connected, it will return that. We do not yet support
/// cases where there are multiple displays.
///
/// When there are no registered displays, it returns
/// `kUnknownDisplayRefreshRate`.
double GetMainDisplayRefreshRate() const;
/// Handles the display updates.
void HandleDisplayUpdates(DisplayUpdateType update_type,
std::vector<Display> displays);
private:
/// Guards `displays_` vector.
mutable std::mutex displays_mutex_;
std::vector<Display> displays_;
/// Checks that the provided display configuration is valid. Currently this
/// ensures that all the displays have an id in the case there are multiple
/// displays. In case where there is a single display, it is valid for the
/// display to not have an id.
void CheckDisplayConfiguration(std::vector<Display> displays) const;
};
} // namespace flutter
#endif // FLUTTER_SHELL_COMMON_DISPLAY_MANAGER_H_