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

Side by Side Diff: ui/display/chromeos/display_configurator.cc

Issue 2427843002: Delay display configuration after waking up from suspend with multi displays (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/display/chromeos/display_configurator.h" 5 #include "ui/display/chromeos/display_configurator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 17 matching lines...) Expand all
28 namespace ui { 28 namespace ui {
29 29
30 namespace { 30 namespace {
31 31
32 typedef std::vector<const DisplayMode*> DisplayModeList; 32 typedef std::vector<const DisplayMode*> DisplayModeList;
33 33
34 // The delay to perform configuration after RRNotify. See the comment for 34 // The delay to perform configuration after RRNotify. See the comment for
35 // |configure_timer_|. 35 // |configure_timer_|.
36 const int kConfigureDelayMs = 500; 36 const int kConfigureDelayMs = 500;
37 37
38 // The delay to perform configuration after waking up from suspend when in dual
39 // display mode. Should be bigger than |kConfigureDelayMs|. Generally big enough
40 // for external displays to be detected and added.
oshima 2016/10/18 22:00:05 please add reference to the bug
afakhry 2016/10/21 20:03:03 Done.
41 const int kConfigureDualDisplayAfterSuspendDelayMs = 2000;
42
38 // The EDID specification marks the top bit of the manufacturer id as reserved. 43 // The EDID specification marks the top bit of the manufacturer id as reserved.
39 const int16_t kReservedManufacturerID = static_cast<int16_t>(1 << 15); 44 const int16_t kReservedManufacturerID = static_cast<int16_t>(1 << 15);
40 45
41 struct DisplayState { 46 struct DisplayState {
42 DisplaySnapshot* display = nullptr; // Not owned. 47 DisplaySnapshot* display = nullptr; // Not owned.
43 48
44 // User-selected mode for the display. 49 // User-selected mode for the display.
45 const DisplayMode* selected_mode = nullptr; 50 const DisplayMode* selected_mode = nullptr;
46 51
47 // Mode used when displaying the same desktop on multiple displays. 52 // Mode used when displaying the same desktop on multiple displays.
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 !(flags & kSetDisplayPowerForceProbe)) { 860 !(flags & kSetDisplayPowerForceProbe)) {
856 callback.Run(true); 861 callback.Run(true);
857 return; 862 return;
858 } 863 }
859 864
860 pending_power_state_ = power_state; 865 pending_power_state_ = power_state;
861 has_pending_power_state_ = true; 866 has_pending_power_state_ = true;
862 pending_power_flags_ = flags; 867 pending_power_flags_ = flags;
863 queued_configuration_callbacks_.push_back(callback); 868 queued_configuration_callbacks_.push_back(callback);
864 869
865 RunPendingConfiguration(); 870 if (power_state == chromeos::DISPLAY_POWER_ALL_ON &&
dnicoara 2016/10/19 14:42:41 I don't think this is the correct place to start t
Daniel Erat 2016/10/19 16:57:56 good catch; this seems wrong to me too. when power
afakhry 2016/10/21 20:03:03 Done.
afakhry 2016/10/21 20:03:03 Thanks for catching that. Done. I modified the uni
871 (current_display_state_ == MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED ||
872 current_display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)) {
873 // When waking up from suspend while being in a dual display mode, we
874 // perform a forced configuration after a delay to wait for all displays to
875 // be added and detected.
876 configure_timer_.Start(FROM_HERE,
877 base::TimeDelta::FromMilliseconds(
878 kConfigureDualDisplayAfterSuspendDelayMs),
879 this, &DisplayConfigurator::ConfigureDisplays);
880 } else {
881 RunPendingConfiguration();
882 }
866 } 883 }
867 884
868 void DisplayConfigurator::SetDisplayPower( 885 void DisplayConfigurator::SetDisplayPower(
869 chromeos::DisplayPowerState power_state, 886 chromeos::DisplayPowerState power_state,
870 int flags, 887 int flags,
871 const ConfigurationCallback& callback) { 888 const ConfigurationCallback& callback) {
872 if (!configure_display_ || display_externally_controlled_) { 889 if (!configure_display_ || display_externally_controlled_) {
873 callback.Run(false); 890 callback.Run(false);
874 return; 891 return;
875 } 892 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 // Don't do anything if the displays are currently suspended. Instead we will 926 // Don't do anything if the displays are currently suspended. Instead we will
910 // probe and reconfigure the displays if necessary in ResumeDisplays(). 927 // probe and reconfigure the displays if necessary in ResumeDisplays().
911 if (displays_suspended_) { 928 if (displays_suspended_) {
912 VLOG(1) << "Displays are currently suspended. Not attempting to " 929 VLOG(1) << "Displays are currently suspended. Not attempting to "
913 << "reconfigure them."; 930 << "reconfigure them.";
914 return; 931 return;
915 } 932 }
916 933
917 // Configure displays with |kConfigureDelayMs| delay, 934 // Configure displays with |kConfigureDelayMs| delay,
918 // so that time-consuming ConfigureDisplays() won't be called multiple times. 935 // so that time-consuming ConfigureDisplays() won't be called multiple times.
919 if (configure_timer_.IsRunning()) { 936 if (configure_timer_.IsRunning() &&
920 // Note: when the timer is running it is possible that a different task 937 configure_timer_.GetCurrentDelay() <=
921 // (RestoreRequestedPowerStateAfterResume()) is scheduled. In these cases, 938 base::TimeDelta::FromMilliseconds(kConfigureDelayMs)) {
922 // prefer the already scheduled task to ConfigureDisplays() since 939 // Avoid resetting the timer to a huge delay if we are currently pending
923 // ConfigureDisplays() performs only basic configuration while 940 // the delayed configuration after waking up from suspend.
924 // RestoreRequestedPowerStateAfterResume() will perform additional
925 // operations.
afakhry 2016/10/17 22:35:28 Outdated comment? Do we still need the below Reset
oshima 2016/10/18 22:00:05 +derat
926 configure_timer_.Reset(); 941 configure_timer_.Reset();
927 } else { 942 } else {
928 configure_timer_.Start( 943 configure_timer_.Start(
929 FROM_HERE, 944 FROM_HERE,
930 base::TimeDelta::FromMilliseconds(kConfigureDelayMs), 945 base::TimeDelta::FromMilliseconds(kConfigureDelayMs),
931 this, 946 this,
932 &DisplayConfigurator::ConfigureDisplays); 947 &DisplayConfigurator::ConfigureDisplays);
933 } 948 }
934 } 949 }
935 950
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 last_virtual_display_id_ = max_display_id & 0xff; 1175 last_virtual_display_id_ = max_display_id & 0xff;
1161 1176
1162 return true; 1177 return true;
1163 } 1178 }
1164 1179
1165 bool DisplayConfigurator::IsDisplayOn() const { 1180 bool DisplayConfigurator::IsDisplayOn() const {
1166 return current_power_state_ != chromeos::DISPLAY_POWER_ALL_OFF; 1181 return current_power_state_ != chromeos::DISPLAY_POWER_ALL_OFF;
1167 } 1182 }
1168 1183
1169 } // namespace ui 1184 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698