diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 16:17:30 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 16:17:30 +0000 |
commit | d30dac8892cd60cd076dc7d0589b5fecf6d534f6 (patch) | |
tree | 2fa81626cc01726209115ec169ff6b5fab5b3bd0 /chromeos | |
parent | 7990b88d68779a5763656fd6199123042a241c76 (diff) | |
download | chromium_src-d30dac8892cd60cd076dc7d0589b5fecf6d534f6.zip chromium_src-d30dac8892cd60cd076dc7d0589b5fecf6d534f6.tar.gz chromium_src-d30dac8892cd60cd076dc7d0589b5fecf6d534f6.tar.bz2 |
chromeos: Avoid an XRRGetScreenResources() call at startup.
OutputConfigurator::Init() and OutputConfigurator::Start()
both called XRRGetScreenResources() before the message loop
is started. Each call blocks for 60 milliseconds. This
change moves Init()'s code to set the background color into
Start() to reduce this to one call.
(There are still additional calls in
DisplayChangeObserverX11 that should be removed.)
BUG=254667
Review URL: https://chromiumcodereview.appspot.com/21130007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214756 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/display/output_configurator.cc | 18 | ||||
-rw-r--r-- | chromeos/display/output_configurator.h | 9 | ||||
-rw-r--r-- | chromeos/display/output_configurator_unittest.cc | 27 |
3 files changed, 24 insertions, 30 deletions
diff --git a/chromeos/display/output_configurator.cc b/chromeos/display/output_configurator.cc index 92f2953..2a51228 100644 --- a/chromeos/display/output_configurator.cc +++ b/chromeos/display/output_configurator.cc @@ -170,8 +170,7 @@ OutputConfigurator::OutputConfigurator() OutputConfigurator::~OutputConfigurator() {} -void OutputConfigurator::SetDelegateForTesting( - scoped_ptr<Delegate> delegate) { +void OutputConfigurator::SetDelegateForTesting(scoped_ptr<Delegate> delegate) { delegate_ = delegate.Pass(); configure_display_ = true; } @@ -181,24 +180,16 @@ void OutputConfigurator::SetInitialDisplayPower(DisplayPowerState power_state) { power_state_ = power_state; } -void OutputConfigurator::Init(bool is_panel_fitting_enabled, - uint32 background_color_argb) { +void OutputConfigurator::Init(bool is_panel_fitting_enabled) { if (!configure_display_) return; if (!delegate_) delegate_.reset(new RealOutputConfiguratorDelegate()); - - // Cache the initial output state. delegate_->SetPanelFittingEnabled(is_panel_fitting_enabled); - delegate_->GrabServer(); - std::vector<OutputSnapshot> outputs = delegate_->GetOutputs(); - if (outputs.size() > 1 && background_color_argb) - delegate_->SetBackgroundColor(background_color_argb); - delegate_->UngrabServer(); } -void OutputConfigurator::Start() { +void OutputConfigurator::Start(uint32 background_color_argb) { if (!configure_display_) return; @@ -206,6 +197,8 @@ void OutputConfigurator::Start() { delegate_->InitXRandRExtension(&xrandr_event_base_); std::vector<OutputSnapshot> outputs = delegate_->GetOutputs(); + if (outputs.size() > 1 && background_color_argb) + delegate_->SetBackgroundColor(background_color_argb); EnterStateOrFallBackToSoftwareMirroring( GetOutputState(outputs, power_state_), power_state_, outputs); @@ -214,6 +207,7 @@ void OutputConfigurator::Start() { delegate_->ForceDPMSOn(); delegate_->UngrabServer(); delegate_->SendProjectingStateToPowerManager(IsProjecting(outputs)); + NotifyOnDisplayChanged(); } void OutputConfigurator::Stop() { diff --git a/chromeos/display/output_configurator.h b/chromeos/display/output_configurator.h index 6805efa..5385b71 100644 --- a/chromeos/display/output_configurator.h +++ b/chromeos/display/output_configurator.h @@ -158,6 +158,7 @@ class CHROMEOS_EXPORT OutputConfigurator virtual void ForceDPMSOn() = 0; // Returns information about the current outputs. + // This method may block for 60 milliseconds or more. virtual std::vector<OutputSnapshot> GetOutputs() = 0; // Gets details corresponding to |mode|. Parameters may be NULL. @@ -251,13 +252,13 @@ class CHROMEOS_EXPORT OutputConfigurator // Initialization, must be called right after constructor. // |is_panel_fitting_enabled| indicates hardware panel fitting support. + void Init(bool is_panel_fitting_enabled); + + // Does initial configuration of displays during startup. // If |background_color_argb| is non zero and there are multiple displays, // OutputConfigurator sets the background color of X's RootWindow to this // color. - void Init(bool is_panel_fitting_enabled, uint32 background_color_argb); - - // Detects displays first time from unknown state. - void Start(); + void Start(uint32 background_color_argb); // Stop handling display configuration events/requests. void Stop(); diff --git a/chromeos/display/output_configurator_unittest.cc b/chromeos/display/output_configurator_unittest.cc index 6c28d97..d0308a8 100644 --- a/chromeos/display/output_configurator_unittest.cc +++ b/chromeos/display/output_configurator_unittest.cc @@ -309,10 +309,9 @@ class OutputConfiguratorTest : public testing::Test { virtual void InitWithSingleOutput() { UpdateOutputs(1); EXPECT_EQ(kNoActions, delegate_->GetActionsAndClear()); - configurator_.Init(false, 0); - EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), - delegate_->GetActionsAndClear()); - configurator_.Start(); + configurator_.Init(false); + EXPECT_EQ(kNoActions, delegate_->GetActionsAndClear()); + configurator_.Start(0); EXPECT_EQ(JoinActions(kGrab, kInitXRandR, GetFramebufferAction(kSmallModeWidth, kSmallModeHeight, outputs_[0].crtc, 0).c_str(), @@ -662,9 +661,9 @@ TEST_F(OutputConfiguratorTest, SuspendAndResume) { TEST_F(OutputConfiguratorTest, Headless) { UpdateOutputs(0); EXPECT_EQ(kNoActions, delegate_->GetActionsAndClear()); - configurator_.Init(false, 0); - EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), delegate_->GetActionsAndClear()); - configurator_.Start(); + configurator_.Init(false); + EXPECT_EQ(kNoActions, delegate_->GetActionsAndClear()); + configurator_.Start(0); EXPECT_EQ(JoinActions(kGrab, kInitXRandR, kForceDPMS, kUngrab, kProjectingOff, NULL), delegate_->GetActionsAndClear()); @@ -696,11 +695,11 @@ TEST_F(OutputConfiguratorTest, Headless) { TEST_F(OutputConfiguratorTest, StartWithTwoOutputs) { UpdateOutputs(2); EXPECT_EQ(kNoActions, delegate_->GetActionsAndClear()); - configurator_.Init(false, 0); - EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), delegate_->GetActionsAndClear()); + configurator_.Init(false); + EXPECT_EQ(kNoActions, delegate_->GetActionsAndClear()); state_controller_.set_state(STATE_DUAL_MIRROR); - configurator_.Start(); + configurator_.Start(0); EXPECT_EQ(JoinActions(kGrab, kInitXRandR, GetFramebufferAction(kSmallModeWidth, kSmallModeHeight, outputs_[0].crtc, outputs_[1].crtc).c_str(), @@ -715,8 +714,8 @@ TEST_F(OutputConfiguratorTest, StartWithTwoOutputs) { TEST_F(OutputConfiguratorTest, InvalidOutputStates) { UpdateOutputs(0); EXPECT_EQ(kNoActions, delegate_->GetActionsAndClear()); - configurator_.Init(false, 0); - configurator_.Start(); + configurator_.Init(false); + configurator_.Start(0); EXPECT_TRUE(configurator_.SetDisplayMode(STATE_HEADLESS)); EXPECT_FALSE(configurator_.SetDisplayMode(STATE_SINGLE)); EXPECT_FALSE(configurator_.SetDisplayMode(STATE_DUAL_MIRROR)); @@ -742,8 +741,8 @@ TEST_F(OutputConfiguratorTest, GetOutputStateForDisplays) { outputs_[0].has_display_id = false; UpdateOutputs(2); - configurator_.Init(false, 0); - configurator_.Start(); + configurator_.Init(false); + configurator_.Start(0); state_controller_.set_state(STATE_DUAL_MIRROR); test_api_.SendOutputChangeEvents(true); |