| OLD | NEW |
| 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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 configure_display_ = true; | 513 configure_display_ = true; |
| 514 } | 514 } |
| 515 | 515 |
| 516 void DisplayConfigurator::SetInitialDisplayPower( | 516 void DisplayConfigurator::SetInitialDisplayPower( |
| 517 chromeos::DisplayPowerState power_state) { | 517 chromeos::DisplayPowerState power_state) { |
| 518 DCHECK_EQ(current_display_state_, MULTIPLE_DISPLAY_STATE_INVALID); | 518 DCHECK_EQ(current_display_state_, MULTIPLE_DISPLAY_STATE_INVALID); |
| 519 requested_power_state_ = current_power_state_ = power_state; | 519 requested_power_state_ = current_power_state_ = power_state; |
| 520 NotifyPowerStateObservers(); | 520 NotifyPowerStateObservers(); |
| 521 } | 521 } |
| 522 | 522 |
| 523 void DisplayConfigurator::Init(bool is_panel_fitting_enabled) { | 523 void DisplayConfigurator::Init( |
| 524 std::unique_ptr<NativeDisplayDelegate> display_delegate, |
| 525 bool is_panel_fitting_enabled) { |
| 524 is_panel_fitting_enabled_ = is_panel_fitting_enabled; | 526 is_panel_fitting_enabled_ = is_panel_fitting_enabled; |
| 525 if (!configure_display_ || display_externally_controlled_) | 527 if (!configure_display_ || display_externally_controlled_) |
| 526 return; | 528 return; |
| 527 | 529 |
| 528 // If the delegate is already initialized don't update it (For example, tests | 530 // If the delegate is already initialized don't update it (For example, tests |
| 529 // set their own delegates). | 531 // set their own delegates). |
| 530 if (!native_display_delegate_) { | 532 if (!native_display_delegate_) { |
| 531 native_display_delegate_ = CreatePlatformNativeDisplayDelegate(); | 533 native_display_delegate_ = std::move(display_delegate); |
| 532 native_display_delegate_->AddObserver(this); | 534 native_display_delegate_->AddObserver(this); |
| 533 } | 535 } |
| 534 } | 536 } |
| 535 | 537 |
| 536 void DisplayConfigurator::TakeControl(const DisplayControlCallback& callback) { | 538 void DisplayConfigurator::TakeControl(const DisplayControlCallback& callback) { |
| 537 if (display_control_changing_) { | 539 if (display_control_changing_) { |
| 538 callback.Run(false); | 540 callback.Run(false); |
| 539 return; | 541 return; |
| 540 } | 542 } |
| 541 | 543 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 } | 603 } |
| 602 | 604 |
| 603 callback.Run(success); | 605 callback.Run(success); |
| 604 } | 606 } |
| 605 | 607 |
| 606 void DisplayConfigurator::ForceInitialConfigure( | 608 void DisplayConfigurator::ForceInitialConfigure( |
| 607 uint32_t background_color_argb) { | 609 uint32_t background_color_argb) { |
| 608 if (!configure_display_ || display_externally_controlled_) | 610 if (!configure_display_ || display_externally_controlled_) |
| 609 return; | 611 return; |
| 610 | 612 |
| 613 DCHECK(native_display_delegate_); |
| 611 native_display_delegate_->Initialize(); | 614 native_display_delegate_->Initialize(); |
| 612 | 615 |
| 613 // ForceInitialConfigure should be the first configuration so there shouldn't | 616 // ForceInitialConfigure should be the first configuration so there shouldn't |
| 614 // be anything scheduled. | 617 // be anything scheduled. |
| 615 DCHECK(!configuration_task_); | 618 DCHECK(!configuration_task_); |
| 616 | 619 |
| 617 configuration_task_.reset(new UpdateDisplayConfigurationTask( | 620 configuration_task_.reset(new UpdateDisplayConfigurationTask( |
| 618 native_display_delegate_.get(), layout_manager_.get(), | 621 native_display_delegate_.get(), layout_manager_.get(), |
| 619 requested_display_state_, requested_power_state_, | 622 requested_display_state_, requested_power_state_, |
| 620 kSetDisplayPowerForceProbe, background_color_argb, true, | 623 kSetDisplayPowerForceProbe, background_color_argb, true, |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 last_virtual_display_id_ = max_display_id & 0xff; | 1154 last_virtual_display_id_ = max_display_id & 0xff; |
| 1152 | 1155 |
| 1153 return true; | 1156 return true; |
| 1154 } | 1157 } |
| 1155 | 1158 |
| 1156 bool DisplayConfigurator::IsDisplayOn() const { | 1159 bool DisplayConfigurator::IsDisplayOn() const { |
| 1157 return current_power_state_ != chromeos::DISPLAY_POWER_ALL_OFF; | 1160 return current_power_state_ != chromeos::DISPLAY_POWER_ALL_OFF; |
| 1158 } | 1161 } |
| 1159 | 1162 |
| 1160 } // namespace ui | 1163 } // namespace ui |
| OLD | NEW |