Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: ui/display/manager/display_manager.cc

Issue 2540383002: Updates display manager and display preferences to handle touch calibration data. (Closed)
Patch Set: Merge with ToT Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/display/manager/display_manager.h ('k') | ui/display/manager/managed_display_info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 return resolution_changed || display_property_changed; 387 return resolution_changed || display_property_changed;
388 } 388 }
389 389
390 void DisplayManager::RegisterDisplayProperty( 390 void DisplayManager::RegisterDisplayProperty(
391 int64_t display_id, 391 int64_t display_id,
392 Display::Rotation rotation, 392 Display::Rotation rotation,
393 float ui_scale, 393 float ui_scale,
394 const gfx::Insets* overscan_insets, 394 const gfx::Insets* overscan_insets,
395 const gfx::Size& resolution_in_pixels, 395 const gfx::Size& resolution_in_pixels,
396 float device_scale_factor, 396 float device_scale_factor,
397 ui::ColorCalibrationProfile color_profile) { 397 ui::ColorCalibrationProfile color_profile,
398 const TouchCalibrationData* touch_calibration_data) {
398 if (display_info_.find(display_id) == display_info_.end()) 399 if (display_info_.find(display_id) == display_info_.end())
399 display_info_[display_id] = 400 display_info_[display_id] =
400 ManagedDisplayInfo(display_id, std::string(), false); 401 ManagedDisplayInfo(display_id, std::string(), false);
401 402
402 // Do not allow rotation in unified desktop mode. 403 // Do not allow rotation in unified desktop mode.
403 if (display_id == kUnifiedDisplayId) 404 if (display_id == kUnifiedDisplayId)
404 rotation = Display::ROTATE_0; 405 rotation = Display::ROTATE_0;
405 406
406 display_info_[display_id].SetRotation(rotation, 407 display_info_[display_id].SetRotation(rotation,
407 Display::ROTATION_SOURCE_USER); 408 Display::ROTATION_SOURCE_USER);
408 display_info_[display_id].SetRotation(rotation, 409 display_info_[display_id].SetRotation(rotation,
409 Display::ROTATION_SOURCE_ACTIVE); 410 Display::ROTATION_SOURCE_ACTIVE);
410 display_info_[display_id].SetColorProfile(color_profile); 411 display_info_[display_id].SetColorProfile(color_profile);
411 // Just in case the preference file was corrupted. 412 // Just in case the preference file was corrupted.
412 // TODO(mukai): register |display_modes_| here as well, so the lookup for the 413 // TODO(mukai): register |display_modes_| here as well, so the lookup for the
413 // default mode in GetActiveModeForDisplayId() gets much simpler. 414 // default mode in GetActiveModeForDisplayId() gets much simpler.
414 if (0.5f <= ui_scale && ui_scale <= 2.0f) 415 if (0.5f <= ui_scale && ui_scale <= 2.0f)
415 display_info_[display_id].set_configured_ui_scale(ui_scale); 416 display_info_[display_id].set_configured_ui_scale(ui_scale);
416 if (overscan_insets) 417 if (overscan_insets)
417 display_info_[display_id].SetOverscanInsets(*overscan_insets); 418 display_info_[display_id].SetOverscanInsets(*overscan_insets);
419 if (touch_calibration_data)
420 display_info_[display_id].SetTouchCalibrationData(*touch_calibration_data);
418 if (!resolution_in_pixels.IsEmpty()) { 421 if (!resolution_in_pixels.IsEmpty()) {
419 DCHECK(!Display::IsInternalDisplayId(display_id)); 422 DCHECK(!Display::IsInternalDisplayId(display_id));
420 // Default refresh rate, until OnNativeDisplaysChanged() updates us with the 423 // Default refresh rate, until OnNativeDisplaysChanged() updates us with the
421 // actual display info, is 60 Hz. 424 // actual display info, is 60 Hz.
422 scoped_refptr<ManagedDisplayMode> mode = new ManagedDisplayMode( 425 scoped_refptr<ManagedDisplayMode> mode = new ManagedDisplayMode(
423 resolution_in_pixels, 60.0f, false, false, 1.0, device_scale_factor); 426 resolution_in_pixels, 60.0f, false, false, 1.0, device_scale_factor);
424 display_modes_[display_id] = mode; 427 display_modes_[display_id] = mode;
425 } 428 }
426 } 429 }
427 430
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 980
978 #if defined(OS_CHROMEOS) 981 #if defined(OS_CHROMEOS)
979 void DisplayManager::SetSoftwareMirroring(bool enabled) { 982 void DisplayManager::SetSoftwareMirroring(bool enabled) {
980 SetMultiDisplayMode(enabled ? MIRRORING 983 SetMultiDisplayMode(enabled ? MIRRORING
981 : current_default_multi_display_mode_); 984 : current_default_multi_display_mode_);
982 } 985 }
983 986
984 bool DisplayManager::SoftwareMirroringEnabled() const { 987 bool DisplayManager::SoftwareMirroringEnabled() const {
985 return software_mirroring_enabled(); 988 return software_mirroring_enabled();
986 } 989 }
990
991 void DisplayManager::SetTouchCalibrationData(
992 int64_t display_id,
993 const TouchCalibrationData::CalibrationPointPairQuad& point_pair_quad,
994 const gfx::Size& display_bounds) {
995 bool update = false;
996 TouchCalibrationData calibration_data(point_pair_quad, display_bounds);
997 DisplayInfoList display_info_list;
998 for (const auto& display : active_display_list_) {
999 display::ManagedDisplayInfo info = GetDisplayInfo(display.id());
1000 if (info.id() == display_id) {
1001 info.SetTouchCalibrationData(calibration_data);
1002 update = true;
1003 }
1004 display_info_list.push_back(info);
1005 }
1006 if (update)
1007 UpdateDisplaysWith(display_info_list);
1008 else
1009 display_info_[display_id].SetTouchCalibrationData(calibration_data);
1010 }
1011
1012 void DisplayManager::ClearTouchCalibrationData(int64_t display_id) {
1013 bool update = false;
1014 DisplayInfoList display_info_list;
1015 for (const auto& display : active_display_list_) {
1016 display::ManagedDisplayInfo info = GetDisplayInfo(display.id());
1017 if (info.id() == display_id) {
1018 info.clear_touch_calibration_data();
1019 update = true;
1020 }
1021 display_info_list.push_back(info);
1022 }
1023 if (update)
1024 UpdateDisplaysWith(display_info_list);
1025 else
1026 display_info_[display_id].clear_touch_calibration_data();
1027 }
987 #endif 1028 #endif
988 1029
989 void DisplayManager::SetDefaultMultiDisplayModeForCurrentDisplays( 1030 void DisplayManager::SetDefaultMultiDisplayModeForCurrentDisplays(
990 MultiDisplayMode mode) { 1031 MultiDisplayMode mode) {
991 DCHECK_NE(MIRRORING, mode); 1032 DCHECK_NE(MIRRORING, mode);
992 DisplayIdList list = GetCurrentDisplayIdList(); 1033 DisplayIdList list = GetCurrentDisplayIdList();
993 layout_store_->UpdateMultiDisplayState(list, IsInMirrorMode(), 1034 layout_store_->UpdateMultiDisplayState(list, IsInMirrorMode(),
994 mode == UNIFIED); 1035 mode == UNIFIED);
995 ReconfigureDisplays(); 1036 ReconfigureDisplays();
996 } 1037 }
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 } 1436 }
1396 1437
1397 const Display& DisplayManager::GetSecondaryDisplay() const { 1438 const Display& DisplayManager::GetSecondaryDisplay() const {
1398 CHECK_LE(2U, GetNumDisplays()); 1439 CHECK_LE(2U, GetNumDisplays());
1399 return GetDisplayAt(0).id() == Screen::GetScreen()->GetPrimaryDisplay().id() 1440 return GetDisplayAt(0).id() == Screen::GetScreen()->GetPrimaryDisplay().id()
1400 ? GetDisplayAt(1) 1441 ? GetDisplayAt(1)
1401 : GetDisplayAt(0); 1442 : GetDisplayAt(0);
1402 } 1443 }
1403 1444
1404 } // namespace display 1445 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/manager/display_manager.h ('k') | ui/display/manager/managed_display_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698