Flutter Engine
display_manager.cc
Go to the documentation of this file.
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 #include "flutter/shell/common/display_manager.h"
6 
7 #include "flutter/fml/logging.h"
8 #include "flutter/fml/macros.h"
9 
10 namespace flutter {
11 
13 
15 
17  std::scoped_lock lock(displays_mutex_);
18  if (displays_.empty()) {
20  } else {
21  return displays_[0]->GetRefreshRate();
22  }
23 }
24 
26  DisplayUpdateType update_type,
27  std::vector<std::unique_ptr<Display>> displays) {
28  std::scoped_lock lock(displays_mutex_);
29  CheckDisplayConfiguration(displays);
30  switch (update_type) {
32  FML_CHECK(displays_.empty());
33  displays_ = std::move(displays);
34  return;
35  default:
36  FML_CHECK(false) << "Unknown DisplayUpdateType.";
37  }
38 }
39 
40 void DisplayManager::CheckDisplayConfiguration(
41  const std::vector<std::unique_ptr<Display>>& displays) const {
42  FML_CHECK(!displays.empty());
43  if (displays.size() > 1) {
44  for (auto& display : displays) {
45  FML_CHECK(display->GetDisplayId().has_value());
46  }
47  }
48 }
49 
50 } // namespace flutter
static constexpr double kUnknownDisplayRefreshRate
To be used when the display refresh rate is unknown.
Definition: display.h:20
#define FML_CHECK(condition)
Definition: logging.h:68
double GetMainDisplayRefreshRate() const
void HandleDisplayUpdates(DisplayUpdateType update_type, std::vector< std::unique_ptr< Display >> displays)
Handles the display updates.