| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/display/manager/display_manager.h" | 5 #include "ui/display/manager/display_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 return resolution_changed || display_property_changed; | 388 return resolution_changed || display_property_changed; |
| 389 } | 389 } |
| 390 | 390 |
| 391 void DisplayManager::RegisterDisplayProperty( | 391 void DisplayManager::RegisterDisplayProperty( |
| 392 int64_t display_id, | 392 int64_t display_id, |
| 393 Display::Rotation rotation, | 393 Display::Rotation rotation, |
| 394 float ui_scale, | 394 float ui_scale, |
| 395 const gfx::Insets* overscan_insets, | 395 const gfx::Insets* overscan_insets, |
| 396 const gfx::Size& resolution_in_pixels, | 396 const gfx::Size& resolution_in_pixels, |
| 397 float device_scale_factor, | 397 float device_scale_factor, |
| 398 ui::ColorCalibrationProfile color_profile, | 398 ColorCalibrationProfile color_profile, |
| 399 const TouchCalibrationData* touch_calibration_data) { | 399 const TouchCalibrationData* touch_calibration_data) { |
| 400 if (display_info_.find(display_id) == display_info_.end()) | 400 if (display_info_.find(display_id) == display_info_.end()) |
| 401 display_info_[display_id] = | 401 display_info_[display_id] = |
| 402 ManagedDisplayInfo(display_id, std::string(), false); | 402 ManagedDisplayInfo(display_id, std::string(), false); |
| 403 | 403 |
| 404 // Do not allow rotation in unified desktop mode. | 404 // Do not allow rotation in unified desktop mode. |
| 405 if (display_id == kUnifiedDisplayId) | 405 if (display_id == kUnifiedDisplayId) |
| 406 rotation = Display::ROTATE_0; | 406 rotation = Display::ROTATE_0; |
| 407 | 407 |
| 408 display_info_[display_id].SetRotation(rotation, | 408 display_info_[display_id].SetRotation(rotation, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 480 |
| 481 gfx::Insets DisplayManager::GetOverscanInsets(int64_t display_id) const { | 481 gfx::Insets DisplayManager::GetOverscanInsets(int64_t display_id) const { |
| 482 std::map<int64_t, ManagedDisplayInfo>::const_iterator it = | 482 std::map<int64_t, ManagedDisplayInfo>::const_iterator it = |
| 483 display_info_.find(display_id); | 483 display_info_.find(display_id); |
| 484 return (it != display_info_.end()) ? it->second.overscan_insets_in_dip() | 484 return (it != display_info_.end()) ? it->second.overscan_insets_in_dip() |
| 485 : gfx::Insets(); | 485 : gfx::Insets(); |
| 486 } | 486 } |
| 487 | 487 |
| 488 void DisplayManager::SetColorCalibrationProfile( | 488 void DisplayManager::SetColorCalibrationProfile( |
| 489 int64_t display_id, | 489 int64_t display_id, |
| 490 ui::ColorCalibrationProfile profile) { | 490 ColorCalibrationProfile profile) { |
| 491 #if defined(OS_CHROMEOS) | 491 #if defined(OS_CHROMEOS) |
| 492 if (!display_info_[display_id].IsColorProfileAvailable(profile)) | 492 if (!display_info_[display_id].IsColorProfileAvailable(profile)) |
| 493 return; | 493 return; |
| 494 | 494 |
| 495 if (delegate_) | 495 if (delegate_) |
| 496 delegate_->PreDisplayConfigurationChange(false); | 496 delegate_->PreDisplayConfigurationChange(false); |
| 497 // Just sets color profile if it's not running on ChromeOS (like tests). | 497 // Just sets color profile if it's not running on ChromeOS (like tests). |
| 498 if (!configure_displays_ || | 498 if (!configure_displays_ || |
| 499 delegate_->display_configurator()->SetColorCalibrationProfile(display_id, | 499 delegate_->display_configurator()->SetColorCalibrationProfile(display_id, |
| 500 profile)) { | 500 profile)) { |
| 501 display_info_[display_id].SetColorProfile(profile); | 501 display_info_[display_id].SetColorProfile(profile); |
| 502 UMA_HISTOGRAM_ENUMERATION("ChromeOS.Display.ColorProfile", profile, | 502 UMA_HISTOGRAM_ENUMERATION("ChromeOS.Display.ColorProfile", profile, |
| 503 ui::NUM_COLOR_PROFILES); | 503 NUM_COLOR_PROFILES); |
| 504 } | 504 } |
| 505 if (delegate_) | 505 if (delegate_) |
| 506 delegate_->PostDisplayConfigurationChange(false); | 506 delegate_->PostDisplayConfigurationChange(false); |
| 507 #endif | 507 #endif |
| 508 } | 508 } |
| 509 | 509 |
| 510 void DisplayManager::OnNativeDisplaysChanged( | 510 void DisplayManager::OnNativeDisplaysChanged( |
| 511 const DisplayInfoList& updated_displays) { | 511 const DisplayInfoList& updated_displays) { |
| 512 if (updated_displays.empty()) { | 512 if (updated_displays.empty()) { |
| 513 VLOG(1) << "OnNativeDisplaysChanged(0): # of current displays=" | 513 VLOG(1) << "OnNativeDisplaysChanged(0): # of current displays=" |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 : kInvalidDisplayId; | 921 : kInvalidDisplayId; |
| 922 } | 922 } |
| 923 | 923 |
| 924 void DisplayManager::SetMirrorMode(bool mirror) { | 924 void DisplayManager::SetMirrorMode(bool mirror) { |
| 925 // TODO(oshima): Enable mirror mode for 2> displays. crbug.com/589319. | 925 // TODO(oshima): Enable mirror mode for 2> displays. crbug.com/589319. |
| 926 if (num_connected_displays() != 2) | 926 if (num_connected_displays() != 2) |
| 927 return; | 927 return; |
| 928 | 928 |
| 929 #if defined(OS_CHROMEOS) | 929 #if defined(OS_CHROMEOS) |
| 930 if (configure_displays_) { | 930 if (configure_displays_) { |
| 931 ui::MultipleDisplayState new_state = | 931 MultipleDisplayState new_state = mirror |
| 932 mirror ? ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR | 932 ? MULTIPLE_DISPLAY_STATE_DUAL_MIRROR |
| 933 : ui::MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED; | 933 : MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED; |
| 934 delegate_->display_configurator()->SetDisplayMode(new_state); | 934 delegate_->display_configurator()->SetDisplayMode(new_state); |
| 935 return; | 935 return; |
| 936 } | 936 } |
| 937 #endif | 937 #endif |
| 938 multi_display_mode_ = | 938 multi_display_mode_ = |
| 939 mirror ? MIRRORING : current_default_multi_display_mode_; | 939 mirror ? MIRRORING : current_default_multi_display_mode_; |
| 940 ReconfigureDisplays(); | 940 ReconfigureDisplays(); |
| 941 } | 941 } |
| 942 | 942 |
| 943 void DisplayManager::AddRemoveDisplay() { | 943 void DisplayManager::AddRemoveDisplay() { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 } | 989 } |
| 990 | 990 |
| 991 void DisplayManager::SetTouchCalibrationData( | 991 void DisplayManager::SetTouchCalibrationData( |
| 992 int64_t display_id, | 992 int64_t display_id, |
| 993 const TouchCalibrationData::CalibrationPointPairQuad& point_pair_quad, | 993 const TouchCalibrationData::CalibrationPointPairQuad& point_pair_quad, |
| 994 const gfx::Size& display_bounds) { | 994 const gfx::Size& display_bounds) { |
| 995 bool update = false; | 995 bool update = false; |
| 996 TouchCalibrationData calibration_data(point_pair_quad, display_bounds); | 996 TouchCalibrationData calibration_data(point_pair_quad, display_bounds); |
| 997 DisplayInfoList display_info_list; | 997 DisplayInfoList display_info_list; |
| 998 for (const auto& display : active_display_list_) { | 998 for (const auto& display : active_display_list_) { |
| 999 display::ManagedDisplayInfo info = GetDisplayInfo(display.id()); | 999 ManagedDisplayInfo info = GetDisplayInfo(display.id()); |
| 1000 if (info.id() == display_id) { | 1000 if (info.id() == display_id) { |
| 1001 info.SetTouchCalibrationData(calibration_data); | 1001 info.SetTouchCalibrationData(calibration_data); |
| 1002 update = true; | 1002 update = true; |
| 1003 } | 1003 } |
| 1004 display_info_list.push_back(info); | 1004 display_info_list.push_back(info); |
| 1005 } | 1005 } |
| 1006 if (update) | 1006 if (update) |
| 1007 UpdateDisplaysWith(display_info_list); | 1007 UpdateDisplaysWith(display_info_list); |
| 1008 else | 1008 else |
| 1009 display_info_[display_id].SetTouchCalibrationData(calibration_data); | 1009 display_info_[display_id].SetTouchCalibrationData(calibration_data); |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 void DisplayManager::ClearTouchCalibrationData(int64_t display_id) { | 1012 void DisplayManager::ClearTouchCalibrationData(int64_t display_id) { |
| 1013 bool update = false; | 1013 bool update = false; |
| 1014 DisplayInfoList display_info_list; | 1014 DisplayInfoList display_info_list; |
| 1015 for (const auto& display : active_display_list_) { | 1015 for (const auto& display : active_display_list_) { |
| 1016 display::ManagedDisplayInfo info = GetDisplayInfo(display.id()); | 1016 ManagedDisplayInfo info = GetDisplayInfo(display.id()); |
| 1017 if (info.id() == display_id) { | 1017 if (info.id() == display_id) { |
| 1018 info.clear_touch_calibration_data(); | 1018 info.clear_touch_calibration_data(); |
| 1019 update = true; | 1019 update = true; |
| 1020 } | 1020 } |
| 1021 display_info_list.push_back(info); | 1021 display_info_list.push_back(info); |
| 1022 } | 1022 } |
| 1023 if (update) | 1023 if (update) |
| 1024 UpdateDisplaysWith(display_info_list); | 1024 UpdateDisplaysWith(display_info_list); |
| 1025 else | 1025 else |
| 1026 display_info_[display_id].clear_touch_calibration_data(); | 1026 display_info_[display_id].clear_touch_calibration_data(); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 display_info_[new_info.id()].set_configured_ui_scale(0.8f); | 1313 display_info_[new_info.id()].set_configured_ui_scale(0.8f); |
| 1314 } | 1314 } |
| 1315 } | 1315 } |
| 1316 display_info_[new_info.id()].UpdateDisplaySize(); | 1316 display_info_[new_info.id()].UpdateDisplaySize(); |
| 1317 OnDisplayInfoUpdated(display_info_[new_info.id()]); | 1317 OnDisplayInfoUpdated(display_info_[new_info.id()]); |
| 1318 } | 1318 } |
| 1319 | 1319 |
| 1320 void DisplayManager::OnDisplayInfoUpdated( | 1320 void DisplayManager::OnDisplayInfoUpdated( |
| 1321 const ManagedDisplayInfo& display_info) { | 1321 const ManagedDisplayInfo& display_info) { |
| 1322 #if defined(OS_CHROMEOS) | 1322 #if defined(OS_CHROMEOS) |
| 1323 ui::ColorCalibrationProfile color_profile = display_info.color_profile(); | 1323 ColorCalibrationProfile color_profile = display_info.color_profile(); |
| 1324 if (color_profile != ui::COLOR_PROFILE_STANDARD) { | 1324 if (color_profile != COLOR_PROFILE_STANDARD) { |
| 1325 delegate_->display_configurator()->SetColorCalibrationProfile( | 1325 delegate_->display_configurator()->SetColorCalibrationProfile( |
| 1326 display_info.id(), color_profile); | 1326 display_info.id(), color_profile); |
| 1327 } | 1327 } |
| 1328 #endif | 1328 #endif |
| 1329 } | 1329 } |
| 1330 | 1330 |
| 1331 Display DisplayManager::CreateDisplayFromDisplayInfoById(int64_t id) { | 1331 Display DisplayManager::CreateDisplayFromDisplayInfoById(int64_t id) { |
| 1332 DCHECK(display_info_.find(id) != display_info_.end()) << "id=" << id; | 1332 DCHECK(display_info_.find(id) != display_info_.end()) << "id=" << id; |
| 1333 const ManagedDisplayInfo& display_info = display_info_[id]; | 1333 const ManagedDisplayInfo& display_info = display_info_[id]; |
| 1334 | 1334 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 } | 1436 } |
| 1437 | 1437 |
| 1438 const Display& DisplayManager::GetSecondaryDisplay() const { | 1438 const Display& DisplayManager::GetSecondaryDisplay() const { |
| 1439 CHECK_LE(2U, GetNumDisplays()); | 1439 CHECK_LE(2U, GetNumDisplays()); |
| 1440 return GetDisplayAt(0).id() == Screen::GetScreen()->GetPrimaryDisplay().id() | 1440 return GetDisplayAt(0).id() == Screen::GetScreen()->GetPrimaryDisplay().id() |
| 1441 ? GetDisplayAt(1) | 1441 ? GetDisplayAt(1) |
| 1442 : GetDisplayAt(0); | 1442 : GetDisplayAt(0); |
| 1443 } | 1443 } |
| 1444 | 1444 |
| 1445 } // namespace display | 1445 } // namespace display |
| OLD | NEW |