| Index: ui/display/chromeos/output_configurator.cc
|
| diff --git a/chromeos/display/output_configurator.cc b/ui/display/chromeos/output_configurator.cc
|
| similarity index 79%
|
| rename from chromeos/display/output_configurator.cc
|
| rename to ui/display/chromeos/output_configurator.cc
|
| index bc6124815ce0aeef3a7a47bdcde20e7086602deb..7002631309792ea50ae6ef61ce71a08dde6bce33 100644
|
| --- a/chromeos/display/output_configurator.cc
|
| +++ b/ui/display/chromeos/output_configurator.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chromeos/display/output_configurator.h"
|
| +#include "ui/display/chromeos/output_configurator.h"
|
|
|
| #include <X11/Xlib.h>
|
| #include <X11/extensions/Xrandr.h>
|
| @@ -13,11 +13,11 @@
|
| #include "base/strings/stringprintf.h"
|
| #include "base/sys_info.h"
|
| #include "base/time/time.h"
|
| -#include "chromeos/display/native_display_delegate_x11.h"
|
| -#include "chromeos/display/output_util.h"
|
| -#include "chromeos/display/touchscreen_delegate_x11.h"
|
| +#include "ui/display/chromeos/x11/display_util.h"
|
| +#include "ui/display/chromeos/x11/native_display_delegate_x11.h"
|
| +#include "ui/display/chromeos/x11/touchscreen_delegate_x11.h"
|
|
|
| -namespace chromeos {
|
| +namespace ui {
|
|
|
| namespace {
|
|
|
| @@ -26,15 +26,15 @@ namespace {
|
| const int64 kConfigureDelayMs = 500;
|
|
|
| // Returns a string describing |state|.
|
| -std::string DisplayPowerStateToString(DisplayPowerState state) {
|
| +std::string DisplayPowerStateToString(chromeos::DisplayPowerState state) {
|
| switch (state) {
|
| - case DISPLAY_POWER_ALL_ON:
|
| + case chromeos::DISPLAY_POWER_ALL_ON:
|
| return "ALL_ON";
|
| - case DISPLAY_POWER_ALL_OFF:
|
| + case chromeos::DISPLAY_POWER_ALL_OFF:
|
| return "ALL_OFF";
|
| - case DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON:
|
| + case chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON:
|
| return "INTERNAL_OFF_EXTERNAL_ON";
|
| - case DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF:
|
| + case chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF:
|
| return "INTERNAL_ON_EXTERNAL_OFF";
|
| default:
|
| return "unknown (" + base::IntToString(state) + ")";
|
| @@ -42,17 +42,17 @@ std::string DisplayPowerStateToString(DisplayPowerState state) {
|
| }
|
|
|
| // Returns a string describing |state|.
|
| -std::string OutputStateToString(ui::OutputState state) {
|
| +std::string OutputStateToString(OutputState state) {
|
| switch (state) {
|
| - case ui::OUTPUT_STATE_INVALID:
|
| + case OUTPUT_STATE_INVALID:
|
| return "INVALID";
|
| - case ui::OUTPUT_STATE_HEADLESS:
|
| + case OUTPUT_STATE_HEADLESS:
|
| return "HEADLESS";
|
| - case ui::OUTPUT_STATE_SINGLE:
|
| + case OUTPUT_STATE_SINGLE:
|
| return "SINGLE";
|
| - case ui::OUTPUT_STATE_DUAL_MIRROR:
|
| + case OUTPUT_STATE_DUAL_MIRROR:
|
| return "DUAL_MIRROR";
|
| - case ui::OUTPUT_STATE_DUAL_EXTENDED:
|
| + case OUTPUT_STATE_DUAL_EXTENDED:
|
| return "DUAL_EXTENDED";
|
| }
|
| NOTREACHED() << "Unknown state " << state;
|
| @@ -79,7 +79,6 @@ std::string ModeInfoToString(const OutputConfigurator::ModeInfo* mode) {
|
| mode->height,
|
| mode->interlaced ? "interlaced " : "",
|
| mode->refresh_rate);
|
| -
|
| }
|
|
|
| // Returns the number of outputs in |outputs| that should be turned on, per
|
| @@ -87,17 +86,19 @@ std::string ModeInfoToString(const OutputConfigurator::ModeInfo* mode) {
|
| // on/off state of each corresponding entry in |outputs|.
|
| int GetOutputPower(
|
| const std::vector<OutputConfigurator::OutputSnapshot>& outputs,
|
| - DisplayPowerState state,
|
| + chromeos::DisplayPowerState state,
|
| std::vector<bool>* output_power) {
|
| int num_on_outputs = 0;
|
| if (output_power)
|
| output_power->resize(outputs.size());
|
|
|
| for (size_t i = 0; i < outputs.size(); ++i) {
|
| - bool internal = outputs[i].type == ui::OUTPUT_TYPE_INTERNAL;
|
| - bool on = state == DISPLAY_POWER_ALL_ON ||
|
| - (state == DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON && !internal) ||
|
| - (state == DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF && internal);
|
| + bool internal = outputs[i].type == OUTPUT_TYPE_INTERNAL;
|
| + bool on =
|
| + state == chromeos::DISPLAY_POWER_ALL_ON ||
|
| + (state == chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON &&
|
| + !internal) ||
|
| + (state == chromeos::DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF && internal);
|
| if (output_power)
|
| (*output_power)[i] = on;
|
| if (on)
|
| @@ -141,7 +142,7 @@ OutputConfigurator::OutputSnapshot::OutputSnapshot()
|
| width_mm(0),
|
| height_mm(0),
|
| is_aspect_preserving_scaling(false),
|
| - type(ui::OUTPUT_TYPE_UNKNOWN),
|
| + type(OUTPUT_TYPE_UNKNOWN),
|
| touch_device_id(0),
|
| display_id(0),
|
| has_display_id(false),
|
| @@ -169,8 +170,8 @@ const OutputConfigurator::ModeInfo* OutputConfigurator::GetModeInfo(
|
|
|
| ModeInfoMap::const_iterator it = output.mode_infos.find(mode);
|
| if (it == output.mode_infos.end()) {
|
| - LOG(WARNING) << "Unable to find info about mode " << mode
|
| - << " for output " << output.output;
|
| + LOG(WARNING) << "Unable to find info about mode " << mode << " for output "
|
| + << output.output;
|
| return NULL;
|
| }
|
| return &it->second;
|
| @@ -185,7 +186,8 @@ RRMode OutputConfigurator::FindOutputModeMatchingSize(
|
| float best_rate = 0;
|
| bool non_interlaced_found = false;
|
| for (ModeInfoMap::const_iterator it = output.mode_infos.begin();
|
| - it != output.mode_infos.end(); ++it) {
|
| + it != output.mode_infos.end();
|
| + ++it) {
|
| RRMode mode = it->first;
|
| const ModeInfo& info = it->second;
|
|
|
| @@ -215,8 +217,8 @@ OutputConfigurator::OutputConfigurator()
|
| mirroring_controller_(NULL),
|
| is_panel_fitting_enabled_(false),
|
| configure_display_(base::SysInfo::IsRunningOnChromeOS()),
|
| - output_state_(ui::OUTPUT_STATE_INVALID),
|
| - power_state_(DISPLAY_POWER_ALL_ON),
|
| + output_state_(OUTPUT_STATE_INVALID),
|
| + power_state_(chromeos::DISPLAY_POWER_ALL_ON),
|
| next_output_protection_client_id_(1) {}
|
|
|
| OutputConfigurator::~OutputConfigurator() {
|
| @@ -240,8 +242,9 @@ void OutputConfigurator::SetTouchscreenDelegateForTesting(
|
| touchscreen_delegate_ = delegate.Pass();
|
| }
|
|
|
| -void OutputConfigurator::SetInitialDisplayPower(DisplayPowerState power_state) {
|
| - DCHECK_EQ(output_state_, ui::OUTPUT_STATE_INVALID);
|
| +void OutputConfigurator::SetInitialDisplayPower(
|
| + chromeos::DisplayPowerState power_state) {
|
| + DCHECK_EQ(output_state_, OUTPUT_STATE_INVALID);
|
| power_state_ = power_state;
|
| }
|
|
|
| @@ -269,9 +272,9 @@ void OutputConfigurator::ForceInitialConfigure(uint32 background_color_argb) {
|
| UpdateCachedOutputs();
|
| if (cached_outputs_.size() > 1 && background_color_argb)
|
| native_display_delegate_->SetBackgroundColor(background_color_argb);
|
| - const ui::OutputState new_state = ChooseOutputState(power_state_);
|
| - const bool success = EnterStateOrFallBackToSoftwareMirroring(
|
| - new_state, power_state_);
|
| + const OutputState new_state = ChooseOutputState(power_state_);
|
| + const bool success =
|
| + EnterStateOrFallBackToSoftwareMirroring(new_state, power_state_);
|
|
|
| // Force the DPMS on chrome startup as the driver doesn't always detect
|
| // that all displays are on when signing out.
|
| @@ -282,33 +285,33 @@ void OutputConfigurator::ForceInitialConfigure(uint32 background_color_argb) {
|
|
|
| bool OutputConfigurator::ApplyProtections(const DisplayProtections& requests) {
|
| for (std::vector<OutputSnapshot>::const_iterator it = cached_outputs_.begin();
|
| - it != cached_outputs_.end(); ++it) {
|
| + it != cached_outputs_.end();
|
| + ++it) {
|
| uint32_t all_desired = 0;
|
| - DisplayProtections::const_iterator request_it = requests.find(
|
| - it->display_id);
|
| + DisplayProtections::const_iterator request_it =
|
| + requests.find(it->display_id);
|
| if (request_it != requests.end())
|
| all_desired = request_it->second;
|
| switch (it->type) {
|
| - case ui::OUTPUT_TYPE_UNKNOWN:
|
| + case OUTPUT_TYPE_UNKNOWN:
|
| return false;
|
| // DisplayPort, DVI, and HDMI all support HDCP.
|
| - case ui::OUTPUT_TYPE_DISPLAYPORT:
|
| - case ui::OUTPUT_TYPE_DVI:
|
| - case ui::OUTPUT_TYPE_HDMI: {
|
| - ui::HDCPState new_desired_state =
|
| - (all_desired & ui::OUTPUT_PROTECTION_METHOD_HDCP)
|
| - ? ui::HDCP_STATE_DESIRED
|
| - : ui::HDCP_STATE_UNDESIRED;
|
| + case OUTPUT_TYPE_DISPLAYPORT:
|
| + case OUTPUT_TYPE_DVI:
|
| + case OUTPUT_TYPE_HDMI: {
|
| + HDCPState new_desired_state =
|
| + (all_desired & OUTPUT_PROTECTION_METHOD_HDCP) ?
|
| + HDCP_STATE_DESIRED : HDCP_STATE_UNDESIRED;
|
| if (!native_display_delegate_->SetHDCPState(*it, new_desired_state))
|
| return false;
|
| break;
|
| }
|
| - case ui::OUTPUT_TYPE_INTERNAL:
|
| - case ui::OUTPUT_TYPE_VGA:
|
| - case ui::OUTPUT_TYPE_NETWORK:
|
| + case OUTPUT_TYPE_INTERNAL:
|
| + case OUTPUT_TYPE_VGA:
|
| + case OUTPUT_TYPE_NETWORK:
|
| // No protections for these types. Do nothing.
|
| break;
|
| - case ui::OUTPUT_TYPE_NONE:
|
| + case OUTPUT_TYPE_NONE:
|
| NOTREACHED();
|
| break;
|
| }
|
| @@ -335,7 +338,8 @@ void OutputConfigurator::UnregisterOutputProtectionClient(
|
| it != client_protection_requests_.end();
|
| ++it) {
|
| for (DisplayProtections::const_iterator it2 = it->second.begin();
|
| - it2 != it->second.end(); ++it2) {
|
| + it2 != it->second.end();
|
| + ++it2) {
|
| protections[it2->first] |= it2->second;
|
| }
|
| }
|
| @@ -355,32 +359,33 @@ bool OutputConfigurator::QueryOutputProtectionStatus(
|
| uint32_t unfulfilled = 0;
|
| *link_mask = 0;
|
| for (std::vector<OutputSnapshot>::const_iterator it = cached_outputs_.begin();
|
| - it != cached_outputs_.end(); ++it) {
|
| + it != cached_outputs_.end();
|
| + ++it) {
|
| if (it->display_id != display_id)
|
| continue;
|
| *link_mask |= it->type;
|
| switch (it->type) {
|
| - case ui::OUTPUT_TYPE_UNKNOWN:
|
| + case OUTPUT_TYPE_UNKNOWN:
|
| return false;
|
| // DisplayPort, DVI, and HDMI all support HDCP.
|
| - case ui::OUTPUT_TYPE_DISPLAYPORT:
|
| - case ui::OUTPUT_TYPE_DVI:
|
| - case ui::OUTPUT_TYPE_HDMI: {
|
| - ui::HDCPState state;
|
| + case OUTPUT_TYPE_DISPLAYPORT:
|
| + case OUTPUT_TYPE_DVI:
|
| + case OUTPUT_TYPE_HDMI: {
|
| + HDCPState state;
|
| if (!native_display_delegate_->GetHDCPState(*it, &state))
|
| return false;
|
| - if (state == ui::HDCP_STATE_ENABLED)
|
| - enabled |= ui::OUTPUT_PROTECTION_METHOD_HDCP;
|
| + if (state == HDCP_STATE_ENABLED)
|
| + enabled |= OUTPUT_PROTECTION_METHOD_HDCP;
|
| else
|
| - unfulfilled |= ui::OUTPUT_PROTECTION_METHOD_HDCP;
|
| + unfulfilled |= OUTPUT_PROTECTION_METHOD_HDCP;
|
| break;
|
| }
|
| - case ui::OUTPUT_TYPE_INTERNAL:
|
| - case ui::OUTPUT_TYPE_VGA:
|
| - case ui::OUTPUT_TYPE_NETWORK:
|
| + case OUTPUT_TYPE_INTERNAL:
|
| + case OUTPUT_TYPE_VGA:
|
| + case OUTPUT_TYPE_NETWORK:
|
| // No protections for these types. Do nothing.
|
| break;
|
| - case ui::OUTPUT_TYPE_NONE:
|
| + case OUTPUT_TYPE_NONE:
|
| NOTREACHED();
|
| break;
|
| }
|
| @@ -412,7 +417,8 @@ bool OutputConfigurator::EnableOutputProtection(
|
| it != client_protection_requests_.end();
|
| ++it) {
|
| for (DisplayProtections::const_iterator it2 = it->second.begin();
|
| - it2 != it->second.end(); ++it2) {
|
| + it2 != it->second.end();
|
| + ++it2) {
|
| if (it->first == client_id && it2->first == display_id)
|
| continue;
|
| protections[it2->first] |= it2->second;
|
| @@ -423,7 +429,7 @@ bool OutputConfigurator::EnableOutputProtection(
|
| if (!ApplyProtections(protections))
|
| return false;
|
|
|
| - if (desired_method_mask == ui::OUTPUT_PROTECTION_METHOD_NONE) {
|
| + if (desired_method_mask == OUTPUT_PROTECTION_METHOD_NONE) {
|
| if (client_protection_requests_.find(client_id) !=
|
| client_protection_requests_.end()) {
|
| client_protection_requests_[client_id].erase(display_id);
|
| @@ -441,8 +447,9 @@ void OutputConfigurator::PrepareForExit() {
|
| configure_display_ = false;
|
| }
|
|
|
| -bool OutputConfigurator::SetDisplayPower(DisplayPowerState power_state,
|
| - int flags) {
|
| +bool OutputConfigurator::SetDisplayPower(
|
| + chromeos::DisplayPowerState power_state,
|
| + int flags) {
|
| if (!configure_display_)
|
| return false;
|
|
|
| @@ -450,14 +457,14 @@ bool OutputConfigurator::SetDisplayPower(DisplayPowerState power_state,
|
| << DisplayPowerStateToString(power_state) << " flags=" << flags
|
| << ", configure timer="
|
| << ((configure_timer_.get() && configure_timer_->IsRunning()) ?
|
| - "Running" : "Stopped");
|
| + "Running" : "Stopped");
|
| if (power_state == power_state_ && !(flags & kSetDisplayPowerForceProbe))
|
| return true;
|
|
|
| native_display_delegate_->GrabServer();
|
| UpdateCachedOutputs();
|
|
|
| - const ui::OutputState new_state = ChooseOutputState(power_state);
|
| + const OutputState new_state = ChooseOutputState(power_state);
|
| bool attempted_change = false;
|
| bool success = false;
|
|
|
| @@ -465,14 +472,14 @@ bool OutputConfigurator::SetDisplayPower(DisplayPowerState power_state,
|
| flags & kSetDisplayPowerOnlyIfSingleInternalDisplay;
|
| bool single_internal_display =
|
| cached_outputs_.size() == 1 &&
|
| - cached_outputs_[0].type == ui::OUTPUT_TYPE_INTERNAL;
|
| + cached_outputs_[0].type == OUTPUT_TYPE_INTERNAL;
|
| if (single_internal_display || !only_if_single_internal_display) {
|
| success = EnterStateOrFallBackToSoftwareMirroring(new_state, power_state);
|
| attempted_change = true;
|
|
|
| // Force the DPMS on since the driver doesn't always detect that it
|
| // should turn on. This is needed when coming back from idle suspend.
|
| - if (success && power_state != DISPLAY_POWER_ALL_OFF)
|
| + if (success && power_state != chromeos::DISPLAY_POWER_ALL_OFF)
|
| native_display_delegate_->ForceDPMSOn();
|
| }
|
|
|
| @@ -482,7 +489,7 @@ bool OutputConfigurator::SetDisplayPower(DisplayPowerState power_state,
|
| return true;
|
| }
|
|
|
| -bool OutputConfigurator::SetDisplayMode(ui::OutputState new_state) {
|
| +bool OutputConfigurator::SetDisplayMode(OutputState new_state) {
|
| if (!configure_display_)
|
| return false;
|
|
|
| @@ -490,7 +497,7 @@ bool OutputConfigurator::SetDisplayMode(ui::OutputState new_state) {
|
| if (output_state_ == new_state) {
|
| // Cancel software mirroring if the state is moving from
|
| // OUTPUT_STATE_DUAL_EXTENDED to OUTPUT_STATE_DUAL_EXTENDED.
|
| - if (mirroring_controller_ && new_state == ui::OUTPUT_STATE_DUAL_EXTENDED)
|
| + if (mirroring_controller_ && new_state == OUTPUT_STATE_DUAL_EXTENDED)
|
| mirroring_controller_->SetSoftwareMirroring(false);
|
| NotifyObservers(true, new_state);
|
| return true;
|
| @@ -498,8 +505,8 @@ bool OutputConfigurator::SetDisplayMode(ui::OutputState new_state) {
|
|
|
| native_display_delegate_->GrabServer();
|
| UpdateCachedOutputs();
|
| - const bool success = EnterStateOrFallBackToSoftwareMirroring(
|
| - new_state, power_state_);
|
| + const bool success =
|
| + EnterStateOrFallBackToSoftwareMirroring(new_state, power_state_);
|
| native_display_delegate_->UngrabServer();
|
|
|
| NotifyObservers(success, new_state);
|
| @@ -535,8 +542,8 @@ void OutputConfigurator::SuspendDisplays() {
|
| // suspending. This shouldn't be very noticeable to the user since the
|
| // backlight is off at this point, and doing this lets us resume directly
|
| // into the "on" state, which greatly reduces resume times.
|
| - if (power_state_ == DISPLAY_POWER_ALL_OFF) {
|
| - SetDisplayPower(DISPLAY_POWER_ALL_ON,
|
| + if (power_state_ == chromeos::DISPLAY_POWER_ALL_OFF) {
|
| + SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
|
| kSetDisplayPowerOnlyIfSingleInternalDisplay);
|
|
|
| // We need to make sure that the monitor configuration we just did actually
|
| @@ -561,9 +568,8 @@ void OutputConfigurator::UpdateCachedOutputs() {
|
| OutputSnapshot* output = &cached_outputs_[i];
|
| if (output->has_display_id) {
|
| int width = 0, height = 0;
|
| - if (state_controller_ &&
|
| - state_controller_->GetResolutionForDisplayId(
|
| - output->display_id, &width, &height)) {
|
| + if (state_controller_ && state_controller_->GetResolutionForDisplayId(
|
| + output->display_id, &width, &height)) {
|
| output->selected_mode =
|
| FindOutputModeMatchingSize(*output, width, height);
|
| }
|
| @@ -575,13 +581,12 @@ void OutputConfigurator::UpdateCachedOutputs() {
|
|
|
| // Set |mirror_mode| fields.
|
| if (cached_outputs_.size() == 2) {
|
| - bool one_is_internal = cached_outputs_[0].type == ui::OUTPUT_TYPE_INTERNAL;
|
| - bool two_is_internal = cached_outputs_[1].type == ui::OUTPUT_TYPE_INTERNAL;
|
| - int internal_outputs = (one_is_internal ? 1 : 0) +
|
| - (two_is_internal ? 1 : 0);
|
| + bool one_is_internal = cached_outputs_[0].type == OUTPUT_TYPE_INTERNAL;
|
| + bool two_is_internal = cached_outputs_[1].type == OUTPUT_TYPE_INTERNAL;
|
| + int internal_outputs =
|
| + (one_is_internal ? 1 : 0) + (two_is_internal ? 1 : 0);
|
| DCHECK_LT(internal_outputs, 2);
|
| - LOG_IF(WARNING, internal_outputs == 2)
|
| - << "Two internal outputs detected.";
|
| + LOG_IF(WARNING, internal_outputs == 2) << "Two internal outputs detected.";
|
|
|
| bool can_mirror = false;
|
| for (int attempt = 0; !can_mirror && attempt < 2; ++attempt) {
|
| @@ -591,24 +596,28 @@ void OutputConfigurator::UpdateCachedOutputs() {
|
|
|
| if (internal_outputs == 1) {
|
| if (one_is_internal) {
|
| - can_mirror = FindMirrorMode(&cached_outputs_[0], &cached_outputs_[1],
|
| - is_panel_fitting_enabled_, preserve_aspect);
|
| + can_mirror = FindMirrorMode(&cached_outputs_[0],
|
| + &cached_outputs_[1],
|
| + is_panel_fitting_enabled_,
|
| + preserve_aspect);
|
| } else {
|
| DCHECK(two_is_internal);
|
| - can_mirror = FindMirrorMode(&cached_outputs_[1], &cached_outputs_[0],
|
| - is_panel_fitting_enabled_, preserve_aspect);
|
| + can_mirror = FindMirrorMode(&cached_outputs_[1],
|
| + &cached_outputs_[0],
|
| + is_panel_fitting_enabled_,
|
| + preserve_aspect);
|
| }
|
| } else { // if (internal_outputs == 0)
|
| // No panel fitting for external outputs, so fall back to exact match.
|
| - can_mirror = FindMirrorMode(&cached_outputs_[0], &cached_outputs_[1],
|
| - false, preserve_aspect);
|
| + can_mirror = FindMirrorMode(
|
| + &cached_outputs_[0], &cached_outputs_[1], false, preserve_aspect);
|
| if (!can_mirror && preserve_aspect) {
|
| // FindMirrorMode() will try to preserve aspect ratio of what it
|
| // thinks is external display, so if it didn't succeed with one, maybe
|
| // it will succeed with the other. This way we will have the correct
|
| // aspect ratio on at least one of them.
|
| - can_mirror = FindMirrorMode(&cached_outputs_[1], &cached_outputs_[0],
|
| - false, preserve_aspect);
|
| + can_mirror = FindMirrorMode(
|
| + &cached_outputs_[1], &cached_outputs_[0], false, preserve_aspect);
|
| }
|
| }
|
| }
|
| @@ -630,8 +639,9 @@ bool OutputConfigurator::FindMirrorMode(OutputSnapshot* internal_output,
|
| // Prefer the modes in the order that X sorts them, assuming this is the order
|
| // in which they look better on the monitor.
|
| for (ModeInfoMap::const_iterator external_it =
|
| - external_output->mode_infos.begin();
|
| - external_it != external_output->mode_infos.end(); ++external_it) {
|
| + external_output->mode_infos.begin();
|
| + external_it != external_output->mode_infos.end();
|
| + ++external_it) {
|
| const ModeInfo& external_info = external_it->second;
|
| bool is_native_aspect_ratio =
|
| external_native_info->width * external_info.height ==
|
| @@ -641,8 +651,9 @@ bool OutputConfigurator::FindMirrorMode(OutputSnapshot* internal_output,
|
|
|
| // Try finding an exact match.
|
| for (ModeInfoMap::const_iterator internal_it =
|
| - internal_output->mode_infos.begin();
|
| - internal_it != internal_output->mode_infos.end(); ++internal_it) {
|
| + internal_output->mode_infos.begin();
|
| + internal_it != internal_output->mode_infos.end();
|
| + ++internal_it) {
|
| const ModeInfo& internal_info = internal_it->second;
|
| if (internal_info.width == external_info.width &&
|
| internal_info.height == external_info.height &&
|
| @@ -658,10 +669,9 @@ bool OutputConfigurator::FindMirrorMode(OutputSnapshot* internal_output,
|
| // We can downscale by 1.125, and upscale indefinitely. Downscaling looks
|
| // ugly, so, can fit == can upscale. Also, internal panels don't support
|
| // fitting interlaced modes.
|
| - bool can_fit =
|
| - internal_native_info->width >= external_info.width &&
|
| - internal_native_info->height >= external_info.height &&
|
| - !external_info.interlaced;
|
| + bool can_fit = internal_native_info->width >= external_info.width &&
|
| + internal_native_info->height >= external_info.height &&
|
| + !external_info.interlaced;
|
| if (can_fit) {
|
| RRMode mode = external_it->first;
|
| native_display_delegate_->AddMode(*internal_output, mode);
|
| @@ -684,48 +694,48 @@ void OutputConfigurator::ConfigureOutputs() {
|
|
|
| native_display_delegate_->GrabServer();
|
| UpdateCachedOutputs();
|
| - const ui::OutputState new_state = ChooseOutputState(power_state_);
|
| - const bool success = EnterStateOrFallBackToSoftwareMirroring(
|
| - new_state, power_state_);
|
| + const OutputState new_state = ChooseOutputState(power_state_);
|
| + const bool success =
|
| + EnterStateOrFallBackToSoftwareMirroring(new_state, power_state_);
|
| native_display_delegate_->UngrabServer();
|
|
|
| NotifyObservers(success, new_state);
|
| }
|
|
|
| void OutputConfigurator::NotifyObservers(bool success,
|
| - ui::OutputState attempted_state) {
|
| + OutputState attempted_state) {
|
| if (success) {
|
| - FOR_EACH_OBSERVER(Observer, observers_,
|
| - OnDisplayModeChanged(cached_outputs_));
|
| + FOR_EACH_OBSERVER(
|
| + Observer, observers_, OnDisplayModeChanged(cached_outputs_));
|
| } else {
|
| - FOR_EACH_OBSERVER(Observer, observers_,
|
| - OnDisplayModeChangeFailed(attempted_state));
|
| + FOR_EACH_OBSERVER(
|
| + Observer, observers_, OnDisplayModeChangeFailed(attempted_state));
|
| }
|
| }
|
|
|
| bool OutputConfigurator::EnterStateOrFallBackToSoftwareMirroring(
|
| - ui::OutputState output_state,
|
| - DisplayPowerState power_state) {
|
| + OutputState output_state,
|
| + chromeos::DisplayPowerState power_state) {
|
| bool success = EnterState(output_state, power_state);
|
| if (mirroring_controller_) {
|
| bool enable_software_mirroring = false;
|
| - if (!success && output_state == ui::OUTPUT_STATE_DUAL_MIRROR) {
|
| - if (output_state_ != ui::OUTPUT_STATE_DUAL_EXTENDED ||
|
| + if (!success && output_state == OUTPUT_STATE_DUAL_MIRROR) {
|
| + if (output_state_ != OUTPUT_STATE_DUAL_EXTENDED ||
|
| power_state_ != power_state)
|
| - EnterState(ui::OUTPUT_STATE_DUAL_EXTENDED, power_state);
|
| + EnterState(OUTPUT_STATE_DUAL_EXTENDED, power_state);
|
| enable_software_mirroring = success =
|
| - output_state_ == ui::OUTPUT_STATE_DUAL_EXTENDED;
|
| + output_state_ == OUTPUT_STATE_DUAL_EXTENDED;
|
| }
|
| mirroring_controller_->SetSoftwareMirroring(enable_software_mirroring);
|
| }
|
| return success;
|
| }
|
|
|
| -bool OutputConfigurator::EnterState(ui::OutputState output_state,
|
| - DisplayPowerState power_state) {
|
| +bool OutputConfigurator::EnterState(OutputState output_state,
|
| + chromeos::DisplayPowerState power_state) {
|
| std::vector<bool> output_power;
|
| - int num_on_outputs = GetOutputPower(
|
| - cached_outputs_, power_state, &output_power);
|
| + int num_on_outputs =
|
| + GetOutputPower(cached_outputs_, power_state, &output_power);
|
| VLOG(1) << "EnterState: output=" << OutputStateToString(output_state)
|
| << " power=" << DisplayPowerStateToString(power_state);
|
|
|
| @@ -734,18 +744,18 @@ bool OutputConfigurator::EnterState(ui::OutputState output_state,
|
| std::vector<OutputSnapshot> updated_outputs = cached_outputs_;
|
|
|
| switch (output_state) {
|
| - case ui::OUTPUT_STATE_INVALID:
|
| + case OUTPUT_STATE_INVALID:
|
| NOTREACHED() << "Ignoring request to enter invalid state with "
|
| << updated_outputs.size() << " connected output(s)";
|
| return false;
|
| - case ui::OUTPUT_STATE_HEADLESS:
|
| + case OUTPUT_STATE_HEADLESS:
|
| if (updated_outputs.size() != 0) {
|
| LOG(WARNING) << "Ignoring request to enter headless mode with "
|
| << updated_outputs.size() << " connected output(s)";
|
| return false;
|
| }
|
| break;
|
| - case ui::OUTPUT_STATE_SINGLE: {
|
| + case OUTPUT_STATE_SINGLE: {
|
| // If there are multiple outputs connected, only one should be turned on.
|
| if (updated_outputs.size() != 1 && num_on_outputs != 1) {
|
| LOG(WARNING) << "Ignoring request to enter single mode with "
|
| @@ -780,7 +790,7 @@ bool OutputConfigurator::EnterState(ui::OutputState output_state,
|
| }
|
| break;
|
| }
|
| - case ui::OUTPUT_STATE_DUAL_MIRROR: {
|
| + case OUTPUT_STATE_DUAL_MIRROR: {
|
| if (updated_outputs.size() != 2 ||
|
| (num_on_outputs != 0 && num_on_outputs != 2)) {
|
| LOG(WARNING) << "Ignoring request to enter mirrored mode with "
|
| @@ -816,7 +826,7 @@ bool OutputConfigurator::EnterState(ui::OutputState output_state,
|
| }
|
| break;
|
| }
|
| - case ui::OUTPUT_STATE_DUAL_EXTENDED: {
|
| + case OUTPUT_STATE_DUAL_EXTENDED: {
|
| if (updated_outputs.size() != 2 ||
|
| (num_on_outputs != 0 && num_on_outputs != 2)) {
|
| LOG(WARNING) << "Ignoring request to enter extended mode with "
|
| @@ -858,21 +868,18 @@ bool OutputConfigurator::EnterState(ui::OutputState output_state,
|
| native_display_delegate_->CreateFrameBuffer(width, height, updated_outputs);
|
| for (size_t i = 0; i < updated_outputs.size(); ++i) {
|
| const OutputSnapshot& output = updated_outputs[i];
|
| - bool configure_succeeded =false;
|
| + bool configure_succeeded = false;
|
|
|
| while (true) {
|
| - if (native_display_delegate_->Configure(output,
|
| - output.current_mode,
|
| - output.x,
|
| - output.y)) {
|
| + if (native_display_delegate_->Configure(
|
| + output, output.current_mode, output.x, output.y)) {
|
| configure_succeeded = true;
|
| break;
|
| }
|
|
|
| LOG(WARNING) << "Unable to configure CRTC " << output.crtc << ":"
|
| << " mode=" << output.current_mode
|
| - << " output=" << output.output
|
| - << " x=" << output.x
|
| + << " output=" << output.output << " x=" << output.x
|
| << " y=" << output.y;
|
|
|
| const ModeInfo* mode_info = GetModeInfo(output, output.current_mode);
|
| @@ -885,7 +892,8 @@ bool OutputConfigurator::EnterState(ui::OutputState output_state,
|
|
|
| int current_mode_pixels = mode_info->width * mode_info->height;
|
| for (ModeInfoMap::const_iterator it = output.mode_infos.begin();
|
| - it != output.mode_infos.end(); it++) {
|
| + it != output.mode_infos.end();
|
| + it++) {
|
| int pixel_count = it->second.width * it->second.height;
|
| if ((pixel_count < current_mode_pixels) &&
|
| (pixel_count > best_mode_pixels)) {
|
| @@ -910,33 +918,32 @@ bool OutputConfigurator::EnterState(ui::OutputState output_state,
|
| // If we are trying to set mirror mode and one of the modesets fails,
|
| // then the two monitors will be mis-matched. In this case, return
|
| // false to let the observers be aware.
|
| - if (output_state == ui::OUTPUT_STATE_DUAL_MIRROR && output_power[i] &&
|
| + if (output_state == OUTPUT_STATE_DUAL_MIRROR && output_power[i] &&
|
| output.current_mode != output.mirror_mode)
|
| all_succeeded = false;
|
| -
|
| }
|
| }
|
|
|
| - if (all_succeeded) {
|
| + if (all_succeeded) {
|
| output_state_ = output_state;
|
| power_state_ = power_state;
|
| }
|
| return all_succeeded;
|
| }
|
|
|
| -ui::OutputState OutputConfigurator::ChooseOutputState(
|
| - DisplayPowerState power_state) const {
|
| +OutputState OutputConfigurator::ChooseOutputState(
|
| + chromeos::DisplayPowerState power_state) const {
|
| int num_on_outputs = GetOutputPower(cached_outputs_, power_state, NULL);
|
| switch (cached_outputs_.size()) {
|
| case 0:
|
| - return ui::OUTPUT_STATE_HEADLESS;
|
| + return OUTPUT_STATE_HEADLESS;
|
| case 1:
|
| - return ui::OUTPUT_STATE_SINGLE;
|
| + return OUTPUT_STATE_SINGLE;
|
| case 2: {
|
| if (num_on_outputs == 1) {
|
| // If only one output is currently turned on, return the "single"
|
| // state so that its native mode will be used.
|
| - return ui::OUTPUT_STATE_SINGLE;
|
| + return OUTPUT_STATE_SINGLE;
|
| } else {
|
| // With either both outputs on or both outputs off, use one of the
|
| // dual modes.
|
| @@ -944,7 +951,7 @@ ui::OutputState OutputConfigurator::ChooseOutputState(
|
| for (size_t i = 0; i < cached_outputs_.size(); ++i) {
|
| // If display id isn't available, switch to extended mode.
|
| if (!cached_outputs_[i].has_display_id)
|
| - return ui::OUTPUT_STATE_DUAL_EXTENDED;
|
| + return OUTPUT_STATE_DUAL_EXTENDED;
|
| display_ids.push_back(cached_outputs_[i].display_id);
|
| }
|
| return state_controller_->GetStateForDisplayIds(display_ids);
|
| @@ -953,7 +960,7 @@ ui::OutputState OutputConfigurator::ChooseOutputState(
|
| default:
|
| NOTREACHED();
|
| }
|
| - return ui::OUTPUT_STATE_INVALID;
|
| + return OUTPUT_STATE_INVALID;
|
| }
|
|
|
| OutputConfigurator::CoordinateTransformation
|
| @@ -963,15 +970,15 @@ OutputConfigurator::GetMirrorModeCTM(
|
| const ModeInfo* native_mode_info = GetModeInfo(output, output.native_mode);
|
| const ModeInfo* mirror_mode_info = GetModeInfo(output, output.mirror_mode);
|
|
|
| - if (!native_mode_info || !mirror_mode_info ||
|
| - native_mode_info->height == 0 || mirror_mode_info->height == 0 ||
|
| - native_mode_info->width == 0 || mirror_mode_info->width == 0)
|
| + if (!native_mode_info || !mirror_mode_info || native_mode_info->height == 0 ||
|
| + mirror_mode_info->height == 0 || native_mode_info->width == 0 ||
|
| + mirror_mode_info->width == 0)
|
| return ctm;
|
|
|
| float native_mode_ar = static_cast<float>(native_mode_info->width) /
|
| - static_cast<float>(native_mode_info->height);
|
| + static_cast<float>(native_mode_info->height);
|
| float mirror_mode_ar = static_cast<float>(mirror_mode_info->width) /
|
| - static_cast<float>(mirror_mode_info->height);
|
| + static_cast<float>(mirror_mode_info->height);
|
|
|
| if (mirror_mode_ar > native_mode_ar) { // Letterboxing
|
| ctm.x_scale = 1.0;
|
| @@ -1036,18 +1043,18 @@ float OutputConfigurator::GetMirroredDisplayAreaRatio(
|
| const ModeInfo* native_mode_info = GetModeInfo(output, output.native_mode);
|
| const ModeInfo* mirror_mode_info = GetModeInfo(output, output.mirror_mode);
|
|
|
| - if (!native_mode_info || !mirror_mode_info ||
|
| - native_mode_info->height == 0 || mirror_mode_info->height == 0 ||
|
| - native_mode_info->width == 0 || mirror_mode_info->width == 0)
|
| + if (!native_mode_info || !mirror_mode_info || native_mode_info->height == 0 ||
|
| + mirror_mode_info->height == 0 || native_mode_info->width == 0 ||
|
| + mirror_mode_info->width == 0)
|
| return area_ratio;
|
|
|
| float width_ratio = static_cast<float>(mirror_mode_info->width) /
|
| - static_cast<float>(native_mode_info->width);
|
| + static_cast<float>(native_mode_info->width);
|
| float height_ratio = static_cast<float>(mirror_mode_info->height) /
|
| - static_cast<float>(native_mode_info->height);
|
| + static_cast<float>(native_mode_info->height);
|
|
|
| area_ratio = width_ratio * height_ratio;
|
| return area_ratio;
|
| }
|
|
|
| -} // namespace chromeos
|
| +} // namespace ui
|
|
|