Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: ui/display/chromeos/display_configurator.cc

Issue 2427843002: Delay display configuration after waking up from suspend with multi displays (Closed)
Patch Set: Working solution on stumpy Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/display/chromeos/display_configurator.cc
diff --git a/ui/display/chromeos/display_configurator.cc b/ui/display/chromeos/display_configurator.cc
index 6c3062317944388f13615d2e7ae7d6db5a276a5a..56bd10da733baee5d26345555444dcc9617ed11a 100644
--- a/ui/display/chromeos/display_configurator.cc
+++ b/ui/display/chromeos/display_configurator.cc
@@ -31,10 +31,6 @@ namespace {
typedef std::vector<const DisplayMode*> DisplayModeList;
-// The delay to perform configuration after RRNotify. See the comment for
-// |configure_timer_|.
-const int kConfigureDelayMs = 500;
-
// The EDID specification marks the top bit of the manufacturer id as reserved.
const int16_t kReservedManufacturerID = static_cast<int16_t>(1 << 15);
@@ -862,6 +858,14 @@ void DisplayConfigurator::SetDisplayPowerInternal(
pending_power_flags_ = flags;
queued_configuration_callbacks_.push_back(callback);
+ if (configure_timer_.IsRunning()) {
+ // If there is a configuration task scheduled, avoid performing
+ // configuration immediately. Instead reset the timer to wait for things to
+ // settle.
+ configure_timer_.Reset();
+ return;
+ }
+
RunPendingConfiguration();
}
@@ -916,13 +920,11 @@ void DisplayConfigurator::OnConfigurationChanged() {
// Configure displays with |kConfigureDelayMs| delay,
// so that time-consuming ConfigureDisplays() won't be called multiple times.
- if (configure_timer_.IsRunning()) {
- // Note: when the timer is running it is possible that a different task
- // (RestoreRequestedPowerStateAfterResume()) is scheduled. In these cases,
- // prefer the already scheduled task to ConfigureDisplays() since
- // ConfigureDisplays() performs only basic configuration while
- // RestoreRequestedPowerStateAfterResume() will perform additional
- // operations.
+ if (configure_timer_.IsRunning() &&
+ configure_timer_.GetCurrentDelay() <=
+ base::TimeDelta::FromMilliseconds(kConfigureDelayMs)) {
+ // Avoid resetting the timer to a huge delay if we are currently pending
+ // the delayed configuration after waking up from suspend.
configure_timer_.Reset();
} else {
configure_timer_.Start(
@@ -967,15 +969,7 @@ void DisplayConfigurator::SuspendDisplays(
}
void DisplayConfigurator::ResumeDisplays() {
- if (!configure_display_ || display_externally_controlled_)
- return;
-
- displays_suspended_ = false;
-
- // If requested_power_state_ is ALL_OFF due to idle suspend, powerd will turn
- // the display power on when it enables the backlight.
- SetDisplayPower(requested_power_state_, kSetDisplayPowerNoFlags,
- base::Bind(&DoNothing));
+ ResumeDisplaysInternal(base::Bind(&DoNothing));
Daniel Erat 2016/10/21 21:09:44 this seems weird: a helper method that's only call
afakhry 2016/10/22 00:28:48 Unittests need to provide a callback, but clients
}
void DisplayConfigurator::ConfigureDisplays() {
@@ -1165,4 +1159,31 @@ bool DisplayConfigurator::IsDisplayOn() const {
return current_power_state_ != chromeos::DISPLAY_POWER_ALL_OFF;
}
+void DisplayConfigurator::ResumeDisplaysInternal(
+ const ConfigurationCallback& callback) {
+ if (!configure_display_ || display_externally_controlled_)
+ return;
+
+ displays_suspended_ = false;
+
+ // If requested_power_state_ is ALL_OFF due to idle suspend, powerd will turn
+ // the display power on when it enables the backlight.
Daniel Erat 2016/10/21 21:09:44 did you mean to keep this comment above the SetDis
afakhry 2016/10/22 00:28:48 Yep, thanks for catching that. Done.
+ if (current_display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR ||
+ current_display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED ||
+ current_display_state_ == MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED) {
+ // When waking up from suspend while being in a multi display mode, we
+ // schedule a delayed forced configuration, which will make
+ // SetDisplayPowerInternal() avoid performing the configuration immediately.
+ // This gives a chance to wait for all displays to be added and detected
+ // before configuration is performed.
+ configure_timer_.Start(FROM_HERE,
+ base::TimeDelta::FromMilliseconds(
+ kResumeConfigureMultiDisplayDelayMs),
+ this,
+ &DisplayConfigurator::ConfigureDisplays);
+ }
+
+ SetDisplayPower(requested_power_state_, kSetDisplayPowerNoFlags, callback);
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698