Chromium Code Reviews| 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 return resolution_changed || display_property_changed; | 385 return resolution_changed || display_property_changed; |
| 386 } | 386 } |
| 387 | 387 |
| 388 void DisplayManager::RegisterDisplayProperty( | 388 void DisplayManager::RegisterDisplayProperty( |
| 389 int64_t display_id, | 389 int64_t display_id, |
| 390 Display::Rotation rotation, | 390 Display::Rotation rotation, |
| 391 float ui_scale, | 391 float ui_scale, |
| 392 const gfx::Insets* overscan_insets, | 392 const gfx::Insets* overscan_insets, |
| 393 const gfx::Size& resolution_in_pixels, | 393 const gfx::Size& resolution_in_pixels, |
| 394 float device_scale_factor, | 394 float device_scale_factor, |
| 395 ui::ColorCalibrationProfile color_profile) { | 395 ui::ColorCalibrationProfile color_profile, |
| 396 const TouchCalibrationData* touch_calibration_data) { | |
| 396 if (display_info_.find(display_id) == display_info_.end()) | 397 if (display_info_.find(display_id) == display_info_.end()) |
| 397 display_info_[display_id] = | 398 display_info_[display_id] = |
| 398 ManagedDisplayInfo(display_id, std::string(), false); | 399 ManagedDisplayInfo(display_id, std::string(), false); |
| 399 | 400 |
| 400 // Do not allow rotation in unified desktop mode. | 401 // Do not allow rotation in unified desktop mode. |
| 401 if (display_id == kUnifiedDisplayId) | 402 if (display_id == kUnifiedDisplayId) |
| 402 rotation = Display::ROTATE_0; | 403 rotation = Display::ROTATE_0; |
| 403 | 404 |
| 404 display_info_[display_id].SetRotation(rotation, | 405 display_info_[display_id].SetRotation(rotation, |
| 405 Display::ROTATION_SOURCE_USER); | 406 Display::ROTATION_SOURCE_USER); |
| 406 display_info_[display_id].SetRotation(rotation, | 407 display_info_[display_id].SetRotation(rotation, |
| 407 Display::ROTATION_SOURCE_ACTIVE); | 408 Display::ROTATION_SOURCE_ACTIVE); |
| 408 display_info_[display_id].SetColorProfile(color_profile); | 409 display_info_[display_id].SetColorProfile(color_profile); |
| 409 // Just in case the preference file was corrupted. | 410 // Just in case the preference file was corrupted. |
| 410 // TODO(mukai): register |display_modes_| here as well, so the lookup for the | 411 // TODO(mukai): register |display_modes_| here as well, so the lookup for the |
| 411 // default mode in GetActiveModeForDisplayId() gets much simpler. | 412 // default mode in GetActiveModeForDisplayId() gets much simpler. |
| 412 if (0.5f <= ui_scale && ui_scale <= 2.0f) | 413 if (0.5f <= ui_scale && ui_scale <= 2.0f) |
| 413 display_info_[display_id].set_configured_ui_scale(ui_scale); | 414 display_info_[display_id].set_configured_ui_scale(ui_scale); |
| 414 if (overscan_insets) | 415 if (overscan_insets) |
| 415 display_info_[display_id].SetOverscanInsets(*overscan_insets); | 416 display_info_[display_id].SetOverscanInsets(*overscan_insets); |
| 417 if (touch_calibration_data) | |
| 418 display_info_[display_id].SetTouchCalibrationData(*touch_calibration_data); | |
| 416 if (!resolution_in_pixels.IsEmpty()) { | 419 if (!resolution_in_pixels.IsEmpty()) { |
| 417 DCHECK(!Display::IsInternalDisplayId(display_id)); | 420 DCHECK(!Display::IsInternalDisplayId(display_id)); |
| 418 // Default refresh rate, until OnNativeDisplaysChanged() updates us with the | 421 // Default refresh rate, until OnNativeDisplaysChanged() updates us with the |
| 419 // actual display info, is 60 Hz. | 422 // actual display info, is 60 Hz. |
| 420 scoped_refptr<ManagedDisplayMode> mode = new ManagedDisplayMode( | 423 scoped_refptr<ManagedDisplayMode> mode = new ManagedDisplayMode( |
| 421 resolution_in_pixels, 60.0f, false, false, 1.0, device_scale_factor); | 424 resolution_in_pixels, 60.0f, false, false, 1.0, device_scale_factor); |
| 422 display_modes_[display_id] = mode; | 425 display_modes_[display_id] = mode; |
| 423 } | 426 } |
| 424 } | 427 } |
| 425 | 428 |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 975 | 978 |
| 976 #if defined(OS_CHROMEOS) | 979 #if defined(OS_CHROMEOS) |
| 977 void DisplayManager::SetSoftwareMirroring(bool enabled) { | 980 void DisplayManager::SetSoftwareMirroring(bool enabled) { |
| 978 SetMultiDisplayMode(enabled ? MIRRORING | 981 SetMultiDisplayMode(enabled ? MIRRORING |
| 979 : current_default_multi_display_mode_); | 982 : current_default_multi_display_mode_); |
| 980 } | 983 } |
| 981 | 984 |
| 982 bool DisplayManager::SoftwareMirroringEnabled() const { | 985 bool DisplayManager::SoftwareMirroringEnabled() const { |
| 983 return software_mirroring_enabled(); | 986 return software_mirroring_enabled(); |
| 984 } | 987 } |
| 988 | |
| 989 void DisplayManager::SetTouchCalibrationData( | |
| 990 int64_t display_id, | |
| 991 const TouchCalibrationData::CalibrationPointPairQuad& point_pair_quad, | |
| 992 const gfx::Size& display_bounds) { | |
| 993 bool update = false; | |
| 994 TouchCalibrationData calibration_data(point_pair_quad, display_bounds); | |
| 995 DisplayInfoList display_info_list; | |
| 996 for (const auto& display : active_display_list_) { | |
| 997 display::ManagedDisplayInfo info = GetDisplayInfo(display.id()); | |
| 998 if (info.id() == display_id) { | |
| 999 info.SetTouchCalibrationData(calibration_data); | |
| 1000 update = true; | |
| 1001 } | |
| 1002 display_info_list.push_back(info); | |
| 1003 } | |
|
oshima
2016/12/02 22:33:41
can should be able to do somethign like
Display*
malaykeshav
2016/12/03 02:01:28
We would still need to iterate through |active_dis
oshima
2016/12/05 20:43:21
ah right. please disregard this.
| |
| 1004 if (update) | |
| 1005 UpdateDisplaysWith(display_info_list); | |
| 1006 else | |
| 1007 display_info_[display_id].SetTouchCalibrationData(calibration_data); | |
| 1008 } | |
| 1009 | |
| 1010 void DisplayManager::ClearTouchCalibrationData(int64_t display_id) { | |
| 1011 bool update = false; | |
| 1012 DisplayInfoList display_info_list; | |
| 1013 for (const auto& display : active_display_list_) { | |
| 1014 display::ManagedDisplayInfo info = GetDisplayInfo(display.id()); | |
| 1015 if (info.id() == display_id) { | |
| 1016 info.clear_touch_calibration_data(); | |
| 1017 update = true; | |
| 1018 } | |
| 1019 display_info_list.push_back(info); | |
| 1020 } | |
| 1021 if (update) | |
| 1022 UpdateDisplaysWith(display_info_list); | |
| 1023 else | |
| 1024 display_info_[display_id].clear_touch_calibration_data(); | |
| 1025 } | |
| 985 #endif | 1026 #endif |
| 986 | 1027 |
| 987 void DisplayManager::SetDefaultMultiDisplayModeForCurrentDisplays( | 1028 void DisplayManager::SetDefaultMultiDisplayModeForCurrentDisplays( |
| 988 MultiDisplayMode mode) { | 1029 MultiDisplayMode mode) { |
| 989 DCHECK_NE(MIRRORING, mode); | 1030 DCHECK_NE(MIRRORING, mode); |
| 990 DisplayIdList list = GetCurrentDisplayIdList(); | 1031 DisplayIdList list = GetCurrentDisplayIdList(); |
| 991 layout_store_->UpdateMultiDisplayState(list, IsInMirrorMode(), | 1032 layout_store_->UpdateMultiDisplayState(list, IsInMirrorMode(), |
| 992 mode == UNIFIED); | 1033 mode == UNIFIED); |
| 993 ReconfigureDisplays(); | 1034 ReconfigureDisplays(); |
| 994 } | 1035 } |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1393 } | 1434 } |
| 1394 | 1435 |
| 1395 const Display& DisplayManager::GetSecondaryDisplay() const { | 1436 const Display& DisplayManager::GetSecondaryDisplay() const { |
| 1396 CHECK_LE(2U, GetNumDisplays()); | 1437 CHECK_LE(2U, GetNumDisplays()); |
| 1397 return GetDisplayAt(0).id() == Screen::GetScreen()->GetPrimaryDisplay().id() | 1438 return GetDisplayAt(0).id() == Screen::GetScreen()->GetPrimaryDisplay().id() |
| 1398 ? GetDisplayAt(1) | 1439 ? GetDisplayAt(1) |
| 1399 : GetDisplayAt(0); | 1440 : GetDisplayAt(0); |
| 1400 } | 1441 } |
| 1401 | 1442 |
| 1402 } // namespace display | 1443 } // namespace display |
| OLD | NEW |