From bcec7fb666c9742f77462d276c65ffdc46e79780 Mon Sep 17 00:00:00 2001 From: "dnicoara@chromium.org" Date: Tue, 8 Apr 2014 20:59:09 +0000 Subject: [PATCH] Renaming ui/display constants and variables from OUTPUT_* to DISPLAY_* This moves all display configuration to using one terminology when referring to displays. BUG=333413 Review URL: https://codereview.chromium.org/227833002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262503 0039d316-1c4b-4281-b951-d872f2087c98 --- .../shell/browser/shell_desktop_controller.cc | 2 +- .../display_change_observer_chromeos.cc | 42 +- .../display_change_observer_chromeos.h | 2 +- .../display_error_observer_chromeos.cc | 4 +- ash/display/display_error_observer_chromeos.h | 4 +- ...isplay_error_observer_chromeos_unittest.cc | 11 +- ash/display/display_manager.cc | 5 +- ash/display/event_transformation_handler.cc | 3 +- ash/display/output_configurator_animation.cc | 2 +- ash/display/output_configurator_animation.h | 4 +- ash/display/projecting_observer_chromeos.cc | 9 +- .../projecting_observer_chromeos_unittest.cc | 4 +- ash/shell.cc | 2 +- ash/wm/lock_state_controller_unittest.cc | 4 +- ash/wm/power_button_controller.cc | 12 +- ...pepper_output_protection_message_filter.cc | 46 +- ui/display/chromeos/display_configurator.cc | 503 +++++++++--------- ui/display/chromeos/display_configurator.h | 165 +++--- .../chromeos/display_configurator_unittest.cc | 206 +++---- ui/display/chromeos/display_snapshot.cc | 2 +- ui/display/chromeos/display_snapshot.h | 8 +- ui/display/chromeos/native_display_delegate.h | 2 +- .../ozone/native_display_delegate_ozone.cc | 2 +- .../ozone/native_display_delegate_ozone.h | 2 +- .../chromeos/test/test_display_snapshot.cc | 4 +- .../chromeos/test/test_display_snapshot.h | 4 +- .../chromeos/x11/display_snapshot_x11.cc | 2 +- .../chromeos/x11/display_snapshot_x11.h | 2 +- ui/display/chromeos/x11/display_util_x11.cc | 32 +- ui/display/chromeos/x11/display_util_x11.h | 7 +- .../chromeos/x11/display_util_x11_unittest.cc | 77 ++- .../x11/native_display_delegate_x11.cc | 12 +- .../x11/native_display_delegate_x11.h | 4 +- .../native_display_event_dispatcher_x11.cc | 2 +- ...e_display_event_dispatcher_x11_unittest.cc | 6 +- .../chromeos/x11/touchscreen_delegate_x11.cc | 2 +- ui/display/display_constants.h | 36 +- 37 files changed, 646 insertions(+), 590 deletions(-) diff --git a/apps/shell/browser/shell_desktop_controller.cc b/apps/shell/browser/shell_desktop_controller.cc index 799d52db2488ea..fec9911add3cbb 100644 --- a/apps/shell/browser/shell_desktop_controller.cc +++ b/apps/shell/browser/shell_desktop_controller.cc @@ -144,7 +144,7 @@ void ShellDesktopController::DestroyRootWindow() { gfx::Size ShellDesktopController::GetPrimaryDisplaySize() { #if defined(OS_CHROMEOS) const std::vector& states = - display_configurator_->cached_outputs(); + display_configurator_->cached_displays(); if (states.empty()) return gfx::Size(); const ui::DisplayMode* mode = states[0].display->current_mode(); diff --git a/ash/display/display_change_observer_chromeos.cc b/ash/display/display_change_observer_chromeos.cc index 259232db377ee6..cfc23017e3d912 100644 --- a/ash/display/display_change_observer_chromeos.cc +++ b/ash/display/display_change_observer_chromeos.cc @@ -96,14 +96,14 @@ DisplayChangeObserver::~DisplayChangeObserver() { Shell::GetInstance()->RemoveShellObserver(this); } -ui::OutputState DisplayChangeObserver::GetStateForDisplayIds( +ui::MultipleDisplayState DisplayChangeObserver::GetStateForDisplayIds( const std::vector& display_ids) const { CHECK_EQ(2U, display_ids.size()); DisplayIdPair pair = std::make_pair(display_ids[0], display_ids[1]); DisplayLayout layout = Shell::GetInstance()->display_manager()-> layout_store()->GetRegisteredDisplayLayout(pair); - return layout.mirrored ? ui::OUTPUT_STATE_DUAL_MIRROR : - ui::OUTPUT_STATE_DUAL_EXTENDED; + return layout.mirrored ? ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR : + ui::MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED; } bool DisplayChangeObserver::GetResolutionForDisplayId(int64 display_id, @@ -118,40 +118,40 @@ bool DisplayChangeObserver::GetResolutionForDisplayId(int64 display_id, } void DisplayChangeObserver::OnDisplayModeChanged( - const std::vector& outputs) { + const std::vector& display_states) { std::vector displays; std::set ids; - for (size_t i = 0; i < outputs.size(); ++i) { - const DisplayConfigurator::DisplayState& output = outputs[i]; + for (size_t i = 0; i < display_states.size(); ++i) { + const DisplayConfigurator::DisplayState& state = display_states[i]; - if (output.display->type() == ui::OUTPUT_TYPE_INTERNAL && + if (state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL && gfx::Display::InternalDisplayId() == gfx::Display::kInvalidDisplayID) { - gfx::Display::SetInternalDisplayId(output.display->display_id()); + gfx::Display::SetInternalDisplayId(state.display->display_id()); } - const ui::DisplayMode* mode_info = output.display->current_mode(); + const ui::DisplayMode* mode_info = state.display->current_mode(); if (!mode_info) continue; float device_scale_factor = 1.0f; - if (!ui::IsDisplaySizeBlackListed(output.display->physical_size()) && + if (!ui::IsDisplaySizeBlackListed(state.display->physical_size()) && (kInchInMm * mode_info->size().width() / - output.display->physical_size().width()) > kHighDensityDPIThreshold) { + state.display->physical_size().width()) > kHighDensityDPIThreshold) { device_scale_factor = 2.0f; } - gfx::Rect display_bounds(output.display->origin(), mode_info->size()); + gfx::Rect display_bounds(state.display->origin(), mode_info->size()); - std::vector display_modes = GetDisplayModeList(output); + std::vector display_modes = GetDisplayModeList(state); std::string name = - output.display->type() == ui::OUTPUT_TYPE_INTERNAL - ? l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME) : - output.display->display_name(); + state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL ? + l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME) : + state.display->display_name(); if (name.empty()) name = l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); - bool has_overscan = output.display->has_overscan(); - int64 id = output.display->display_id(); + bool has_overscan = state.display->has_overscan(); + int64 id = state.display->display_id(); ids.insert(id); displays.push_back(DisplayInfo(id, name, has_overscan)); @@ -160,9 +160,9 @@ void DisplayChangeObserver::OnDisplayModeChanged( new_info.SetBounds(display_bounds); new_info.set_native(true); new_info.set_display_modes(display_modes); - new_info.set_touch_support( - output.touch_device_id == 0 ? gfx::Display::TOUCH_SUPPORT_UNAVAILABLE : - gfx::Display::TOUCH_SUPPORT_AVAILABLE); + new_info.set_touch_support(state.touch_device_id == 0 ? + gfx::Display::TOUCH_SUPPORT_UNAVAILABLE : + gfx::Display::TOUCH_SUPPORT_AVAILABLE); new_info.set_available_color_profiles( Shell::GetInstance() ->display_configurator() diff --git a/ash/display/display_change_observer_chromeos.h b/ash/display/display_change_observer_chromeos.h index 707c37f01c993f..1e6521ff7816bf 100644 --- a/ash/display/display_change_observer_chromeos.h +++ b/ash/display/display_change_observer_chromeos.h @@ -28,7 +28,7 @@ class DisplayChangeObserver : public ui::DisplayConfigurator::StateController, virtual ~DisplayChangeObserver(); // ui::DisplayConfigurator::StateController overrides: - virtual ui::OutputState GetStateForDisplayIds( + virtual ui::MultipleDisplayState GetStateForDisplayIds( const std::vector& outputs) const OVERRIDE; virtual bool GetResolutionForDisplayId(int64 display_id, gfx::Size* size) const OVERRIDE; diff --git a/ash/display/display_error_observer_chromeos.cc b/ash/display/display_error_observer_chromeos.cc index 72b76398d35509..145bbc0e2628d3 100644 --- a/ash/display/display_error_observer_chromeos.cc +++ b/ash/display/display_error_observer_chromeos.cc @@ -30,13 +30,13 @@ DisplayErrorObserver::~DisplayErrorObserver() { } void DisplayErrorObserver::OnDisplayModeChangeFailed( - ui::OutputState new_state) { + ui::MultipleDisplayState new_state) { // Always remove the notification to make sure the notification appears // as a popup in any situation. message_center::MessageCenter::Get()->RemoveNotification( kDisplayErrorNotificationId, false /* by_user */); - int message_id = (new_state == ui::OUTPUT_STATE_DUAL_MIRROR) ? + int message_id = (new_state == ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) ? IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING : IDS_ASH_DISPLAY_FAILURE_ON_NON_MIRRORING; diff --git a/ash/display/display_error_observer_chromeos.h b/ash/display/display_error_observer_chromeos.h index d49060b7642c31..58de819e041dc2 100644 --- a/ash/display/display_error_observer_chromeos.h +++ b/ash/display/display_error_observer_chromeos.h @@ -21,8 +21,8 @@ class ASH_EXPORT DisplayErrorObserver virtual ~DisplayErrorObserver(); // ui::DisplayConfigurator::Observer overrides: - virtual void OnDisplayModeChangeFailed(ui::OutputState failed_new_state) - OVERRIDE; + virtual void OnDisplayModeChangeFailed( + ui::MultipleDisplayState failed_new_state) OVERRIDE; private: friend class DisplayErrorObserverTest; diff --git a/ash/display/display_error_observer_chromeos_unittest.cc b/ash/display/display_error_observer_chromeos_unittest.cc index b43dd21a066680..a1436f0bf96b81 100644 --- a/ash/display/display_error_observer_chromeos_unittest.cc +++ b/ash/display/display_error_observer_chromeos_unittest.cc @@ -46,7 +46,7 @@ TEST_F(DisplayErrorObserverTest, Normal) { return; UpdateDisplay("200x200,300x300"); - observer()->OnDisplayModeChangeFailed(ui::OUTPUT_STATE_DUAL_MIRROR); + observer()->OnDisplayModeChangeFailed(ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING), GetMessageContents()); } @@ -56,11 +56,11 @@ TEST_F(DisplayErrorObserverTest, CallTwice) { return; UpdateDisplay("200x200,300x300"); - observer()->OnDisplayModeChangeFailed(ui::OUTPUT_STATE_DUAL_MIRROR); + observer()->OnDisplayModeChangeFailed(ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); base::string16 message = GetMessageContents(); EXPECT_FALSE(message.empty()); - observer()->OnDisplayModeChangeFailed(ui::OUTPUT_STATE_DUAL_MIRROR); + observer()->OnDisplayModeChangeFailed(ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); base::string16 message2 = GetMessageContents(); EXPECT_FALSE(message2.empty()); EXPECT_EQ(message, message2); @@ -71,11 +71,12 @@ TEST_F(DisplayErrorObserverTest, CallWithDifferentState) { return; UpdateDisplay("200x200,300x300"); - observer()->OnDisplayModeChangeFailed(ui::OUTPUT_STATE_DUAL_MIRROR); + observer()->OnDisplayModeChangeFailed(ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING), GetMessageContents()); - observer()->OnDisplayModeChangeFailed(ui::OUTPUT_STATE_DUAL_EXTENDED); + observer()->OnDisplayModeChangeFailed( + ui::MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_NON_MIRRORING), GetMessageContents()); } diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc index 37eb0ee5dae0b6..32e0dea5d47004 100644 --- a/ash/display/display_manager.cc +++ b/ash/display/display_manager.cc @@ -864,8 +864,9 @@ void DisplayManager::SetMirrorMode(bool mirrored) { #if defined(OS_CHROMEOS) if (base::SysInfo::IsRunningOnChromeOS()) { - ui::OutputState new_state = mirrored ? ui::OUTPUT_STATE_DUAL_MIRROR : - ui::OUTPUT_STATE_DUAL_EXTENDED; + ui::MultipleDisplayState new_state = + mirrored ? ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR : + ui::MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED; Shell::GetInstance()->display_configurator()->SetDisplayMode(new_state); return; } diff --git a/ash/display/event_transformation_handler.cc b/ash/display/event_transformation_handler.cc index 4591a7ca817064..ef545fc1d2142e 100644 --- a/ash/display/event_transformation_handler.cc +++ b/ash/display/event_transformation_handler.cc @@ -66,7 +66,8 @@ void EventTransformationHandler::OnTouchEvent(ui::TouchEvent* event) { // Check display_configurator's output_state instead of checking // DisplayManager::IsMirrored() because the compositor based mirroring // won't cause the scaling issue. - if (display_configurator->output_state() != ui::OUTPUT_STATE_DUAL_MIRROR) + if (display_configurator->display_state() != + ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) return; const std::map& area_ratio_map = diff --git a/ash/display/output_configurator_animation.cc b/ash/display/output_configurator_animation.cc index 1a090185562f9f..f2aa2524cbad06 100644 --- a/ash/display/output_configurator_animation.cc +++ b/ash/display/output_configurator_animation.cc @@ -209,7 +209,7 @@ void OutputConfiguratorAnimation::OnDisplayModeChanged( } void OutputConfiguratorAnimation::OnDisplayModeChangeFailed( - ui::OutputState failed_new_state) { + ui::MultipleDisplayState failed_new_state) { if (!hiding_layers_.empty()) StartFadeInAnimation(); } diff --git a/ash/display/output_configurator_animation.h b/ash/display/output_configurator_animation.h index 34bdfaf015ef9f..e82217aaecbf4f 100644 --- a/ash/display/output_configurator_animation.h +++ b/ash/display/output_configurator_animation.h @@ -44,8 +44,8 @@ class ASH_EXPORT OutputConfiguratorAnimation // ui::DisplayConfigurator::Observer overrides: virtual void OnDisplayModeChanged( const ui::DisplayConfigurator::DisplayStateList& outputs) OVERRIDE; - virtual void OnDisplayModeChangeFailed(ui::OutputState failed_new_state) - OVERRIDE; + virtual void OnDisplayModeChangeFailed( + ui::MultipleDisplayState failed_new_state) OVERRIDE; private: // Clears all hiding layers. Note that in case that this method is called diff --git a/ash/display/projecting_observer_chromeos.cc b/ash/display/projecting_observer_chromeos.cc index d47ff29e449f70..404ff24bc682c8 100644 --- a/ash/display/projecting_observer_chromeos.cc +++ b/ash/display/projecting_observer_chromeos.cc @@ -18,12 +18,13 @@ ProjectingObserver::ProjectingObserver() ProjectingObserver::~ProjectingObserver() {} void ProjectingObserver::OnDisplayModeChanged( - const ui::DisplayConfigurator::DisplayStateList& outputs) { + const ui::DisplayConfigurator::DisplayStateList& display_states) { has_internal_output_ = false; - output_count_ = outputs.size(); + output_count_ = display_states.size(); - for (size_t i = 0; i < outputs.size(); ++i) { - if (outputs[i].display->type() == ui::OUTPUT_TYPE_INTERNAL) { + for (size_t i = 0; i < display_states.size(); ++i) { + if (display_states[i].display->type() == + ui::DISPLAY_CONNECTION_TYPE_INTERNAL) { has_internal_output_ = true; break; } diff --git a/ash/display/projecting_observer_chromeos_unittest.cc b/ash/display/projecting_observer_chromeos_unittest.cc index 5837202aacd2eb..3a72551a644293 100644 --- a/ash/display/projecting_observer_chromeos_unittest.cc +++ b/ash/display/projecting_observer_chromeos_unittest.cc @@ -15,13 +15,13 @@ namespace { ui::TestDisplaySnapshot* CreateInternalSnapshot() { ui::TestDisplaySnapshot* output = new ui::TestDisplaySnapshot(); - output->set_type(ui::OUTPUT_TYPE_INTERNAL); + output->set_type(ui::DISPLAY_CONNECTION_TYPE_INTERNAL); return output; } ui::TestDisplaySnapshot* CreateVGASnapshot() { ui::TestDisplaySnapshot* output = new ui::TestDisplaySnapshot(); - output->set_type(ui::OUTPUT_TYPE_VGA); + output->set_type(ui::DISPLAY_CONNECTION_TYPE_VGA); return output; } diff --git a/ash/shell.cc b/ash/shell.cc index c0064c395a59f1..eea3bff2157b69 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -911,7 +911,7 @@ void Shell::Init() { #if defined(OS_CHROMEOS) // Pass the initial display state to PowerButtonController. power_button_controller_->OnDisplayModeChanged( - display_configurator_->cached_outputs()); + display_configurator_->cached_displays()); #endif AddShellObserver(lock_state_controller_.get()); diff --git a/ash/wm/lock_state_controller_unittest.cc b/ash/wm/lock_state_controller_unittest.cc index abbf223197910f..ef48c088f477b5 100644 --- a/ash/wm/lock_state_controller_unittest.cc +++ b/ash/wm/lock_state_controller_unittest.cc @@ -1000,14 +1000,14 @@ TEST_F(LockStateControllerTest, HonorPowerButtonInDockedMode) { ui::DisplayConfigurator::DisplayStateList outputs; ui::DisplayConfigurator::DisplayState internal_output; ui::TestDisplaySnapshot internal_display; - internal_display.set_type(ui::OUTPUT_TYPE_INTERNAL); + internal_display.set_type(ui::DISPLAY_CONNECTION_TYPE_INTERNAL); internal_display.set_modes(modes.get()); internal_output.display = &internal_display; outputs.push_back(internal_output); ui::DisplayConfigurator::DisplayState external_output; ui::TestDisplaySnapshot external_display; - external_display.set_type(ui::OUTPUT_TYPE_HDMI); + external_display.set_type(ui::DISPLAY_CONNECTION_TYPE_HDMI); external_display.set_modes(modes.get()); external_output.display = &external_display; outputs.push_back(external_output); diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc index f23543fbf455c0..3e4861a2ccfc1d 100644 --- a/ash/wm/power_button_controller.cc +++ b/ash/wm/power_button_controller.cc @@ -118,15 +118,15 @@ void PowerButtonController::OnLockButtonEvent( #if defined(OS_CHROMEOS) void PowerButtonController::OnDisplayModeChanged( - const ui::DisplayConfigurator::DisplayStateList& outputs) { + const ui::DisplayConfigurator::DisplayStateList& display_states) { bool internal_display_off = false; bool external_display_on = false; - for (size_t i = 0; i < outputs.size(); ++i) { - const ui::DisplayConfigurator::DisplayState& output = outputs[i]; - if (output.display->type() == ui::OUTPUT_TYPE_INTERNAL) { - if (!output.display->current_mode()) + for (size_t i = 0; i < display_states.size(); ++i) { + const ui::DisplayConfigurator::DisplayState& state = display_states[i]; + if (state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL) { + if (!state.display->current_mode()) internal_display_off = true; - } else if (output.display->current_mode()) { + } else if (state.display->current_mode()) { external_display_on = true; } } diff --git a/chrome/browser/renderer_host/pepper/pepper_output_protection_message_filter.cc b/chrome/browser/renderer_host/pepper/pepper_output_protection_message_filter.cc index 80a07ae7731474..b973bfad9302f3 100644 --- a/chrome/browser/renderer_host/pepper/pepper_output_protection_message_filter.cc +++ b/chrome/browser/renderer_host/pepper/pepper_output_protection_message_filter.cc @@ -31,38 +31,38 @@ namespace { #if defined(OS_CHROMEOS) COMPILE_ASSERT(static_cast(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NONE) == - static_cast(ui::OUTPUT_TYPE_NONE), + static_cast(ui::DISPLAY_CONNECTION_TYPE_NONE), PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NONE); COMPILE_ASSERT( static_cast(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_UNKNOWN) == - static_cast(ui::OUTPUT_TYPE_UNKNOWN), + static_cast(ui::DISPLAY_CONNECTION_TYPE_UNKNOWN), PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_UNKNOWN); COMPILE_ASSERT( static_cast(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_INTERNAL) == - static_cast(ui::OUTPUT_TYPE_INTERNAL), + static_cast(ui::DISPLAY_CONNECTION_TYPE_INTERNAL), PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_INTERNAL); COMPILE_ASSERT(static_cast(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_VGA) == - static_cast(ui::OUTPUT_TYPE_VGA), + static_cast(ui::DISPLAY_CONNECTION_TYPE_VGA), PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_VGA); COMPILE_ASSERT(static_cast(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI) == - static_cast(ui::OUTPUT_TYPE_HDMI), + static_cast(ui::DISPLAY_CONNECTION_TYPE_HDMI), PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI); COMPILE_ASSERT(static_cast(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DVI) == - static_cast(ui::OUTPUT_TYPE_DVI), + static_cast(ui::DISPLAY_CONNECTION_TYPE_DVI), PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DVI); COMPILE_ASSERT( static_cast(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DISPLAYPORT) == - static_cast(ui::OUTPUT_TYPE_DISPLAYPORT), + static_cast(ui::DISPLAY_CONNECTION_TYPE_DISPLAYPORT), PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DISPLAYPORT); COMPILE_ASSERT( static_cast(PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NETWORK) == - static_cast(ui::OUTPUT_TYPE_NETWORK), + static_cast(ui::DISPLAY_CONNECTION_TYPE_NETWORK), PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NETWORK); COMPILE_ASSERT(static_cast(PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE) == - static_cast(ui::OUTPUT_PROTECTION_METHOD_NONE), + static_cast(ui::CONTENT_PROTECTION_METHOD_NONE), PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE); COMPILE_ASSERT(static_cast(PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP) == - static_cast(ui::OUTPUT_PROTECTION_METHOD_HDCP), + static_cast(ui::CONTENT_PROTECTION_METHOD_HDCP), PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP); bool GetCurrentDisplayId(content::RenderFrameHost* rfh, int64* display_id) { @@ -96,13 +96,13 @@ class PepperOutputProtectionMessageFilter::Delegate int32_t OnEnableProtection(uint32_t desired_method_mask); private: - ui::DisplayConfigurator::OutputProtectionClientId GetClientId(); + ui::DisplayConfigurator::ContentProtectionClientId GetClientId(); // Used to lookup the WebContents associated with this PP_Instance. int render_process_id_; int render_frame_id_; - ui::DisplayConfigurator::OutputProtectionClientId client_id_; + ui::DisplayConfigurator::ContentProtectionClientId client_id_; // The display id which the renderer currently uses. int64 display_id_; // The last desired method mask. Will enable this mask on new display if @@ -125,7 +125,7 @@ PepperOutputProtectionMessageFilter::Delegate::~Delegate() { ui::DisplayConfigurator* configurator = ash::Shell::GetInstance()->display_configurator(); - configurator->UnregisterOutputProtectionClient(client_id_); + configurator->UnregisterContentProtectionClient(client_id_); content::RenderFrameHost* rfh = content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); @@ -136,7 +136,7 @@ PepperOutputProtectionMessageFilter::Delegate::~Delegate() { } } -ui::DisplayConfigurator::OutputProtectionClientId +ui::DisplayConfigurator::ContentProtectionClientId PepperOutputProtectionMessageFilter::Delegate::GetClientId() { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); if (client_id_ == ui::DisplayConfigurator::kInvalidClientId) { @@ -151,7 +151,7 @@ PepperOutputProtectionMessageFilter::Delegate::GetClientId() { ui::DisplayConfigurator* configurator = ash::Shell::GetInstance()->display_configurator(); - client_id_ = configurator->RegisterOutputProtectionClient(); + client_id_ = configurator->RegisterContentProtectionClient(); } return client_id_; } @@ -169,7 +169,7 @@ int32_t PepperOutputProtectionMessageFilter::Delegate::OnQueryStatus( ui::DisplayConfigurator* configurator = ash::Shell::GetInstance()->display_configurator(); - bool result = configurator->QueryOutputProtectionStatus( + bool result = configurator->QueryContentProtectionStatus( GetClientId(), display_id_, link_mask, protection_mask); // If we successfully retrieved the device level status, check for capturers. @@ -182,7 +182,7 @@ int32_t PepperOutputProtectionMessageFilter::Delegate::OnQueryStatus( MediaCaptureDevicesDispatcher::GetInstance() ->IsDesktopCaptureInProgress(); if (capture_detected) - *link_mask |= ui::OUTPUT_TYPE_NETWORK; + *link_mask |= ui::DISPLAY_CONNECTION_TYPE_NETWORK; } return result ? PP_OK : PP_ERROR_FAILED; @@ -194,7 +194,7 @@ int32_t PepperOutputProtectionMessageFilter::Delegate::OnEnableProtection( ui::DisplayConfigurator* configurator = ash::Shell::GetInstance()->display_configurator(); - bool result = configurator->EnableOutputProtection( + bool result = configurator->EnableContentProtection( GetClientId(), display_id_, desired_method_mask); desired_method_mask_ = desired_method_mask; return result ? PP_OK : PP_ERROR_FAILED; @@ -215,14 +215,14 @@ void PepperOutputProtectionMessageFilter::Delegate::OnWindowHierarchyChanged( if (display_id_ == new_display_id) return; - if (desired_method_mask_ != ui::OUTPUT_PROTECTION_METHOD_NONE) { + if (desired_method_mask_ != ui::CONTENT_PROTECTION_METHOD_NONE) { // Display changed and should enable output protections on new display. ui::DisplayConfigurator* configurator = ash::Shell::GetInstance()->display_configurator(); - configurator->EnableOutputProtection(GetClientId(), new_display_id, - desired_method_mask_); - configurator->EnableOutputProtection( - GetClientId(), display_id_, ui::OUTPUT_PROTECTION_METHOD_NONE); + configurator->EnableContentProtection( + GetClientId(), new_display_id, desired_method_mask_); + configurator->EnableContentProtection( + GetClientId(), display_id_, ui::CONTENT_PROTECTION_METHOD_NONE); } display_id_ = new_display_id; } diff --git a/ui/display/chromeos/display_configurator.cc b/ui/display/chromeos/display_configurator.cc index 74180f82130f5e..8a8885a5e03204 100644 --- a/ui/display/chromeos/display_configurator.cc +++ b/ui/display/chromeos/display_configurator.cc @@ -51,47 +51,48 @@ std::string DisplayPowerStateToString(chromeos::DisplayPowerState state) { } // Returns a string describing |state|. -std::string OutputStateToString(OutputState state) { +std::string DisplayStateToString(MultipleDisplayState state) { switch (state) { - case OUTPUT_STATE_INVALID: + case MULTIPLE_DISPLAY_STATE_INVALID: return "INVALID"; - case OUTPUT_STATE_HEADLESS: + case MULTIPLE_DISPLAY_STATE_HEADLESS: return "HEADLESS"; - case OUTPUT_STATE_SINGLE: + case MULTIPLE_DISPLAY_STATE_SINGLE: return "SINGLE"; - case OUTPUT_STATE_DUAL_MIRROR: + case MULTIPLE_DISPLAY_STATE_DUAL_MIRROR: return "DUAL_MIRROR"; - case OUTPUT_STATE_DUAL_EXTENDED: + case MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED: return "DUAL_EXTENDED"; } NOTREACHED() << "Unknown state " << state; return "INVALID"; } -// Returns the number of outputs in |outputs| that should be turned on, per -// |state|. If |output_power| is non-NULL, it is updated to contain the -// on/off state of each corresponding entry in |outputs|. -int GetOutputPower( - const std::vector& outputs, +// Returns the number of displays in |displays| that should be turned on, per +// |state|. If |display_power| is non-NULL, it is updated to contain the +// on/off state of each corresponding entry in |displays|. +int GetDisplayPower( + const std::vector& display_states, chromeos::DisplayPowerState state, - std::vector* 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].display->type() == OUTPUT_TYPE_INTERNAL; + std::vector* display_power) { + int num_on_displays = 0; + if (display_power) + display_power->resize(display_states.size()); + + for (size_t i = 0; i < display_states.size(); ++i) { + bool internal = + display_states[i].display->type() == DISPLAY_CONNECTION_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 (display_power) + (*display_power)[i] = on; if (on) - num_on_outputs++; + num_on_displays++; } - return num_on_outputs; + return num_on_displays; } } // namespace @@ -112,7 +113,7 @@ bool DisplayConfigurator::TestApi::TriggerConfigureTimeout() { if (configurator_->configure_timer_.get() && configurator_->configure_timer_->IsRunning()) { configurator_->configure_timer_.reset(); - configurator_->ConfigureOutputs(); + configurator_->ConfigureDisplays(); return true; } else { return false; @@ -121,11 +122,11 @@ bool DisplayConfigurator::TestApi::TriggerConfigureTimeout() { // static const DisplayMode* DisplayConfigurator::FindDisplayModeMatchingSize( - const DisplaySnapshot& output, + const DisplaySnapshot& display, const gfx::Size& size) { const DisplayMode* best_mode = NULL; - for (DisplayModeList::const_iterator it = output.modes().begin(); - it != output.modes().end(); + for (DisplayModeList::const_iterator it = display.modes().begin(); + it != display.modes().end(); ++it) { const DisplayMode* mode = *it; @@ -162,9 +163,9 @@ DisplayConfigurator::DisplayConfigurator() mirroring_controller_(NULL), is_panel_fitting_enabled_(false), configure_display_(base::SysInfo::IsRunningOnChromeOS()), - output_state_(OUTPUT_STATE_INVALID), + display_state_(MULTIPLE_DISPLAY_STATE_INVALID), power_state_(chromeos::DISPLAY_POWER_ALL_ON), - next_output_protection_client_id_(1) {} + next_display_protection_client_id_(1) {} DisplayConfigurator::~DisplayConfigurator() { if (native_display_delegate_) @@ -189,7 +190,7 @@ void DisplayConfigurator::SetTouchscreenDelegateForTesting( void DisplayConfigurator::SetInitialDisplayPower( chromeos::DisplayPowerState power_state) { - DCHECK_EQ(output_state_, OUTPUT_STATE_INVALID); + DCHECK_EQ(display_state_, MULTIPLE_DISPLAY_STATE_INVALID); power_state_ = power_state; } @@ -228,10 +229,10 @@ void DisplayConfigurator::ForceInitialConfigure( native_display_delegate_->GrabServer(); native_display_delegate_->Initialize(); - UpdateCachedOutputs(); - if (cached_outputs_.size() > 1 && background_color_argb) + UpdateCachedDisplays(); + if (cached_displays_.size() > 1 && background_color_argb) native_display_delegate_->SetBackgroundColor(background_color_argb); - const OutputState new_state = ChooseOutputState(power_state_); + const MultipleDisplayState new_state = ChooseDisplayState(power_state_); const bool success = EnterStateOrFallBackToSoftwareMirroring(new_state, power_state_); @@ -242,36 +243,36 @@ void DisplayConfigurator::ForceInitialConfigure( NotifyObservers(success, new_state); } -bool DisplayConfigurator::ApplyProtections(const DisplayProtections& requests) { - for (DisplayStateList::const_iterator it = cached_outputs_.begin(); - it != cached_outputs_.end(); +bool DisplayConfigurator::ApplyProtections(const ContentProtections& requests) { + for (DisplayStateList::const_iterator it = cached_displays_.begin(); + it != cached_displays_.end(); ++it) { uint32_t all_desired = 0; - DisplayProtections::const_iterator request_it = + ContentProtections::const_iterator request_it = requests.find(it->display->display_id()); if (request_it != requests.end()) all_desired = request_it->second; switch (it->display->type()) { - case OUTPUT_TYPE_UNKNOWN: + case DISPLAY_CONNECTION_TYPE_UNKNOWN: return false; // DisplayPort, DVI, and HDMI all support HDCP. - case OUTPUT_TYPE_DISPLAYPORT: - case OUTPUT_TYPE_DVI: - case OUTPUT_TYPE_HDMI: { + case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: + case DISPLAY_CONNECTION_TYPE_DVI: + case DISPLAY_CONNECTION_TYPE_HDMI: { HDCPState new_desired_state = - (all_desired & OUTPUT_PROTECTION_METHOD_HDCP) ? + (all_desired & CONTENT_PROTECTION_METHOD_HDCP) ? HDCP_STATE_DESIRED : HDCP_STATE_UNDESIRED; if (!native_display_delegate_->SetHDCPState(*it->display, new_desired_state)) return false; break; } - case OUTPUT_TYPE_INTERNAL: - case OUTPUT_TYPE_VGA: - case OUTPUT_TYPE_NETWORK: + case DISPLAY_CONNECTION_TYPE_INTERNAL: + case DISPLAY_CONNECTION_TYPE_VGA: + case DISPLAY_CONNECTION_TYPE_NETWORK: // No protections for these types. Do nothing. break; - case OUTPUT_TYPE_NONE: + case DISPLAY_CONNECTION_TYPE_NONE: NOTREACHED(); break; } @@ -280,24 +281,24 @@ bool DisplayConfigurator::ApplyProtections(const DisplayProtections& requests) { return true; } -DisplayConfigurator::OutputProtectionClientId -DisplayConfigurator::RegisterOutputProtectionClient() { +DisplayConfigurator::ContentProtectionClientId +DisplayConfigurator::RegisterContentProtectionClient() { if (!configure_display_) return kInvalidClientId; - return next_output_protection_client_id_++; + return next_display_protection_client_id_++; } -void DisplayConfigurator::UnregisterOutputProtectionClient( - OutputProtectionClientId client_id) { +void DisplayConfigurator::UnregisterContentProtectionClient( + ContentProtectionClientId client_id) { client_protection_requests_.erase(client_id); - DisplayProtections protections; + ContentProtections protections; for (ProtectionRequests::const_iterator it = client_protection_requests_.begin(); it != client_protection_requests_.end(); ++it) { - for (DisplayProtections::const_iterator it2 = it->second.begin(); + for (ContentProtections::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) { protections[it2->first] |= it2->second; @@ -307,8 +308,8 @@ void DisplayConfigurator::UnregisterOutputProtectionClient( ApplyProtections(protections); } -bool DisplayConfigurator::QueryOutputProtectionStatus( - OutputProtectionClientId client_id, +bool DisplayConfigurator::QueryContentProtectionStatus( + ContentProtectionClientId client_id, int64_t display_id, uint32_t* link_mask, uint32_t* protection_mask) { @@ -318,34 +319,34 @@ bool DisplayConfigurator::QueryOutputProtectionStatus( uint32_t enabled = 0; uint32_t unfulfilled = 0; *link_mask = 0; - for (DisplayStateList::const_iterator it = cached_outputs_.begin(); - it != cached_outputs_.end(); + for (DisplayStateList::const_iterator it = cached_displays_.begin(); + it != cached_displays_.end(); ++it) { if (it->display->display_id() != display_id) continue; *link_mask |= it->display->type(); switch (it->display->type()) { - case OUTPUT_TYPE_UNKNOWN: + case DISPLAY_CONNECTION_TYPE_UNKNOWN: return false; // DisplayPort, DVI, and HDMI all support HDCP. - case OUTPUT_TYPE_DISPLAYPORT: - case OUTPUT_TYPE_DVI: - case OUTPUT_TYPE_HDMI: { + case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: + case DISPLAY_CONNECTION_TYPE_DVI: + case DISPLAY_CONNECTION_TYPE_HDMI: { HDCPState state; if (!native_display_delegate_->GetHDCPState(*it->display, &state)) return false; if (state == HDCP_STATE_ENABLED) - enabled |= OUTPUT_PROTECTION_METHOD_HDCP; + enabled |= CONTENT_PROTECTION_METHOD_HDCP; else - unfulfilled |= OUTPUT_PROTECTION_METHOD_HDCP; + unfulfilled |= CONTENT_PROTECTION_METHOD_HDCP; break; } - case OUTPUT_TYPE_INTERNAL: - case OUTPUT_TYPE_VGA: - case OUTPUT_TYPE_NETWORK: + case DISPLAY_CONNECTION_TYPE_INTERNAL: + case DISPLAY_CONNECTION_TYPE_VGA: + case DISPLAY_CONNECTION_TYPE_NETWORK: // No protections for these types. Do nothing. break; - case OUTPUT_TYPE_NONE: + case DISPLAY_CONNECTION_TYPE_NONE: NOTREACHED(); break; } @@ -364,19 +365,19 @@ bool DisplayConfigurator::QueryOutputProtectionStatus( return true; } -bool DisplayConfigurator::EnableOutputProtection( - OutputProtectionClientId client_id, +bool DisplayConfigurator::EnableContentProtection( + ContentProtectionClientId client_id, int64_t display_id, uint32_t desired_method_mask) { if (!configure_display_) return false; - DisplayProtections protections; + ContentProtections protections; for (ProtectionRequests::const_iterator it = client_protection_requests_.begin(); it != client_protection_requests_.end(); ++it) { - for (DisplayProtections::const_iterator it2 = it->second.begin(); + for (ContentProtections::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) { if (it->first == client_id && it2->first == display_id) @@ -389,7 +390,7 @@ bool DisplayConfigurator::EnableOutputProtection( if (!ApplyProtections(protections)) return false; - if (desired_method_mask == OUTPUT_PROTECTION_METHOD_NONE) { + if (desired_method_mask == CONTENT_PROTECTION_METHOD_NONE) { if (client_protection_requests_.find(client_id) != client_protection_requests_.end()) { client_protection_requests_[client_id].erase(display_id); @@ -407,11 +408,11 @@ std::vector DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { if (!base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableDisplayColorCalibration)) { - for (size_t i = 0; i < cached_outputs_.size(); ++i) { - if (cached_outputs_[i].display && - cached_outputs_[i].display->display_id() == display_id) { + for (size_t i = 0; i < cached_displays_.size(); ++i) { + if (cached_displays_[i].display && + cached_displays_[i].display->display_id() == display_id) { return native_display_delegate_->GetAvailableColorCalibrationProfiles( - *cached_outputs_[i].display); + *cached_displays_[i].display); } } } @@ -422,11 +423,11 @@ DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { bool DisplayConfigurator::SetColorCalibrationProfile( int64_t display_id, ui::ColorCalibrationProfile new_profile) { - for (size_t i = 0; i < cached_outputs_.size(); ++i) { - if (cached_outputs_[i].display && - cached_outputs_[i].display->display_id() == display_id) { + for (size_t i = 0; i < cached_displays_.size(); ++i) { + if (cached_displays_[i].display && + cached_displays_[i].display->display_id() == display_id) { return native_display_delegate_->SetColorCalibrationProfile( - *cached_outputs_[i].display, new_profile); + *cached_displays_[i].display, new_profile); } } @@ -452,17 +453,17 @@ bool DisplayConfigurator::SetDisplayPower( return true; native_display_delegate_->GrabServer(); - UpdateCachedOutputs(); + UpdateCachedDisplays(); - const OutputState new_state = ChooseOutputState(power_state); + const MultipleDisplayState new_state = ChooseDisplayState(power_state); bool attempted_change = false; bool success = false; bool only_if_single_internal_display = flags & kSetDisplayPowerOnlyIfSingleInternalDisplay; bool single_internal_display = - cached_outputs_.size() == 1 && - cached_outputs_[0].display->type() == OUTPUT_TYPE_INTERNAL; + cached_displays_.size() == 1 && + cached_displays_[0].display->type() == DISPLAY_CONNECTION_TYPE_INTERNAL; if (single_internal_display || !only_if_single_internal_display) { success = EnterStateOrFallBackToSoftwareMirroring(new_state, power_state); attempted_change = true; @@ -479,22 +480,24 @@ bool DisplayConfigurator::SetDisplayPower( return true; } -bool DisplayConfigurator::SetDisplayMode(OutputState new_state) { +bool DisplayConfigurator::SetDisplayMode(MultipleDisplayState new_state) { if (!configure_display_) return false; - VLOG(1) << "SetDisplayMode: state=" << OutputStateToString(new_state); - if (output_state_ == new_state) { + VLOG(1) << "SetDisplayMode: state=" << DisplayStateToString(new_state); + if (display_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 == OUTPUT_STATE_DUAL_EXTENDED) + // MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED to + // MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED. + if (mirroring_controller_ && + new_state == MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED) mirroring_controller_->SetSoftwareMirroring(false); NotifyObservers(true, new_state); return true; } native_display_delegate_->GrabServer(); - UpdateCachedOutputs(); + UpdateCachedDisplays(); const bool success = EnterStateOrFallBackToSoftwareMirroring(new_state, power_state_); native_display_delegate_->UngrabServer(); @@ -504,8 +507,8 @@ bool DisplayConfigurator::SetDisplayMode(OutputState new_state) { } void DisplayConfigurator::OnConfigurationChanged() { - // Configure outputs with |kConfigureDelayMs| delay, - // so that time-consuming ConfigureOutputs() won't be called multiple times. + // Configure displays with |kConfigureDelayMs| delay, + // so that time-consuming ConfigureDisplays() won't be called multiple times. if (configure_timer_.get()) { configure_timer_->Reset(); } else { @@ -514,7 +517,7 @@ void DisplayConfigurator::OnConfigurationChanged() { FROM_HERE, base::TimeDelta::FromMilliseconds(kConfigureDelayMs), this, - &DisplayConfigurator::ConfigureOutputs); + &DisplayConfigurator::ConfigureDisplays); } } @@ -549,99 +552,103 @@ void DisplayConfigurator::ResumeDisplays() { SetDisplayPower(power_state_, kSetDisplayPowerForceProbe); } -void DisplayConfigurator::UpdateCachedOutputs() { +void DisplayConfigurator::UpdateCachedDisplays() { std::vector snapshots = - native_display_delegate_->GetOutputs(); + native_display_delegate_->GetDisplays(); - cached_outputs_.clear(); + cached_displays_.clear(); for (size_t i = 0; i < snapshots.size(); ++i) { DisplayState display_state; display_state.display = snapshots[i]; - cached_outputs_.push_back(display_state); + cached_displays_.push_back(display_state); } - touchscreen_delegate_->AssociateTouchscreens(&cached_outputs_); + touchscreen_delegate_->AssociateTouchscreens(&cached_displays_); // Set |selected_mode| fields. - for (size_t i = 0; i < cached_outputs_.size(); ++i) { - DisplayState* output = &cached_outputs_[i]; - if (output->display->has_proper_display_id()) { + for (size_t i = 0; i < cached_displays_.size(); ++i) { + DisplayState* display_state = &cached_displays_[i]; + if (display_state->display->has_proper_display_id()) { gfx::Size size; - if (state_controller_ && state_controller_->GetResolutionForDisplayId( - output->display->display_id(), &size)) { - output->selected_mode = - FindDisplayModeMatchingSize(*output->display, size); + if (state_controller_ && + state_controller_->GetResolutionForDisplayId( + display_state->display->display_id(), &size)) { + display_state->selected_mode = + FindDisplayModeMatchingSize(*display_state->display, size); } } // Fall back to native mode. - if (!output->selected_mode) - output->selected_mode = output->display->native_mode(); + if (!display_state->selected_mode) + display_state->selected_mode = display_state->display->native_mode(); } // Set |mirror_mode| fields. - if (cached_outputs_.size() == 2) { + if (cached_displays_.size() == 2) { bool one_is_internal = - cached_outputs_[0].display->type() == OUTPUT_TYPE_INTERNAL; + cached_displays_[0].display->type() == DISPLAY_CONNECTION_TYPE_INTERNAL; bool two_is_internal = - cached_outputs_[1].display->type() == OUTPUT_TYPE_INTERNAL; - int internal_outputs = + cached_displays_[1].display->type() == DISPLAY_CONNECTION_TYPE_INTERNAL; + int internal_displays = (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."; + DCHECK_LT(internal_displays, 2); + LOG_IF(WARNING, internal_displays == 2) + << "Two internal displays detected."; bool can_mirror = false; for (int attempt = 0; !can_mirror && attempt < 2; ++attempt) { - // Try preserving external output's aspect ratio on the first attempt. + // Try preserving external display's aspect ratio on the first attempt. // If that fails, fall back to the highest matching resolution. bool preserve_aspect = attempt == 0; - if (internal_outputs == 1) { + if (internal_displays == 1) { if (one_is_internal) { - can_mirror = FindMirrorMode(&cached_outputs_[0], - &cached_outputs_[1], + can_mirror = FindMirrorMode(&cached_displays_[0], + &cached_displays_[1], is_panel_fitting_enabled_, preserve_aspect); } else { DCHECK(two_is_internal); - can_mirror = FindMirrorMode(&cached_outputs_[1], - &cached_outputs_[0], + can_mirror = FindMirrorMode(&cached_displays_[1], + &cached_displays_[0], is_panel_fitting_enabled_, preserve_aspect); } - } else { // if (internal_outputs == 0) - // No panel fitting for external outputs, so fall back to exact match. + } else { // if (internal_displays == 0) + // No panel fitting for external displays, so fall back to exact match. can_mirror = FindMirrorMode( - &cached_outputs_[0], &cached_outputs_[1], false, preserve_aspect); + &cached_displays_[0], &cached_displays_[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_displays_[1], + &cached_displays_[0], + false, + preserve_aspect); } } } } } -bool DisplayConfigurator::FindMirrorMode(DisplayState* internal_output, - DisplayState* external_output, +bool DisplayConfigurator::FindMirrorMode(DisplayState* internal_display, + DisplayState* external_display, bool try_panel_fitting, bool preserve_aspect) { const DisplayMode* internal_native_info = - internal_output->display->native_mode(); + internal_display->display->native_mode(); const DisplayMode* external_native_info = - external_output->display->native_mode(); + external_display->display->native_mode(); if (!internal_native_info || !external_native_info) return false; - // Check if some external output resolution can be mirrored on internal. - // Prefer the modes in the order that X sorts them, assuming this is the order - // in which they look better on the monitor. + // Check if some external display resolution can be mirrored on internal. + // Prefer the modes in the order they're present in DisplaySnapshot, assuming + // this is the order in which they look better on the monitor. for (DisplayModeList::const_iterator external_it = - external_output->display->modes().begin(); - external_it != external_output->display->modes().end(); + external_display->display->modes().begin(); + external_it != external_display->display->modes().end(); ++external_it) { const DisplayMode& external_info = **external_it; bool is_native_aspect_ratio = @@ -652,20 +659,20 @@ bool DisplayConfigurator::FindMirrorMode(DisplayState* internal_output, // Try finding an exact match. for (DisplayModeList::const_iterator internal_it = - internal_output->display->modes().begin(); - internal_it != internal_output->display->modes().end(); + internal_display->display->modes().begin(); + internal_it != internal_display->display->modes().end(); ++internal_it) { const DisplayMode& internal_info = **internal_it; if (internal_info.size().width() == external_info.size().width() && internal_info.size().height() == external_info.size().height() && internal_info.is_interlaced() == external_info.is_interlaced()) { - internal_output->mirror_mode = *internal_it; - external_output->mirror_mode = *external_it; + internal_display->mirror_mode = *internal_it; + external_display->mirror_mode = *external_it; return true; // Mirror mode found. } } - // Try to create a matching internal output mode by panel fitting. + // Try to create a matching internal display mode by panel fitting. if (try_panel_fitting) { // We can downscale by 1.125, and upscale indefinitely. Downscaling looks // ugly, so, can fit == can upscale. Also, internal panels don't support @@ -676,11 +683,11 @@ bool DisplayConfigurator::FindMirrorMode(DisplayState* internal_output, external_info.size().height() && !external_info.is_interlaced(); if (can_fit) { - native_display_delegate_->AddMode(*internal_output->display, + native_display_delegate_->AddMode(*internal_display->display, *external_it); - internal_output->display->add_mode(*external_it); - internal_output->mirror_mode = *external_it; - external_output->mirror_mode = *external_it; + internal_display->display->add_mode(*external_it); + internal_display->mirror_mode = *external_it; + external_display->mirror_mode = *external_it; return true; // Mirror mode created. } } @@ -689,15 +696,15 @@ bool DisplayConfigurator::FindMirrorMode(DisplayState* internal_output, return false; } -void DisplayConfigurator::ConfigureOutputs() { +void DisplayConfigurator::ConfigureDisplays() { configure_timer_.reset(); if (!configure_display_) return; native_display_delegate_->GrabServer(); - UpdateCachedOutputs(); - const OutputState new_state = ChooseOutputState(power_state_); + UpdateCachedDisplays(); + const MultipleDisplayState new_state = ChooseDisplayState(power_state_); const bool success = EnterStateOrFallBackToSoftwareMirroring(new_state, power_state_); native_display_delegate_->UngrabServer(); @@ -705,11 +712,12 @@ void DisplayConfigurator::ConfigureOutputs() { NotifyObservers(success, new_state); } -void DisplayConfigurator::NotifyObservers(bool success, - OutputState attempted_state) { +void DisplayConfigurator::NotifyObservers( + bool success, + MultipleDisplayState attempted_state) { if (success) { FOR_EACH_OBSERVER( - Observer, observers_, OnDisplayModeChanged(cached_outputs_)); + Observer, observers_, OnDisplayModeChanged(cached_displays_)); } else { FOR_EACH_OBSERVER( Observer, observers_, OnDisplayModeChangeFailed(attempted_state)); @@ -717,74 +725,74 @@ void DisplayConfigurator::NotifyObservers(bool success, } bool DisplayConfigurator::EnterStateOrFallBackToSoftwareMirroring( - OutputState output_state, + MultipleDisplayState display_state, chromeos::DisplayPowerState power_state) { - bool success = EnterState(output_state, power_state); + bool success = EnterState(display_state, power_state); if (mirroring_controller_) { bool enable_software_mirroring = false; - if (!success && output_state == OUTPUT_STATE_DUAL_MIRROR) { - if (output_state_ != OUTPUT_STATE_DUAL_EXTENDED || + if (!success && display_state == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR) { + if (display_state_ != MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED || power_state_ != power_state) - EnterState(OUTPUT_STATE_DUAL_EXTENDED, power_state); + EnterState(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, power_state); enable_software_mirroring = success = - output_state_ == OUTPUT_STATE_DUAL_EXTENDED; + display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED; } mirroring_controller_->SetSoftwareMirroring(enable_software_mirroring); } return success; } -bool DisplayConfigurator::EnterState(OutputState output_state, +bool DisplayConfigurator::EnterState(MultipleDisplayState display_state, chromeos::DisplayPowerState power_state) { - std::vector output_power; - int num_on_outputs = - GetOutputPower(cached_outputs_, power_state, &output_power); - VLOG(1) << "EnterState: output=" << OutputStateToString(output_state) + std::vector display_power; + int num_on_displays = + GetDisplayPower(cached_displays_, power_state, &display_power); + VLOG(1) << "EnterState: display=" << DisplayStateToString(display_state) << " power=" << DisplayPowerStateToString(power_state); // Framebuffer dimensions. gfx::Size size; - std::vector new_origins(cached_outputs_.size(), gfx::Point()); + std::vector new_origins(cached_displays_.size(), gfx::Point()); std::vector new_mode; - for (size_t i = 0; i < cached_outputs_.size(); ++i) - new_mode.push_back(cached_outputs_[i].display->current_mode()); + for (size_t i = 0; i < cached_displays_.size(); ++i) + new_mode.push_back(cached_displays_[i].display->current_mode()); - switch (output_state) { - case OUTPUT_STATE_INVALID: + switch (display_state) { + case MULTIPLE_DISPLAY_STATE_INVALID: NOTREACHED() << "Ignoring request to enter invalid state with " - << cached_outputs_.size() << " connected output(s)"; + << cached_displays_.size() << " connected display(s)"; return false; - case OUTPUT_STATE_HEADLESS: - if (cached_outputs_.size() != 0) { + case MULTIPLE_DISPLAY_STATE_HEADLESS: + if (cached_displays_.size() != 0) { LOG(WARNING) << "Ignoring request to enter headless mode with " - << cached_outputs_.size() << " connected output(s)"; + << cached_displays_.size() << " connected display(s)"; return false; } break; - case OUTPUT_STATE_SINGLE: { - // If there are multiple outputs connected, only one should be turned on. - if (cached_outputs_.size() != 1 && num_on_outputs != 1) { + case MULTIPLE_DISPLAY_STATE_SINGLE: { + // If there are multiple displays connected, only one should be turned on. + if (cached_displays_.size() != 1 && num_on_displays != 1) { LOG(WARNING) << "Ignoring request to enter single mode with " - << cached_outputs_.size() << " connected outputs and " - << num_on_outputs << " turned on"; + << cached_displays_.size() << " connected displays and " + << num_on_displays << " turned on"; return false; } - for (size_t i = 0; i < cached_outputs_.size(); ++i) { - DisplayState* output = &cached_outputs_[i]; - new_mode[i] = output_power[i] ? output->selected_mode : NULL; + for (size_t i = 0; i < cached_displays_.size(); ++i) { + DisplayState* state = &cached_displays_[i]; + new_mode[i] = display_power[i] ? state->selected_mode : NULL; - if (output_power[i] || cached_outputs_.size() == 1) { - const DisplayMode* mode_info = output->selected_mode; + if (display_power[i] || cached_displays_.size() == 1) { + const DisplayMode* mode_info = state->selected_mode; if (!mode_info) return false; if (mode_info->size() == gfx::Size(1024, 768)) { VLOG(1) << "Potentially misdetecting display(1024x768):" - << " outputs size=" << cached_outputs_.size() - << ", num_on_outputs=" << num_on_outputs + << " displays size=" << cached_displays_.size() + << ", num_on_displays=" << num_on_displays << ", current size:" << size.width() << "x" << size.height() - << ", i=" << i << ", output=" << output->display->ToString() + << ", i=" << i << ", display=" << state->display->ToString() << ", display_mode=" << mode_info->ToString(); } size = mode_info->size(); @@ -792,54 +800,54 @@ bool DisplayConfigurator::EnterState(OutputState output_state, } break; } - case OUTPUT_STATE_DUAL_MIRROR: { - if (cached_outputs_.size() != 2 || - (num_on_outputs != 0 && num_on_outputs != 2)) { + case MULTIPLE_DISPLAY_STATE_DUAL_MIRROR: { + if (cached_displays_.size() != 2 || + (num_on_displays != 0 && num_on_displays != 2)) { LOG(WARNING) << "Ignoring request to enter mirrored mode with " - << cached_outputs_.size() << " connected output(s) and " - << num_on_outputs << " turned on"; + << cached_displays_.size() << " connected display(s) and " + << num_on_displays << " turned on"; return false; } - const DisplayMode* mode_info = cached_outputs_[0].mirror_mode; + const DisplayMode* mode_info = cached_displays_[0].mirror_mode; if (!mode_info) return false; size = mode_info->size(); - for (size_t i = 0; i < cached_outputs_.size(); ++i) { - DisplayState* output = &cached_outputs_[i]; - new_mode[i] = output_power[i] ? output->mirror_mode : NULL; - if (output->touch_device_id) { + for (size_t i = 0; i < cached_displays_.size(); ++i) { + DisplayState* state = &cached_displays_[i]; + new_mode[i] = display_power[i] ? state->mirror_mode : NULL; + if (state->touch_device_id) { // CTM needs to be calculated if aspect preserving scaling is used. // Otherwise, assume it is full screen, and use identity CTM. - if (output->mirror_mode != output->display->native_mode() && - output->display->is_aspect_preserving_scaling()) { - output->transform = GetMirrorModeCTM(*output); - mirrored_display_area_ratio_map_[output->touch_device_id] = - GetMirroredDisplayAreaRatio(*output); + if (state->mirror_mode != state->display->native_mode() && + state->display->is_aspect_preserving_scaling()) { + state->transform = GetMirrorModeCTM(*state); + mirrored_display_area_ratio_map_[state->touch_device_id] = + GetMirroredDisplayAreaRatio(*state); } } } break; } - case OUTPUT_STATE_DUAL_EXTENDED: { - if (cached_outputs_.size() != 2 || - (num_on_outputs != 0 && num_on_outputs != 2)) { + case MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED: { + if (cached_displays_.size() != 2 || + (num_on_displays != 0 && num_on_displays != 2)) { LOG(WARNING) << "Ignoring request to enter extended mode with " - << cached_outputs_.size() << " connected output(s) and " - << num_on_outputs << " turned on"; + << cached_displays_.size() << " connected display(s) and " + << num_on_displays << " turned on"; return false; } - for (size_t i = 0; i < cached_outputs_.size(); ++i) { - DisplayState* output = &cached_outputs_[i]; + for (size_t i = 0; i < cached_displays_.size(); ++i) { + DisplayState* state = &cached_displays_[i]; new_origins[i].set_y(size.height() ? size.height() + kVerticalGap : 0); - new_mode[i] = output_power[i] ? output->selected_mode : NULL; + new_mode[i] = display_power[i] ? state->selected_mode : NULL; - // Retain the full screen size even if all outputs are off so the - // same desktop configuration can be restored when the outputs are + // Retain the full screen size even if all displays are off so the + // same desktop configuration can be restored when the displays are // turned back on. - const DisplayMode* mode_info = cached_outputs_[i].selected_mode; + const DisplayMode* mode_info = cached_displays_[i].selected_mode; if (!mode_info) return false; @@ -848,10 +856,10 @@ bool DisplayConfigurator::EnterState(OutputState output_state, mode_info->size().height()); } - for (size_t i = 0; i < cached_outputs_.size(); ++i) { - DisplayState* output = &cached_outputs_[i]; - if (output->touch_device_id) - output->transform = GetExtendedModeCTM(*output, new_origins[i], size); + for (size_t i = 0; i < cached_displays_.size(); ++i) { + DisplayState* state = &cached_displays_[i]; + if (state->touch_device_id) + state->transform = GetExtendedModeCTM(*state, new_origins[i], size); } break; } @@ -859,17 +867,17 @@ bool DisplayConfigurator::EnterState(OutputState output_state, // Finally, apply the desired changes. bool all_succeeded = true; - if (!cached_outputs_.empty()) { + if (!cached_displays_.empty()) { native_display_delegate_->CreateFrameBuffer(size); - for (size_t i = 0; i < cached_outputs_.size(); ++i) { - const DisplayState& output = cached_outputs_[i]; + for (size_t i = 0; i < cached_displays_.size(); ++i) { + const DisplayState& state = cached_displays_[i]; bool configure_succeeded = false; while (true) { if (native_display_delegate_->Configure( - *output.display, new_mode[i], new_origins[i])) { - output.display->set_current_mode(new_mode[i]); - output.display->set_origin(new_origins[i]); + *state.display, new_mode[i], new_origins[i])) { + state.display->set_current_mode(new_mode[i]); + state.display->set_origin(new_origins[i]); configure_succeeded = true; break; @@ -885,8 +893,8 @@ bool DisplayConfigurator::EnterState(OutputState output_state, int current_mode_pixels = mode_info->size().GetArea(); for (DisplayModeList::const_iterator it = - output.display->modes().begin(); - it != output.display->modes().end(); + state.display->modes().begin(); + it != state.display->modes().end(); it++) { int pixel_count = (*it)->size().GetArea(); if ((pixel_count < current_mode_pixels) && @@ -901,9 +909,9 @@ bool DisplayConfigurator::EnterState(OutputState output_state, } if (configure_succeeded) { - if (output.touch_device_id) - touchscreen_delegate_->ConfigureCTM(output.touch_device_id, - output.transform); + if (state.touch_device_id) + touchscreen_delegate_->ConfigureCTM(state.touch_device_id, + state.transform); } else { all_succeeded = false; } @@ -911,43 +919,44 @@ bool DisplayConfigurator::EnterState(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 == OUTPUT_STATE_DUAL_MIRROR && output_power[i] && - output.display->current_mode() != output.mirror_mode) + if (display_state == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR && + display_power[i] && + state.display->current_mode() != state.mirror_mode) all_succeeded = false; } } if (all_succeeded) { - output_state_ = output_state; + display_state_ = display_state; power_state_ = power_state; } return all_succeeded; } -OutputState DisplayConfigurator::ChooseOutputState( +MultipleDisplayState DisplayConfigurator::ChooseDisplayState( chromeos::DisplayPowerState power_state) const { - int num_on_outputs = GetOutputPower(cached_outputs_, power_state, NULL); - switch (cached_outputs_.size()) { + int num_on_displays = GetDisplayPower(cached_displays_, power_state, NULL); + switch (cached_displays_.size()) { case 0: - return OUTPUT_STATE_HEADLESS; + return MULTIPLE_DISPLAY_STATE_HEADLESS; case 1: - return OUTPUT_STATE_SINGLE; + return MULTIPLE_DISPLAY_STATE_SINGLE; case 2: { - if (num_on_outputs == 1) { - // If only one output is currently turned on, return the "single" + if (num_on_displays == 1) { + // If only one display is currently turned on, return the "single" // state so that its native mode will be used. - return OUTPUT_STATE_SINGLE; + return MULTIPLE_DISPLAY_STATE_SINGLE; } else { if (!state_controller_) - return OUTPUT_STATE_DUAL_EXTENDED; - // With either both outputs on or both outputs off, use one of the + return MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED; + // With either both displays on or both displays off, use one of the // dual modes. std::vector display_ids; - for (size_t i = 0; i < cached_outputs_.size(); ++i) { + for (size_t i = 0; i < cached_displays_.size(); ++i) { // If display id isn't available, switch to extended mode. - if (!cached_outputs_[i].display->has_proper_display_id()) - return OUTPUT_STATE_DUAL_EXTENDED; - display_ids.push_back(cached_outputs_[i].display->display_id()); + if (!cached_displays_[i].display->has_proper_display_id()) + return MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED; + display_ids.push_back(cached_displays_[i].display->display_id()); } return state_controller_->GetStateForDisplayIds(display_ids); } @@ -955,14 +964,14 @@ OutputState DisplayConfigurator::ChooseOutputState( default: NOTREACHED(); } - return OUTPUT_STATE_INVALID; + return MULTIPLE_DISPLAY_STATE_INVALID; } DisplayConfigurator::CoordinateTransformation -DisplayConfigurator::GetMirrorModeCTM(const DisplayState& output) { +DisplayConfigurator::GetMirrorModeCTM(const DisplayState& display_state) { CoordinateTransformation ctm; // Default to identity - const DisplayMode* native_mode_info = output.display->native_mode(); - const DisplayMode* mirror_mode_info = output.mirror_mode; + const DisplayMode* native_mode_info = display_state.display->native_mode(); + const DisplayMode* mirror_mode_info = display_state.mirror_mode; if (!native_mode_info || !mirror_mode_info || native_mode_info->size().height() == 0 || @@ -995,11 +1004,11 @@ DisplayConfigurator::GetMirrorModeCTM(const DisplayState& output) { } DisplayConfigurator::CoordinateTransformation -DisplayConfigurator::GetExtendedModeCTM(const DisplayState& output, +DisplayConfigurator::GetExtendedModeCTM(const DisplayState& display_state, const gfx::Point& new_origin, const gfx::Size& framebuffer_size) { CoordinateTransformation ctm; // Default to identity - const DisplayMode* mode_info = output.selected_mode; + const DisplayMode* mode_info = display_state.selected_mode; DCHECK(mode_info); if (!mode_info) return ctm; @@ -1035,10 +1044,10 @@ DisplayConfigurator::GetExtendedModeCTM(const DisplayState& output, } float DisplayConfigurator::GetMirroredDisplayAreaRatio( - const DisplayState& output) { + const DisplayState& display_state) { float area_ratio = 1.0f; - const DisplayMode* native_mode_info = output.display->native_mode(); - const DisplayMode* mirror_mode_info = output.mirror_mode; + const DisplayMode* native_mode_info = display_state.display->native_mode(); + const DisplayMode* mirror_mode_info = display_state.mirror_mode; if (!native_mode_info || !mirror_mode_info || native_mode_info->size().height() == 0 || diff --git a/ui/display/chromeos/display_configurator.h b/ui/display/chromeos/display_configurator.h index 9aaa745ae5c25c..26a423e71bbcf3 100644 --- a/ui/display/chromeos/display_configurator.h +++ b/ui/display/chromeos/display_configurator.h @@ -33,8 +33,8 @@ class NativeDisplayDelegate; // This class interacts directly with the system display configurator. class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { public: - typedef uint64_t OutputProtectionClientId; - static const OutputProtectionClientId kInvalidClientId = 0; + typedef uint64_t ContentProtectionClientId; + static const ContentProtectionClientId kInvalidClientId = 0; struct CoordinateTransformation { // Initialized to the identity transformation. @@ -51,15 +51,15 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { DisplaySnapshot* display; // Not owned. - // XInput device ID or 0 if this output isn't a touchscreen. + // XInput device ID or 0 if this display isn't a touchscreen. int touch_device_id; CoordinateTransformation transform; - // User-selected mode for the output. + // User-selected mode for the display. const DisplayMode* selected_mode; - // Mode used when displaying the same desktop on multiple outputs. + // Mode used when displaying the same desktop on multiple displays. const DisplayMode* mirror_mode; }; @@ -69,29 +69,30 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { public: virtual ~Observer() {} - // Called after the display mode has been changed. |output| contains the + // Called after the display mode has been changed. |display| contains the // just-applied configuration. Note that the X server is no longer grabbed // when this method is called, so the actual configuration could've changed // already. virtual void OnDisplayModeChanged( - const std::vector& outputs) {} + const std::vector& displays) {} // Called after a display mode change attempt failed. |failed_new_state| is // the new state which the system failed to enter. - virtual void OnDisplayModeChangeFailed(OutputState failed_new_state) {} + virtual void OnDisplayModeChangeFailed( + MultipleDisplayState failed_new_state) {} }; - // Interface for classes that make decisions about which output state + // Interface for classes that make decisions about which display state // should be used. class StateController { public: virtual ~StateController() {} // Called when displays are detected. - virtual OutputState GetStateForDisplayIds( + virtual MultipleDisplayState GetStateForDisplayIds( const std::vector& display_ids) const = 0; - // Queries the resolution (|size|) in pixels to select output mode for the + // Queries the resolution (|size|) in pixels to select display mode for the // given display id. virtual bool GetResolutionForDisplayId(int64_t display_id, gfx::Size* size) const = 0; @@ -111,11 +112,11 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { virtual ~TouchscreenDelegate() {} // Searches for touchscreens among input devices, - // and tries to match them up to screens in |outputs|. - // |outputs| is an array of detected screens. - // If a touchscreen with same resolution as an output's native mode - // is detected, its id will be stored in this output. - virtual void AssociateTouchscreens(std::vector* outputs) = 0; + // and tries to match them up to screens in |displays|. + // |displays| is an array of detected screens. + // If a touchscreen with same resolution as a display's native mode + // is detected, its id will be stored in this display. + virtual void AssociateTouchscreens(std::vector* displays) = 0; // Configures XInput's Coordinate Transformation Matrix property. // |touch_device_id| the ID of the touchscreen device to configure. @@ -133,7 +134,7 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { ~TestApi() {} // If |configure_timer_| is started, stops the timer, runs - // ConfigureOutputs(), and returns true; returns false otherwise. + // ConfigureDisplays(), and returns true; returns false otherwise. bool TriggerConfigureTimeout(); private: @@ -159,19 +160,19 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { // See crbug.com/130188 for initial discussion. static const int kVerticalGap = 60; - // Returns the mode within |output| that matches the given size with highest - // refresh rate. Returns None if no matching output was found. + // Returns the mode within |display| that matches the given size with highest + // refresh rate. Returns None if no matching display was found. static const DisplayMode* FindDisplayModeMatchingSize( - const DisplaySnapshot& output, + const DisplaySnapshot& display, const gfx::Size& size); DisplayConfigurator(); virtual ~DisplayConfigurator(); - OutputState output_state() const { return output_state_; } + MultipleDisplayState display_state() const { return display_state_; } chromeos::DisplayPowerState power_state() const { return power_state_; } - const std::vector& cached_outputs() const { - return cached_outputs_; + const std::vector& cached_displays() const { + return cached_displays_; } void set_state_controller(StateController* controller) { @@ -213,8 +214,8 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { // Force switching the display mode to |new_state|. Returns false if // switching failed (possibly because |new_state| is invalid for the - // current set of connected outputs). - bool SetDisplayMode(OutputState new_state); + // current set of connected displays). + bool SetDisplayMode(MultipleDisplayState new_state); // NativeDisplayDelegate::Observer overrides: virtual void OnConfigurationChanged() OVERRIDE; @@ -235,30 +236,30 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { return mirrored_display_area_ratio_map_; } - // Registers a client for output protection and requests a client id. Returns + // Registers a client for display protection and requests a client id. Returns // 0 if requesting failed. - OutputProtectionClientId RegisterOutputProtectionClient(); + ContentProtectionClientId RegisterContentProtectionClient(); // Unregisters the client. - void UnregisterOutputProtectionClient(OutputProtectionClientId client_id); + void UnregisterContentProtectionClient(ContentProtectionClientId client_id); // Queries link status and protection status. - // |link_mask| is the type of connected output links, which is a bitmask of - // OutputType values. |protection_mask| is the desired protection methods, - // which is a bitmask of the OutputProtectionMethod values. + // |link_mask| is the type of connected display links, which is a bitmask of + // DisplayConnectionType values. |protection_mask| is the desired protection + // methods, which is a bitmask of the ContentProtectionMethod values. // Returns true on success. - bool QueryOutputProtectionStatus(OutputProtectionClientId client_id, - int64_t display_id, - uint32_t* link_mask, - uint32_t* protection_mask); + bool QueryContentProtectionStatus(ContentProtectionClientId client_id, + int64_t display_id, + uint32_t* link_mask, + uint32_t* protection_mask); // Requests the desired protection methods. // |protection_mask| is the desired protection methods, which is a bitmask - // of the OutputProtectionMethod values. + // of the ContentProtectionMethod values. // Returns true when the protection request has been made. - bool EnableOutputProtection(OutputProtectionClientId client_id, - int64_t display_id, - uint32_t desired_protection_mask); + bool EnableContentProtection(ContentProtectionClientId client_id, + int64_t display_id, + uint32_t desired_protection_mask); // Checks the available color profiles for |display_id| and fills the result // into |profiles|. @@ -271,80 +272,82 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { private: // Mapping a display_id to a protection request bitmask. - typedef std::map DisplayProtections; + typedef std::map ContentProtections; // Mapping a client to its protection request. - typedef std::map + typedef std::map ProtectionRequests; - // Updates |cached_outputs_| to contain currently-connected outputs. Calls - // |delegate_->GetOutputs()| and then does additional work, like finding the + // Updates |cached_displays_| to contain currently-connected displays. Calls + // |delegate_->GetDisplays()| and then does additional work, like finding the // mirror mode and setting user-preferred modes. Note that the server must be // grabbed via |delegate_->GrabServer()| first. - void UpdateCachedOutputs(); + void UpdateCachedDisplays(); - // Helper method for UpdateCachedOutputs() that initializes the passed-in - // outputs' |mirror_mode| fields by looking for a mode in |internal_output| - // and |external_output| having the same resolution. Returns false if a shared + // Helper method for UpdateCachedDisplays() that initializes the passed-in + // displays' |mirror_mode| fields by looking for a mode in |internal_display| + // and |external_display| having the same resolution. Returns false if a + // shared // mode wasn't found or created. // // |try_panel_fitting| allows creating a panel-fitting mode for - // |internal_output| instead of only searching for a matching mode (note that + // |internal_display| instead of only searching for a matching mode (note that // it may lead to a crash if |internal_info| is not capable of panel fitting). // // |preserve_aspect| limits the search/creation only to the modes having the - // native aspect ratio of |external_output|. - bool FindMirrorMode(DisplayState* internal_output, - DisplayState* external_output, + // native aspect ratio of |external_display|. + bool FindMirrorMode(DisplayState* internal_display, + DisplayState* external_display, bool try_panel_fitting, bool preserve_aspect); - // Configures outputs. - void ConfigureOutputs(); + // Configures displays. + void ConfigureDisplays(); // Notifies observers about an attempted state change. - void NotifyObservers(bool success, OutputState attempted_state); + void NotifyObservers(bool success, MultipleDisplayState attempted_state); - // Switches to the state specified in |output_state| and |power_state|. + // Switches to the state specified in |display_state| and |power_state|. // If the hardware mirroring failed and |mirroring_controller_| is set, // it switches to |STATE_DUAL_EXTENDED| and calls |SetSoftwareMirroring()| // to enable software based mirroring. - // On success, updates |output_state_|, |power_state_|, and |cached_outputs_| - // and returns true. + // On success, updates |display_state_|, |power_state_|, and + // |cached_displays_| and returns true. bool EnterStateOrFallBackToSoftwareMirroring( - OutputState output_state, + MultipleDisplayState display_state, chromeos::DisplayPowerState power_state); - // Switches to the state specified in |output_state| and |power_state|. - // On success, updates |output_state_|, |power_state_|, and - // |cached_outputs_| and returns true. - bool EnterState(OutputState output_state, + // Switches to the state specified in |display_state| and |power_state|. + // On success, updates |display_state_|, |power_state_|, and + // |cached_displays_| and returns true. + bool EnterState(MultipleDisplayState display_state, chromeos::DisplayPowerState power_state); - // Returns the output state that should be used with |cached_outputs_| while + // Returns the display state that should be used with |cached_displays_| while // in |power_state|. - OutputState ChooseOutputState(chromeos::DisplayPowerState power_state) const; + MultipleDisplayState ChooseDisplayState( + chromeos::DisplayPowerState power_state) const; // Computes the relevant transformation for mirror mode. - // |output| is the output on which mirror mode is being applied. + // |display| is the display on which mirror mode is being applied. // Returns the transformation or identity if computations fail. - CoordinateTransformation GetMirrorModeCTM(const DisplayState& output); + CoordinateTransformation GetMirrorModeCTM(const DisplayState& display); - // Computes the relevant transformation for extended mode. |output| is the - // output on which extended mode is being applied. |new_origin| is the - // position of the output on the framebuffer. |framebuffer_size| is the + // Computes the relevant transformation for extended mode. |display| is the + // display on which extended mode is being applied. |new_origin| is the + // position of the display on the framebuffer. |framebuffer_size| is the // size of the combined framebuffer. // Returns the transformation or identity if computations fail. CoordinateTransformation GetExtendedModeCTM( - const DisplayState& output, + const DisplayState& display, const gfx::Point& new_origin, const gfx::Size& framebuffer_size); // Returns the ratio between mirrored mode area and native mode area: // (mirror_mode_width * mirrow_mode_height) / (native_width * native_height) - float GetMirroredDisplayAreaRatio(const DisplayState& output); + float GetMirroredDisplayAreaRatio(const DisplayState& display); - // Applies output protections according to requests. - bool ApplyProtections(const DisplayProtections& requests); + // Applies display protections according to requests. + bool ApplyProtections(const ContentProtections& requests); StateController* state_controller_; SoftwareMirroringController* mirroring_controller_; @@ -365,30 +368,30 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { // This is detected by the constructor to determine whether or not we should // be enabled. If we aren't running on ChromeOS, we can't assume that the // Xrandr X11 extension is supported. - // If this flag is set to false, any attempts to change the output + // If this flag is set to false, any attempts to change the display // configuration to immediately fail without changing the state. bool configure_display_; // The current display state. - OutputState output_state_; + MultipleDisplayState display_state_; // The current power state. chromeos::DisplayPowerState power_state_; - // Most-recently-used output configuration. Note that the actual + // Most-recently-used display configuration. Note that the actual // configuration changes asynchronously. - DisplayStateList cached_outputs_; + DisplayStateList cached_displays_; ObserverList observers_; - // The timer to delay configuring outputs. See also the comments in + // The timer to delay configuring displays. See also the comments in // Dispatch(). scoped_ptr > configure_timer_; - // Id for next output protection client. - OutputProtectionClientId next_output_protection_client_id_; + // Id for next display protection client. + ContentProtectionClientId next_display_protection_client_id_; - // Output protection requests of each client. + // Display protection requests of each client. ProtectionRequests client_protection_requests_; DISALLOW_COPY_AND_ASSIGN(DisplayConfigurator); diff --git a/ui/display/chromeos/display_configurator_unittest.cc b/ui/display/chromeos/display_configurator_unittest.cc index a3833c4b509258..f7b1182cb36a09 100644 --- a/ui/display/chromeos/display_configurator_unittest.cc +++ b/ui/display/chromeos/display_configurator_unittest.cc @@ -218,7 +218,7 @@ class TestNativeDisplayDelegate : public NativeDisplayDelegate { log_->AppendAction(GetBackgroundAction(color_argb)); } virtual void ForceDPMSOn() OVERRIDE { log_->AppendAction(kForceDPMS); } - virtual std::vector GetOutputs() OVERRIDE { + virtual std::vector GetDisplays() OVERRIDE { return outputs_; } virtual void AddMode(const DisplaySnapshot& output, @@ -272,7 +272,7 @@ class TestNativeDisplayDelegate : public NativeDisplayDelegate { virtual void RemoveObserver(NativeDisplayObserver* observer) OVERRIDE {} private: - // Outputs to be returned by GetOutputs(). + // Outputs to be returned by GetDisplays(). std::vector outputs_; // |max_configurable_pixels_| represents the maximum number of pixels that @@ -305,13 +305,15 @@ class TestObserver : public DisplayConfigurator::Observer { const DisplayConfigurator::DisplayStateList& latest_outputs() const { return latest_outputs_; } - OutputState latest_failed_state() const { return latest_failed_state_; } + MultipleDisplayState latest_failed_state() const { + return latest_failed_state_; + } void Reset() { num_changes_ = 0; num_failures_ = 0; latest_outputs_.clear(); - latest_failed_state_ = OUTPUT_STATE_INVALID; + latest_failed_state_ = MULTIPLE_DISPLAY_STATE_INVALID; } // DisplayConfigurator::Observer overrides: @@ -321,7 +323,7 @@ class TestObserver : public DisplayConfigurator::Observer { latest_outputs_ = outputs; } - virtual void OnDisplayModeChangeFailed(OutputState failed_new_state) + virtual void OnDisplayModeChangeFailed(MultipleDisplayState failed_new_state) OVERRIDE { num_failures_++; latest_failed_state_ = failed_new_state; @@ -336,20 +338,20 @@ class TestObserver : public DisplayConfigurator::Observer { // Parameters most recently passed to OnDisplayMode*(). DisplayConfigurator::DisplayStateList latest_outputs_; - OutputState latest_failed_state_; + MultipleDisplayState latest_failed_state_; DISALLOW_COPY_AND_ASSIGN(TestObserver); }; class TestStateController : public DisplayConfigurator::StateController { public: - TestStateController() : state_(OUTPUT_STATE_DUAL_EXTENDED) {} + TestStateController() : state_(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED) {} virtual ~TestStateController() {} - void set_state(OutputState state) { state_ = state; } + void set_state(MultipleDisplayState state) { state_ = state; } // DisplayConfigurator::StateController overrides: - virtual OutputState GetStateForDisplayIds( + virtual MultipleDisplayState GetStateForDisplayIds( const std::vector& outputs) const OVERRIDE { return state_; } @@ -359,7 +361,7 @@ class TestStateController : public DisplayConfigurator::StateController { } private: - OutputState state_; + MultipleDisplayState state_; DISALLOW_COPY_AND_ASSIGN(TestStateController); }; @@ -415,7 +417,7 @@ class DisplayConfiguratorTest : public testing::Test { o->set_current_mode(&small_mode_); o->set_native_mode(&small_mode_); o->set_modes(modes); - o->set_type(OUTPUT_TYPE_INTERNAL); + o->set_type(DISPLAY_CONNECTION_TYPE_INTERNAL); o->set_is_aspect_preserving_scaling(true); o->set_display_id(123); o->set_has_proper_display_id(true); @@ -425,7 +427,7 @@ class DisplayConfiguratorTest : public testing::Test { o->set_native_mode(&big_mode_); modes.push_back(&big_mode_); o->set_modes(modes); - o->set_type(OUTPUT_TYPE_HDMI); + o->set_type(DISPLAY_CONNECTION_TYPE_HDMI); o->set_is_aspect_preserving_scaling(true); o->set_display_id(456); o->set_has_proper_display_id(true); @@ -571,7 +573,7 @@ TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { // Connect a second output and check that the configurator enters // extended mode. observer_.Reset(); - state_controller_.set_state(OUTPUT_STATE_DUAL_EXTENDED); + state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); UpdateOutputs(2, true); const int kDualHeight = small_mode_.size().height() + DisplayConfigurator::kVerticalGap + @@ -596,7 +598,7 @@ TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { EXPECT_EQ(1, observer_.num_changes()); observer_.Reset(); - EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); + EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); EXPECT_EQ( JoinActions( kGrab, @@ -626,7 +628,7 @@ TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { // Get rid of shared modes to force software mirroring. outputs_[1].set_modes(std::vector(1, &big_mode_)); - state_controller_.set_state(OUTPUT_STATE_DUAL_EXTENDED); + state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); UpdateOutputs(2, true); EXPECT_EQ( JoinActions( @@ -647,24 +649,27 @@ TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); observer_.Reset(); - EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); + EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); - EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, + configurator_.display_state()); EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); EXPECT_EQ(1, observer_.num_changes()); - // Setting OUTPUT_STATE_DUAL_MIRROR should try to reconfigure. + // Setting MULTIPLE_DISPLAY_STATE_DUAL_MIRROR should try to reconfigure. observer_.Reset(); - EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_EXTENDED)); + EXPECT_TRUE( + configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED)); EXPECT_EQ(JoinActions(NULL), log_->GetActionsAndClear()); EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); EXPECT_EQ(1, observer_.num_changes()); // Set back to software mirror mode. observer_.Reset(); - EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); + EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); - EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, + configurator_.display_state()); EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); EXPECT_EQ(1, observer_.num_changes()); @@ -686,7 +691,7 @@ TEST_F(DisplayConfiguratorTest, ConnectSecondOutput) { TEST_F(DisplayConfiguratorTest, SetDisplayPower) { InitWithSingleOutput(); - state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); + state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); observer_.Reset(); UpdateOutputs(2, true); EXPECT_EQ( @@ -719,7 +724,7 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) { kUngrab, NULL), log_->GetActionsAndClear()); - EXPECT_EQ(OUTPUT_STATE_SINGLE, configurator_.output_state()); + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); EXPECT_EQ(1, observer_.num_changes()); // When all displays are turned off, the framebuffer should switch back @@ -736,7 +741,7 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) { kUngrab, NULL), log_->GetActionsAndClear()); - EXPECT_EQ(OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); EXPECT_EQ(1, observer_.num_changes()); @@ -755,13 +760,13 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) { kUngrab, NULL), log_->GetActionsAndClear()); - EXPECT_EQ(OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); EXPECT_EQ(1, observer_.num_changes()); // Get rid of shared modes to force software mirroring. outputs_[1].set_modes(std::vector(1, &big_mode_)); - state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); + state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); observer_.Reset(); UpdateOutputs(2, true); const int kDualHeight = small_mode_.size().height() + @@ -783,7 +788,8 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) { kUngrab, NULL), log_->GetActionsAndClear()); - EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, + configurator_.display_state()); EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); EXPECT_EQ(1, observer_.num_changes()); @@ -804,7 +810,7 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) { kUngrab, NULL), log_->GetActionsAndClear()); - EXPECT_EQ(OUTPUT_STATE_SINGLE, configurator_.output_state()); + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_SINGLE, configurator_.display_state()); EXPECT_FALSE(mirroring_controller_.software_mirroring_enabled()); EXPECT_EQ(1, observer_.num_changes()); @@ -829,7 +835,8 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) { kUngrab, NULL), log_->GetActionsAndClear()); - EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, + configurator_.display_state()); EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); EXPECT_EQ(1, observer_.num_changes()); @@ -854,7 +861,8 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) { kUngrab, NULL), log_->GetActionsAndClear()); - EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, + configurator_.display_state()); EXPECT_TRUE(mirroring_controller_.software_mirroring_enabled()); EXPECT_EQ(1, observer_.num_changes()); } @@ -916,7 +924,7 @@ TEST_F(DisplayConfiguratorTest, SuspendAndResume) { // If a second, external display is connected, the displays shouldn't be // powered back on before suspending. - state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); + state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); UpdateOutputs(2, true); EXPECT_EQ( JoinActions( @@ -1001,7 +1009,7 @@ TEST_F(DisplayConfiguratorTest, StartWithTwoOutputs) { configurator_.Init(false); EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); - state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); + state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); configurator_.ForceInitialConfigure(0); EXPECT_EQ( JoinActions( @@ -1017,69 +1025,75 @@ TEST_F(DisplayConfiguratorTest, StartWithTwoOutputs) { log_->GetActionsAndClear()); } -TEST_F(DisplayConfiguratorTest, InvalidOutputStates) { +TEST_F(DisplayConfiguratorTest, InvalidMultipleDisplayStates) { UpdateOutputs(0, false); EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); configurator_.Init(false); configurator_.ForceInitialConfigure(0); observer_.Reset(); - EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_HEADLESS)); - EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_SINGLE)); - EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); - EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_EXTENDED)); + EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_HEADLESS)); + EXPECT_FALSE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_SINGLE)); + EXPECT_FALSE( + configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); + EXPECT_FALSE( + configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED)); EXPECT_EQ(1, observer_.num_changes()); EXPECT_EQ(3, observer_.num_failures()); UpdateOutputs(1, true); observer_.Reset(); - EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_HEADLESS)); - EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_SINGLE)); - EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); - EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_EXTENDED)); + EXPECT_FALSE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_HEADLESS)); + EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_SINGLE)); + EXPECT_FALSE( + configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); + EXPECT_FALSE( + configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED)); EXPECT_EQ(1, observer_.num_changes()); EXPECT_EQ(3, observer_.num_failures()); - state_controller_.set_state(OUTPUT_STATE_DUAL_EXTENDED); + state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); UpdateOutputs(2, true); observer_.Reset(); - EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_HEADLESS)); - EXPECT_FALSE(configurator_.SetDisplayMode(OUTPUT_STATE_SINGLE)); - EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_MIRROR)); - EXPECT_TRUE(configurator_.SetDisplayMode(OUTPUT_STATE_DUAL_EXTENDED)); + EXPECT_FALSE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_HEADLESS)); + EXPECT_FALSE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_SINGLE)); + EXPECT_TRUE(configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)); + EXPECT_TRUE( + configurator_.SetDisplayMode(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED)); EXPECT_EQ(2, observer_.num_changes()); EXPECT_EQ(2, observer_.num_failures()); } -TEST_F(DisplayConfiguratorTest, GetOutputStateForDisplaysWithoutId) { +TEST_F(DisplayConfiguratorTest, GetMultipleDisplayStateForDisplaysWithoutId) { outputs_[0].set_has_proper_display_id(false); UpdateOutputs(2, false); configurator_.Init(false); - state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); + state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); configurator_.ForceInitialConfigure(0); - EXPECT_EQ(OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, + configurator_.display_state()); } -TEST_F(DisplayConfiguratorTest, GetOutputStateForDisplaysWithId) { +TEST_F(DisplayConfiguratorTest, GetMultipleDisplayStateForDisplaysWithId) { outputs_[0].set_has_proper_display_id(true); UpdateOutputs(2, false); configurator_.Init(false); - state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); + state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); configurator_.ForceInitialConfigure(0); - EXPECT_EQ(OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); } TEST_F(DisplayConfiguratorTest, UpdateCachedOutputsEvenAfterFailure) { InitWithSingleOutput(); const DisplayConfigurator::DisplayStateList* cached = - &configurator_.cached_outputs(); + &configurator_.cached_displays(); ASSERT_EQ(static_cast(1), cached->size()); EXPECT_EQ(outputs_[0].current_mode(), (*cached)[0].display->current_mode()); // After connecting a second output, check that it shows up in - // |cached_outputs_| even if an invalid state is requested. - state_controller_.set_state(OUTPUT_STATE_SINGLE); + // |cached_displays_| even if an invalid state is requested. + state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); UpdateOutputs(2, true); - cached = &configurator_.cached_outputs(); + cached = &configurator_.cached_displays(); ASSERT_EQ(static_cast(2), cached->size()); EXPECT_EQ(outputs_[0].current_mode(), (*cached)[0].display->current_mode()); EXPECT_EQ(outputs_[1].current_mode(), (*cached)[1].display->current_mode()); @@ -1099,10 +1113,10 @@ TEST_F(DisplayConfiguratorTest, PanelFitting) { // The small mode should be added to the internal output when requesting // mirrored mode. UpdateOutputs(2, false); - state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); + state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); configurator_.Init(true /* is_panel_fitting_enabled */); configurator_.ForceInitialConfigure(0); - EXPECT_EQ(OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); + EXPECT_EQ(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, configurator_.display_state()); EXPECT_EQ( JoinActions( kGrab, @@ -1137,13 +1151,13 @@ TEST_F(DisplayConfiguratorTest, PanelFitting) { &small_mode_)); } -TEST_F(DisplayConfiguratorTest, OutputProtection) { +TEST_F(DisplayConfiguratorTest, ContentProtection) { configurator_.Init(false); configurator_.ForceInitialConfigure(0); EXPECT_NE(kNoActions, log_->GetActionsAndClear()); - DisplayConfigurator::OutputProtectionClientId id = - configurator_.RegisterOutputProtectionClient(); + DisplayConfigurator::ContentProtectionClientId id = + configurator_.RegisterContentProtectionClient(); EXPECT_NE(0u, id); // One output. @@ -1151,48 +1165,48 @@ TEST_F(DisplayConfiguratorTest, OutputProtection) { EXPECT_NE(kNoActions, log_->GetActionsAndClear()); uint32_t link_mask = 0; uint32_t protection_mask = 0; - EXPECT_TRUE(configurator_.QueryOutputProtectionStatus( + EXPECT_TRUE(configurator_.QueryContentProtectionStatus( id, outputs_[0].display_id(), &link_mask, &protection_mask)); - EXPECT_EQ(static_cast(OUTPUT_TYPE_INTERNAL), link_mask); - EXPECT_EQ(static_cast(OUTPUT_PROTECTION_METHOD_NONE), + EXPECT_EQ(static_cast(DISPLAY_CONNECTION_TYPE_INTERNAL), link_mask); + EXPECT_EQ(static_cast(CONTENT_PROTECTION_METHOD_NONE), protection_mask); EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); // Two outputs. UpdateOutputs(2, true); EXPECT_NE(kNoActions, log_->GetActionsAndClear()); - EXPECT_TRUE(configurator_.QueryOutputProtectionStatus( + EXPECT_TRUE(configurator_.QueryContentProtectionStatus( id, outputs_[1].display_id(), &link_mask, &protection_mask)); - EXPECT_EQ(static_cast(OUTPUT_TYPE_HDMI), link_mask); - EXPECT_EQ(static_cast(OUTPUT_PROTECTION_METHOD_NONE), + EXPECT_EQ(static_cast(DISPLAY_CONNECTION_TYPE_HDMI), link_mask); + EXPECT_EQ(static_cast(CONTENT_PROTECTION_METHOD_NONE), protection_mask); EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); - EXPECT_TRUE(configurator_.EnableOutputProtection( - id, outputs_[1].display_id(), OUTPUT_PROTECTION_METHOD_HDCP)); + EXPECT_TRUE(configurator_.EnableContentProtection( + id, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_HDCP)); EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_DESIRED), log_->GetActionsAndClear()); // Enable protection. native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); - EXPECT_TRUE(configurator_.QueryOutputProtectionStatus( + EXPECT_TRUE(configurator_.QueryContentProtectionStatus( id, outputs_[1].display_id(), &link_mask, &protection_mask)); - EXPECT_EQ(static_cast(OUTPUT_TYPE_HDMI), link_mask); - EXPECT_EQ(static_cast(OUTPUT_PROTECTION_METHOD_HDCP), + EXPECT_EQ(static_cast(DISPLAY_CONNECTION_TYPE_HDMI), link_mask); + EXPECT_EQ(static_cast(CONTENT_PROTECTION_METHOD_HDCP), protection_mask); EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); // Protections should be disabled after unregister. - configurator_.UnregisterOutputProtectionClient(id); + configurator_.UnregisterContentProtectionClient(id); EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_UNDESIRED), log_->GetActionsAndClear()); } -TEST_F(DisplayConfiguratorTest, OutputProtectionTwoClients) { - DisplayConfigurator::OutputProtectionClientId client1 = - configurator_.RegisterOutputProtectionClient(); - DisplayConfigurator::OutputProtectionClientId client2 = - configurator_.RegisterOutputProtectionClient(); +TEST_F(DisplayConfiguratorTest, ContentProtectionTwoClients) { + DisplayConfigurator::ContentProtectionClientId client1 = + configurator_.RegisterContentProtectionClient(); + DisplayConfigurator::ContentProtectionClientId client2 = + configurator_.RegisterContentProtectionClient(); EXPECT_NE(client1, client2); configurator_.Init(false); @@ -1201,31 +1215,31 @@ TEST_F(DisplayConfiguratorTest, OutputProtectionTwoClients) { EXPECT_NE(kNoActions, log_->GetActionsAndClear()); // Clients never know state enableness for methods that they didn't request. - EXPECT_TRUE(configurator_.EnableOutputProtection( - client1, outputs_[1].display_id(), OUTPUT_PROTECTION_METHOD_HDCP)); + EXPECT_TRUE(configurator_.EnableContentProtection( + client1, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_HDCP)); EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_DESIRED).c_str(), log_->GetActionsAndClear()); native_display_delegate_->set_hdcp_state(HDCP_STATE_ENABLED); uint32_t link_mask = 0; uint32_t protection_mask = 0; - EXPECT_TRUE(configurator_.QueryOutputProtectionStatus( + EXPECT_TRUE(configurator_.QueryContentProtectionStatus( client1, outputs_[1].display_id(), &link_mask, &protection_mask)); - EXPECT_EQ(static_cast(OUTPUT_TYPE_HDMI), link_mask); - EXPECT_EQ(OUTPUT_PROTECTION_METHOD_HDCP, protection_mask); + EXPECT_EQ(static_cast(DISPLAY_CONNECTION_TYPE_HDMI), link_mask); + EXPECT_EQ(CONTENT_PROTECTION_METHOD_HDCP, protection_mask); - EXPECT_TRUE(configurator_.QueryOutputProtectionStatus( + EXPECT_TRUE(configurator_.QueryContentProtectionStatus( client2, outputs_[1].display_id(), &link_mask, &protection_mask)); - EXPECT_EQ(static_cast(OUTPUT_TYPE_HDMI), link_mask); - EXPECT_EQ(OUTPUT_PROTECTION_METHOD_NONE, protection_mask); + EXPECT_EQ(static_cast(DISPLAY_CONNECTION_TYPE_HDMI), link_mask); + EXPECT_EQ(CONTENT_PROTECTION_METHOD_NONE, protection_mask); // Protections will be disabled only if no more clients request them. - EXPECT_TRUE(configurator_.EnableOutputProtection( - client2, outputs_[1].display_id(), OUTPUT_PROTECTION_METHOD_NONE)); + EXPECT_TRUE(configurator_.EnableContentProtection( + client2, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_NONE)); EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_DESIRED).c_str(), log_->GetActionsAndClear()); - EXPECT_TRUE(configurator_.EnableOutputProtection( - client1, outputs_[1].display_id(), OUTPUT_PROTECTION_METHOD_NONE)); + EXPECT_TRUE(configurator_.EnableContentProtection( + client1, outputs_[1].display_id(), CONTENT_PROTECTION_METHOD_NONE)); EXPECT_EQ(GetSetHDCPStateAction(outputs_[1], HDCP_STATE_UNDESIRED).c_str(), log_->GetActionsAndClear()); } @@ -1234,7 +1248,7 @@ TEST_F(DisplayConfiguratorTest, CTMForMultiScreens) { touchscreen_delegate_->set_configure_touchscreens(true); UpdateOutputs(2, false); configurator_.Init(false); - state_controller_.set_state(OUTPUT_STATE_DUAL_EXTENDED); + state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED); configurator_.ForceInitialConfigure(0); const int kDualHeight = small_mode_.size().height() + @@ -1286,12 +1300,12 @@ TEST_F(DisplayConfiguratorTest, HandleConfigureCrtcFailure) { configurator_.Init(false); - // First test simply fails in OUTPUT_STATE_SINGLE mode. This is probably - // unrealistic but the want to make sure any assumptions don't - // creep in. + // First test simply fails in MULTIPLE_DISPLAY_STATE_SINGLE mode. This is + // probably unrealistic but we want to make sure any assumptions don't creep + // in. native_display_delegate_->set_max_configurable_pixels( modes[2]->size().GetArea()); - state_controller_.set_state(OUTPUT_STATE_SINGLE); + state_controller_.set_state(MULTIPLE_DISPLAY_STATE_SINGLE); UpdateOutputs(1, true); EXPECT_EQ( @@ -1309,7 +1323,7 @@ TEST_F(DisplayConfiguratorTest, HandleConfigureCrtcFailure) { // and should end up in extended mode. native_display_delegate_->set_max_configurable_pixels( modes[3]->size().GetArea()); - state_controller_.set_state(OUTPUT_STATE_DUAL_MIRROR); + state_controller_.set_state(MULTIPLE_DISPLAY_STATE_DUAL_MIRROR); UpdateOutputs(2, true); EXPECT_EQ( diff --git a/ui/display/chromeos/display_snapshot.cc b/ui/display/chromeos/display_snapshot.cc index 8f9eb15543b17a..da2827ad81db95 100644 --- a/ui/display/chromeos/display_snapshot.cc +++ b/ui/display/chromeos/display_snapshot.cc @@ -10,7 +10,7 @@ DisplaySnapshot::DisplaySnapshot(int64_t display_id, bool has_proper_display_id, const gfx::Point& origin, const gfx::Size& physical_size, - OutputType type, + DisplayConnectionType type, bool is_aspect_preserving_scaling, bool has_overscan, std::string display_name, diff --git a/ui/display/chromeos/display_snapshot.h b/ui/display/chromeos/display_snapshot.h index e2d7ea73bd9760..68d73e82d0f601 100644 --- a/ui/display/chromeos/display_snapshot.h +++ b/ui/display/chromeos/display_snapshot.h @@ -24,7 +24,7 @@ class DISPLAY_EXPORT DisplaySnapshot { bool has_proper_display_id, const gfx::Point& origin, const gfx::Size& physical_size, - OutputType type, + DisplayConnectionType type, bool is_aspect_preserving_scaling, bool has_overscan, std::string display_name, @@ -35,7 +35,7 @@ class DISPLAY_EXPORT DisplaySnapshot { const gfx::Point& origin() const { return origin_; } const gfx::Size& physical_size() const { return physical_size_; } - ui::OutputType type() const { return type_; } + ui::DisplayConnectionType type() const { return type_; } bool is_aspect_preserving_scaling() const { return is_aspect_preserving_scaling_; } @@ -62,12 +62,12 @@ class DISPLAY_EXPORT DisplaySnapshot { int64_t display_id_; bool has_proper_display_id_; - // Output's origin on the framebuffer. + // Display's origin on the framebuffer. gfx::Point origin_; gfx::Size physical_size_; - OutputType type_; + DisplayConnectionType type_; bool is_aspect_preserving_scaling_; diff --git a/ui/display/chromeos/native_display_delegate.h b/ui/display/chromeos/native_display_delegate.h index f20eca075c8189..5532607a43ee0a 100644 --- a/ui/display/chromeos/native_display_delegate.h +++ b/ui/display/chromeos/native_display_delegate.h @@ -51,7 +51,7 @@ class DISPLAY_EXPORT NativeDisplayDelegate { // 60 milliseconds or more. // NativeDisplayDelegate maintains ownership of the ui::DisplaySnapshot // pointers. - virtual std::vector GetOutputs() = 0; + virtual std::vector GetDisplays() = 0; // Adds |mode| to |output|. |mode| must be a valid display mode pointer. virtual void AddMode(const ui::DisplaySnapshot& output, diff --git a/ui/display/chromeos/ozone/native_display_delegate_ozone.cc b/ui/display/chromeos/ozone/native_display_delegate_ozone.cc index f9dc6785309715..8f5517f6272b94 100644 --- a/ui/display/chromeos/ozone/native_display_delegate_ozone.cc +++ b/ui/display/chromeos/ozone/native_display_delegate_ozone.cc @@ -36,7 +36,7 @@ void NativeDisplayDelegateOzone::ForceDPMSOn() { NOTIMPLEMENTED(); } -std::vector NativeDisplayDelegateOzone::GetOutputs() { +std::vector NativeDisplayDelegateOzone::GetDisplays() { NOTIMPLEMENTED(); return std::vector(); } diff --git a/ui/display/chromeos/ozone/native_display_delegate_ozone.h b/ui/display/chromeos/ozone/native_display_delegate_ozone.h index 1519b852c72119..cb0117186e9e6f 100644 --- a/ui/display/chromeos/ozone/native_display_delegate_ozone.h +++ b/ui/display/chromeos/ozone/native_display_delegate_ozone.h @@ -22,7 +22,7 @@ class NativeDisplayDelegateOzone : public NativeDisplayDelegate { virtual void SyncWithServer() OVERRIDE; virtual void SetBackgroundColor(uint32_t color_argb) OVERRIDE; virtual void ForceDPMSOn() OVERRIDE; - virtual std::vector GetOutputs() OVERRIDE; + virtual std::vector GetDisplays() OVERRIDE; virtual void AddMode(const ui::DisplaySnapshot& output, const ui::DisplayMode* mode) OVERRIDE; virtual bool Configure(const ui::DisplaySnapshot& output, diff --git a/ui/display/chromeos/test/test_display_snapshot.cc b/ui/display/chromeos/test/test_display_snapshot.cc index e9797ddbd9aefd..b7eba9add57155 100644 --- a/ui/display/chromeos/test/test_display_snapshot.cc +++ b/ui/display/chromeos/test/test_display_snapshot.cc @@ -10,7 +10,7 @@ TestDisplaySnapshot::TestDisplaySnapshot() false, gfx::Point(0, 0), gfx::Size(0, 0), - OUTPUT_TYPE_UNKNOWN, + DISPLAY_CONNECTION_TYPE_UNKNOWN, false, false, std::string(), @@ -23,7 +23,7 @@ TestDisplaySnapshot::TestDisplaySnapshot( bool has_proper_display_id, const gfx::Point& origin, const gfx::Size& physical_size, - OutputType type, + DisplayConnectionType type, bool is_aspect_preserving_scaling, const std::vector& modes, const DisplayMode* current_mode, diff --git a/ui/display/chromeos/test/test_display_snapshot.h b/ui/display/chromeos/test/test_display_snapshot.h index adc1c41613aeda..cac793888849da 100644 --- a/ui/display/chromeos/test/test_display_snapshot.h +++ b/ui/display/chromeos/test/test_display_snapshot.h @@ -16,14 +16,14 @@ class DISPLAY_EXPORT TestDisplaySnapshot : public DisplaySnapshot { bool has_proper_display_id, const gfx::Point& origin, const gfx::Size& physical_size, - OutputType type, + DisplayConnectionType type, bool is_aspect_preserving_scaling, const std::vector& modes, const DisplayMode* current_mode, const DisplayMode* native_mode); virtual ~TestDisplaySnapshot(); - void set_type(OutputType type) { type_ = type; } + void set_type(DisplayConnectionType type) { type_ = type; } void set_modes(const std::vector& modes) { modes_ = modes; } diff --git a/ui/display/chromeos/x11/display_snapshot_x11.cc b/ui/display/chromeos/x11/display_snapshot_x11.cc index ee28d58a55b4e0..52c4ba78b60dd7 100644 --- a/ui/display/chromeos/x11/display_snapshot_x11.cc +++ b/ui/display/chromeos/x11/display_snapshot_x11.cc @@ -14,7 +14,7 @@ DisplaySnapshotX11::DisplaySnapshotX11( bool has_proper_display_id, const gfx::Point& origin, const gfx::Size& physical_size, - OutputType type, + DisplayConnectionType type, bool is_aspect_preserving_scaling, bool has_overscan, std::string display_name, diff --git a/ui/display/chromeos/x11/display_snapshot_x11.h b/ui/display/chromeos/x11/display_snapshot_x11.h index 178ff0d930a384..1f55d14a577907 100644 --- a/ui/display/chromeos/x11/display_snapshot_x11.h +++ b/ui/display/chromeos/x11/display_snapshot_x11.h @@ -20,7 +20,7 @@ class DISPLAY_EXPORT DisplaySnapshotX11 : public DisplaySnapshot { bool has_proper_display_id, const gfx::Point& origin, const gfx::Size& physical_size, - OutputType type, + DisplayConnectionType type, bool is_aspect_preserving_scaling, bool has_overscan, std::string display_name, diff --git a/ui/display/chromeos/x11/display_util_x11.cc b/ui/display/chromeos/x11/display_util_x11.cc index f5a4f2701e54f6..560edd08e29b4b 100644 --- a/ui/display/chromeos/x11/display_util_x11.cc +++ b/ui/display/chromeos/x11/display_util_x11.cc @@ -10,32 +10,32 @@ namespace ui { namespace { -struct OutputTypeMapping { +struct DisplayConnectionTypeMapping { // Prefix of output name. const char* name; - OutputType type; + DisplayConnectionType type; }; -const OutputTypeMapping kOutputTypeMapping[] = { - {"LVDS", OUTPUT_TYPE_INTERNAL}, - {"eDP", OUTPUT_TYPE_INTERNAL}, - {"DSI", OUTPUT_TYPE_INTERNAL}, - {"VGA", OUTPUT_TYPE_VGA}, - {"HDMI", OUTPUT_TYPE_HDMI}, - {"DVI", OUTPUT_TYPE_DVI}, - {"DP", OUTPUT_TYPE_DISPLAYPORT} -}; +const DisplayConnectionTypeMapping kDisplayConnectionTypeMapping[] = { + {"LVDS", DISPLAY_CONNECTION_TYPE_INTERNAL}, + {"eDP", DISPLAY_CONNECTION_TYPE_INTERNAL}, + {"DSI", DISPLAY_CONNECTION_TYPE_INTERNAL}, + {"VGA", DISPLAY_CONNECTION_TYPE_VGA}, + {"HDMI", DISPLAY_CONNECTION_TYPE_HDMI}, + {"DVI", DISPLAY_CONNECTION_TYPE_DVI}, + {"DP", DISPLAY_CONNECTION_TYPE_DISPLAYPORT}}; } // namespace -OutputType GetOutputTypeFromName(const std::string& name) { - for (unsigned int i = 0; i < arraysize(kOutputTypeMapping); ++i) { - if (name.find(kOutputTypeMapping[i].name) == 0) { - return kOutputTypeMapping[i].type; +DisplayConnectionType GetDisplayConnectionTypeFromName( + const std::string& name) { + for (unsigned int i = 0; i < arraysize(kDisplayConnectionTypeMapping); ++i) { + if (name.find(kDisplayConnectionTypeMapping[i].name) == 0) { + return kDisplayConnectionTypeMapping[i].type; } } - return OUTPUT_TYPE_UNKNOWN; + return DISPLAY_CONNECTION_TYPE_UNKNOWN; } } // namespace ui diff --git a/ui/display/chromeos/x11/display_util_x11.h b/ui/display/chromeos/x11/display_util_x11.h index c8a783710b2591..894d8559f82c1e 100644 --- a/ui/display/chromeos/x11/display_util_x11.h +++ b/ui/display/chromeos/x11/display_util_x11.h @@ -15,9 +15,10 @@ typedef XID RROutput; namespace ui { -// Returns the OutputType by matching known type prefixes to |name|. Returns -// OUTPUT_TYPE_UNKNOWN if no valid match. -DISPLAY_EXPORT OutputType GetOutputTypeFromName(const std::string& name); +// Returns the DisplayConnectionType by matching known type prefixes to |name|. +// Returns DISPLAY_TYPE_UNKNOWN if no valid match. +DISPLAY_EXPORT DisplayConnectionType + GetDisplayConnectionTypeFromName(const std::string& name); } // namespace ui diff --git a/ui/display/chromeos/x11/display_util_x11_unittest.cc b/ui/display/chromeos/x11/display_util_x11_unittest.cc index e178f7fb5ed132..5c13024ce3ecfd 100644 --- a/ui/display/chromeos/x11/display_util_x11_unittest.cc +++ b/ui/display/chromeos/x11/display_util_x11_unittest.cc @@ -9,34 +9,59 @@ namespace ui { -TEST(DisplayUtilX11Test, GetOutputTypeFromName) { - EXPECT_EQ(OUTPUT_TYPE_INTERNAL, GetOutputTypeFromName("LVDS")); - EXPECT_EQ(OUTPUT_TYPE_INTERNAL, GetOutputTypeFromName("eDP")); - EXPECT_EQ(OUTPUT_TYPE_INTERNAL, GetOutputTypeFromName("DSI")); - EXPECT_EQ(OUTPUT_TYPE_INTERNAL, GetOutputTypeFromName("LVDSxx")); - EXPECT_EQ(OUTPUT_TYPE_INTERNAL, GetOutputTypeFromName("eDPzz")); - EXPECT_EQ(OUTPUT_TYPE_INTERNAL, GetOutputTypeFromName("DSIyy")); +TEST(DisplayUtilX11Test, GetDisplayConnectionTypeFromName) { + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_INTERNAL, + GetDisplayConnectionTypeFromName("LVDS")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_INTERNAL, + GetDisplayConnectionTypeFromName("eDP")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_INTERNAL, + GetDisplayConnectionTypeFromName("DSI")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_INTERNAL, + GetDisplayConnectionTypeFromName("LVDSxx")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_INTERNAL, + GetDisplayConnectionTypeFromName("eDPzz")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_INTERNAL, + GetDisplayConnectionTypeFromName("DSIyy")); - EXPECT_EQ(OUTPUT_TYPE_VGA, GetOutputTypeFromName("VGA")); - EXPECT_EQ(OUTPUT_TYPE_VGA, GetOutputTypeFromName("VGAxx")); - EXPECT_EQ(OUTPUT_TYPE_HDMI, GetOutputTypeFromName("HDMI")); - EXPECT_EQ(OUTPUT_TYPE_HDMI, GetOutputTypeFromName("HDMIyy")); - EXPECT_EQ(OUTPUT_TYPE_DVI, GetOutputTypeFromName("DVI")); - EXPECT_EQ(OUTPUT_TYPE_DVI, GetOutputTypeFromName("DVIzz")); - EXPECT_EQ(OUTPUT_TYPE_DISPLAYPORT, GetOutputTypeFromName("DP")); - EXPECT_EQ(OUTPUT_TYPE_DISPLAYPORT, GetOutputTypeFromName("DPww")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_VGA, + GetDisplayConnectionTypeFromName("VGA")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_VGA, + GetDisplayConnectionTypeFromName("VGAxx")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_HDMI, + GetDisplayConnectionTypeFromName("HDMI")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_HDMI, + GetDisplayConnectionTypeFromName("HDMIyy")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_DVI, + GetDisplayConnectionTypeFromName("DVI")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_DVI, + GetDisplayConnectionTypeFromName("DVIzz")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_DISPLAYPORT, + GetDisplayConnectionTypeFromName("DP")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_DISPLAYPORT, + GetDisplayConnectionTypeFromName("DPww")); - EXPECT_EQ(OUTPUT_TYPE_UNKNOWN, GetOutputTypeFromName("xyz")); - EXPECT_EQ(OUTPUT_TYPE_UNKNOWN, GetOutputTypeFromName("abcLVDS")); - EXPECT_EQ(OUTPUT_TYPE_UNKNOWN, GetOutputTypeFromName("cdeeDP")); - EXPECT_EQ(OUTPUT_TYPE_UNKNOWN, GetOutputTypeFromName("abcDSI")); - EXPECT_EQ(OUTPUT_TYPE_UNKNOWN, GetOutputTypeFromName("LVD")); - EXPECT_EQ(OUTPUT_TYPE_UNKNOWN, GetOutputTypeFromName("eD")); - EXPECT_EQ(OUTPUT_TYPE_UNKNOWN, GetOutputTypeFromName("DS")); - EXPECT_EQ(OUTPUT_TYPE_UNKNOWN, GetOutputTypeFromName("VG")); - EXPECT_EQ(OUTPUT_TYPE_UNKNOWN, GetOutputTypeFromName("HDM")); - EXPECT_EQ(OUTPUT_TYPE_UNKNOWN, GetOutputTypeFromName("DV")); - EXPECT_EQ(OUTPUT_TYPE_UNKNOWN, GetOutputTypeFromName("D")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_UNKNOWN, + GetDisplayConnectionTypeFromName("xyz")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_UNKNOWN, + GetDisplayConnectionTypeFromName("abcLVDS")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_UNKNOWN, + GetDisplayConnectionTypeFromName("cdeeDP")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_UNKNOWN, + GetDisplayConnectionTypeFromName("abcDSI")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_UNKNOWN, + GetDisplayConnectionTypeFromName("LVD")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_UNKNOWN, + GetDisplayConnectionTypeFromName("eD")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_UNKNOWN, + GetDisplayConnectionTypeFromName("DS")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_UNKNOWN, + GetDisplayConnectionTypeFromName("VG")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_UNKNOWN, + GetDisplayConnectionTypeFromName("HDM")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_UNKNOWN, + GetDisplayConnectionTypeFromName("DV")); + EXPECT_EQ(DISPLAY_CONNECTION_TYPE_UNKNOWN, + GetDisplayConnectionTypeFromName("D")); } } // namespace ui diff --git a/ui/display/chromeos/x11/native_display_delegate_x11.cc b/ui/display/chromeos/x11/native_display_delegate_x11.cc index 0703fc76e4ccdb..d7467430f6d1dd 100644 --- a/ui/display/chromeos/x11/native_display_delegate_x11.cc +++ b/ui/display/chromeos/x11/native_display_delegate_x11.cc @@ -86,7 +86,7 @@ class NativeDisplayDelegateX11::HelperDelegateX11 OVERRIDE { XRRUpdateConfiguration(event); } - virtual const std::vector& GetCachedOutputs() const + virtual const std::vector& GetCachedDisplays() const OVERRIDE { return delegate_->cached_outputs_.get(); } @@ -220,7 +220,7 @@ void NativeDisplayDelegateX11::ForceDPMSOn() { CHECK(DPMSForceLevel(display_, DPMSModeOn)); } -std::vector NativeDisplayDelegateX11::GetOutputs() { +std::vector NativeDisplayDelegateX11::GetDisplays() { CHECK(screen_) << "Server not grabbed"; cached_outputs_.clear(); @@ -250,7 +250,7 @@ void NativeDisplayDelegateX11::AddMode(const DisplaySnapshot& output, static_cast(output); RRMode mode_id = static_cast(mode)->mode_id(); - VLOG(1) << "AddOutputMode: output=" << x11_output.output() + VLOG(1) << "AddDisplayMode: output=" << x11_output.output() << " mode=" << mode_id; XRRAddOutputMode(display_, x11_output.output(), mode_id); } @@ -350,15 +350,15 @@ DisplaySnapshotX11* NativeDisplayDelegateX11::InitDisplaySnapshot( bool has_overscan = false; GetOutputOverscanFlag(id, &has_overscan); - OutputType type = GetOutputTypeFromName(info->name); - if (type == OUTPUT_TYPE_UNKNOWN) + DisplayConnectionType type = GetDisplayConnectionTypeFromName(info->name); + if (type == DISPLAY_CONNECTION_TYPE_UNKNOWN) LOG(ERROR) << "Unknown link type: " << info->name; // Use the index as a valid display ID even if the internal // display doesn't have valid EDID because the index // will never change. if (!has_display_id) { - if (type == OUTPUT_TYPE_INTERNAL) + if (type == DISPLAY_CONNECTION_TYPE_INTERNAL) has_display_id = true; // Fallback to output index. diff --git a/ui/display/chromeos/x11/native_display_delegate_x11.h b/ui/display/chromeos/x11/native_display_delegate_x11.h index 1d2cf107335e27..355a03867744df 100644 --- a/ui/display/chromeos/x11/native_display_delegate_x11.h +++ b/ui/display/chromeos/x11/native_display_delegate_x11.h @@ -57,7 +57,7 @@ class DISPLAY_EXPORT NativeDisplayDelegateX11 : public NativeDisplayDelegate { // Returns the list of current outputs. This is used to discard duplicate // events. - virtual const std::vector& GetCachedOutputs() const = 0; + virtual const std::vector& GetCachedDisplays() const = 0; // Notify |observers_| that a change in configuration has occurred. virtual void NotifyDisplayObservers() = 0; @@ -73,7 +73,7 @@ class DISPLAY_EXPORT NativeDisplayDelegateX11 : public NativeDisplayDelegate { virtual void SyncWithServer() OVERRIDE; virtual void SetBackgroundColor(uint32_t color_argb) OVERRIDE; virtual void ForceDPMSOn() OVERRIDE; - virtual std::vector GetOutputs() OVERRIDE; + virtual std::vector GetDisplays() OVERRIDE; virtual void AddMode(const DisplaySnapshot& output, const DisplayMode* mode) OVERRIDE; virtual bool Configure(const DisplaySnapshot& output, diff --git a/ui/display/chromeos/x11/native_display_event_dispatcher_x11.cc b/ui/display/chromeos/x11/native_display_event_dispatcher_x11.cc index d42f5619ccbd3b..f5c2e2e929839f 100644 --- a/ui/display/chromeos/x11/native_display_event_dispatcher_x11.cc +++ b/ui/display/chromeos/x11/native_display_event_dispatcher_x11.cc @@ -66,7 +66,7 @@ uint32_t NativeDisplayEventDispatcherX11::DispatchEvent( if (check_cache) { bool found_changed_output = false; const std::vector& cached_outputs = - delegate_->GetCachedOutputs(); + delegate_->GetCachedDisplays(); for (std::vector::const_iterator it = cached_outputs.begin(); it != cached_outputs.end(); diff --git a/ui/display/chromeos/x11/native_display_event_dispatcher_x11_unittest.cc b/ui/display/chromeos/x11/native_display_event_dispatcher_x11_unittest.cc index d5cd5b17706dcf..d7cf58926408b9 100644 --- a/ui/display/chromeos/x11/native_display_event_dispatcher_x11_unittest.cc +++ b/ui/display/chromeos/x11/native_display_event_dispatcher_x11_unittest.cc @@ -27,7 +27,7 @@ DisplaySnapshotX11* CreateOutput(RROutput output, RRCrtc crtc) { false, gfx::Point(0, 0), gfx::Size(0, 0), - OUTPUT_TYPE_UNKNOWN, + DISPLAY_CONNECTION_TYPE_UNKNOWN, false, false, std::string(), @@ -59,7 +59,7 @@ class TestHelperDelegate : public NativeDisplayDelegateX11::HelperDelegate { // NativeDisplayDelegateX11::HelperDelegate overrides: virtual void UpdateXRandRConfiguration(const base::NativeEvent& event) OVERRIDE; - virtual const std::vector& GetCachedOutputs() const + virtual const std::vector& GetCachedDisplays() const OVERRIDE; virtual void NotifyDisplayObservers() OVERRIDE; @@ -82,7 +82,7 @@ void TestHelperDelegate::UpdateXRandRConfiguration( ++num_calls_update_xrandr_config_; } -const std::vector& TestHelperDelegate::GetCachedOutputs() +const std::vector& TestHelperDelegate::GetCachedDisplays() const { return cached_outputs_; } diff --git a/ui/display/chromeos/x11/touchscreen_delegate_x11.cc b/ui/display/chromeos/x11/touchscreen_delegate_x11.cc index 3e59d88b4a21dc..6299023af97ef8 100644 --- a/ui/display/chromeos/x11/touchscreen_delegate_x11.cc +++ b/ui/display/chromeos/x11/touchscreen_delegate_x11.cc @@ -115,7 +115,7 @@ void TouchscreenDelegateX11::AssociateTouchscreens( it != no_match_touchscreen.end(); it++) { for (size_t i = 0; i < outputs->size(); i++) { - if ((*outputs)[i].display->type() != OUTPUT_TYPE_INTERNAL && + if ((*outputs)[i].display->type() != DISPLAY_CONNECTION_TYPE_INTERNAL && (*outputs)[i].display->native_mode() != NULL && (*outputs)[i].touch_device_id == None) { (*outputs)[i].touch_device_id = *it; diff --git a/ui/display/display_constants.h b/ui/display/display_constants.h index 7ad266495bd3e8..b721fc76e0c72e 100644 --- a/ui/display/display_constants.h +++ b/ui/display/display_constants.h @@ -8,30 +8,30 @@ namespace ui { // Used to describe the state of a multi-display configuration. -enum OutputState { - OUTPUT_STATE_INVALID, - OUTPUT_STATE_HEADLESS, - OUTPUT_STATE_SINGLE, - OUTPUT_STATE_DUAL_MIRROR, - OUTPUT_STATE_DUAL_EXTENDED, +enum MultipleDisplayState { + MULTIPLE_DISPLAY_STATE_INVALID, + MULTIPLE_DISPLAY_STATE_HEADLESS, + MULTIPLE_DISPLAY_STATE_SINGLE, + MULTIPLE_DISPLAY_STATE_DUAL_MIRROR, + MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED, }; // Video output types. -enum OutputType { - OUTPUT_TYPE_NONE = 0, - OUTPUT_TYPE_UNKNOWN = 1 << 0, - OUTPUT_TYPE_INTERNAL = 1 << 1, - OUTPUT_TYPE_VGA = 1 << 2, - OUTPUT_TYPE_HDMI = 1 << 3, - OUTPUT_TYPE_DVI = 1 << 4, - OUTPUT_TYPE_DISPLAYPORT = 1 << 5, - OUTPUT_TYPE_NETWORK = 1 << 6, +enum DisplayConnectionType { + DISPLAY_CONNECTION_TYPE_NONE = 0, + DISPLAY_CONNECTION_TYPE_UNKNOWN = 1 << 0, + DISPLAY_CONNECTION_TYPE_INTERNAL = 1 << 1, + DISPLAY_CONNECTION_TYPE_VGA = 1 << 2, + DISPLAY_CONNECTION_TYPE_HDMI = 1 << 3, + DISPLAY_CONNECTION_TYPE_DVI = 1 << 4, + DISPLAY_CONNECTION_TYPE_DISPLAYPORT = 1 << 5, + DISPLAY_CONNECTION_TYPE_NETWORK = 1 << 6, }; // Content protection methods applied on video output. -enum OutputProtectionMethod { - OUTPUT_PROTECTION_METHOD_NONE = 0, - OUTPUT_PROTECTION_METHOD_HDCP = 1 << 0, +enum ContentProtectionMethod { + CONTENT_PROTECTION_METHOD_NONE = 0, + CONTENT_PROTECTION_METHOD_HDCP = 1 << 0, }; // HDCP protection state.