Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6e65ba1

Browse files
committed
fix code review comments
1 parent 4dac64d commit 6e65ba1

File tree

6 files changed

+20
-15
lines changed

6 files changed

+20
-15
lines changed

shell/common/display.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Display {
2323
public:
2424
//------------------------------------------------------------------------------
2525
/// @brief Construct a new Display object in case where the display id of the
26-
/// display is known. In cases where there are more than one displays, every
26+
/// display is known. In cases where there is more than one display, every
2727
/// display is expected to have a display id.
2828
///
2929
Display(DisplayId display_id, double refresh_rate)
@@ -33,7 +33,8 @@ class Display {
3333
/// @brief Construct a new Display object when there is only a single display.
3434
/// When there are multiple displays, every display must have a display id.
3535
///
36-
Display(double refresh_rate) : display_id_({}), refresh_rate_(refresh_rate) {}
36+
explicit Display(double refresh_rate)
37+
: display_id_({}), refresh_rate_(refresh_rate) {}
3738

3839
~Display() = default;
3940

shell/common/display_manager.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ DisplayManager::DisplayManager() = default;
1313

1414
DisplayManager::~DisplayManager() = default;
1515

16-
double DisplayManager::GetMainDisplayRefreshRate() {
16+
double DisplayManager::GetMainDisplayRefreshRate() const {
1717
std::scoped_lock lock(displays_mutex_);
1818
if (displays_.empty()) {
1919
return kUnknownDisplayRefreshRate;
@@ -24,19 +24,20 @@ double DisplayManager::GetMainDisplayRefreshRate() {
2424

2525
void DisplayManager::HandleDisplayUpdates(DisplayUpdateType update_type,
2626
std::vector<Display> displays) {
27-
CheckDisplayConfiguration(displays);
2827
std::scoped_lock lock(displays_mutex_);
28+
CheckDisplayConfiguration(displays);
2929
switch (update_type) {
3030
case DisplayUpdateType::kStartup:
3131
FML_CHECK(displays_.empty());
3232
displays_ = displays;
3333
return;
3434
default:
35-
FML_LOG(ERROR) << "Unknown DisplayUpdateType.";
35+
FML_CHECK(false) << "Unknown DisplayUpdateType.";
3636
}
3737
}
3838

39-
void DisplayManager::CheckDisplayConfiguration(std::vector<Display> displays) {
39+
void DisplayManager::CheckDisplayConfiguration(
40+
std::vector<Display> displays) const {
4041
FML_CHECK(!displays.empty());
4142
if (displays.size() > 1) {
4243
for (auto& display : displays) {

shell/common/display_manager.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ enum class DisplayUpdateType {
1919
/// considered active if:
2020
/// 1. The frame buffer hardware is connected.
2121
/// 2. The display is drawable, e.g. it isn't being mirrored from another
22-
/// connected display or sleeping.
22+
/// connected display or sleeping.
2323
kStartup
2424
};
2525

@@ -31,26 +31,27 @@ class DisplayManager {
3131
~DisplayManager();
3232

3333
/// Returns the display refresh rate of the main display. In cases where there
34-
/// is only one display connected, it will return that. We do not yer support
34+
/// is only one display connected, it will return that. We do not yet support
3535
/// cases where there are multiple displays.
3636
///
3737
/// When there are no registered displays, it returns
3838
/// `kUnknownDisplayRefreshRate`.
39-
double GetMainDisplayRefreshRate();
39+
double GetMainDisplayRefreshRate() const;
4040

4141
/// Handles the display updates.
4242
void HandleDisplayUpdates(DisplayUpdateType update_type,
4343
std::vector<Display> displays);
4444

4545
private:
4646
/// Guards `displays_` vector.
47-
std::mutex displays_mutex_;
47+
mutable std::mutex displays_mutex_;
4848
std::vector<Display> displays_;
4949

5050
/// Checks that the provided display configuration is valid. Currently this
51-
/// ensures that all the displays have id in case there are multiple. In case
52-
/// there is a single display, it is valid for the display to not have an id.
53-
void CheckDisplayConfiguration(std::vector<Display> displays);
51+
/// ensures that all the displays have an id in the case there are multiple
52+
/// displays. In case where there is a single display, it is valid for the
53+
/// display to not have an id.
54+
void CheckDisplayConfiguration(std::vector<Display> displays) const;
5455
};
5556

5657
} // namespace flutter

shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ - (void)invalidate {
8383
- (void)dealloc {
8484
[self invalidate];
8585

86+
[display_link_ dealloc];
8687
[super dealloc];
8788
}
8889

@@ -129,6 +130,7 @@ - (void)onDisplayLink:(CADisplayLink*)link {
129130
- (void)dealloc {
130131
[display_link_ invalidate];
131132

133+
[display_link_ dealloc];
132134
[super dealloc];
133135
}
134136

shell/platform/embedder/embedder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ static bool ValidDisplayConfiguration(const FlutterEngineDisplay* displays,
19621962
size_t display_count) {
19631963
std::set<FlutterEngineDisplayId> display_ids;
19641964
for (size_t i = 0; i < display_count; i++) {
1965-
if (displays[i].single_display && (display_count != 1)) {
1965+
if (displays[i].single_display && display_count != 1) {
19661966
return false;
19671967
}
19681968
display_ids.insert(displays[i].display_id);

shell/platform/embedder/embedder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ typedef enum {
10091009
///
10101010
FlutterEngineResult FlutterEngineNotifyDisplayUpdate(
10111011
FLUTTER_API_SYMBOL(FlutterEngine) engine,
1012-
const FlutterEngineDisplaysUpdateType update_type,
1012+
FlutterEngineDisplaysUpdateType update_type,
10131013
const FlutterEngineDisplay* displays,
10141014
size_t display_count);
10151015

0 commit comments

Comments
 (0)