| 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 "ash/display/display_manager.h" | 5 #include "ash/display/display_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 } | 318 } |
| 319 if (update) { | 319 if (update) { |
| 320 AddMirrorDisplayInfoIfAny(&display_info_list); | 320 AddMirrorDisplayInfoIfAny(&display_info_list); |
| 321 UpdateDisplays(display_info_list); | 321 UpdateDisplays(display_info_list); |
| 322 } else { | 322 } else { |
| 323 display_info_[display_id].SetOverscanInsets(insets_in_dip); | 323 display_info_[display_id].SetOverscanInsets(insets_in_dip); |
| 324 } | 324 } |
| 325 } | 325 } |
| 326 | 326 |
| 327 void DisplayManager::SetDisplayRotation(int64 display_id, | 327 void DisplayManager::SetDisplayRotation(int64 display_id, |
| 328 gfx::Display::Rotation rotation) { | 328 gfx::Display::Rotation rotation, |
| 329 gfx::Display::RotationSource source) { |
| 329 DisplayInfoList display_info_list; | 330 DisplayInfoList display_info_list; |
| 330 for (const auto& display : active_display_list_) { | 331 for (const auto& display : active_display_list_) { |
| 331 DisplayInfo info = GetDisplayInfo(display.id()); | 332 DisplayInfo info = GetDisplayInfo(display.id()); |
| 332 if (info.id() == display_id) { | 333 if (info.id() == display_id) { |
| 333 if (info.rotation() == rotation) | 334 if (info.GetRotation(source) == rotation && |
| 335 info.GetActiveRotation() == rotation) { |
| 334 return; | 336 return; |
| 335 info.set_rotation(rotation); | 337 } |
| 338 info.SetRotation(rotation, source); |
| 336 } | 339 } |
| 337 display_info_list.push_back(info); | 340 display_info_list.push_back(info); |
| 338 } | 341 } |
| 339 AddMirrorDisplayInfoIfAny(&display_info_list); | 342 AddMirrorDisplayInfoIfAny(&display_info_list); |
| 340 UpdateDisplays(display_info_list); | 343 UpdateDisplays(display_info_list); |
| 341 } | 344 } |
| 342 | 345 |
| 343 bool DisplayManager::SetDisplayUIScale(int64 display_id, | 346 bool DisplayManager::SetDisplayUIScale(int64 display_id, |
| 344 float ui_scale) { | 347 float ui_scale) { |
| 345 if (!IsDisplayUIScalingEnabled() || | 348 if (!IsDisplayUIScalingEnabled() || |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 int64 display_id, | 444 int64 display_id, |
| 442 gfx::Display::Rotation rotation, | 445 gfx::Display::Rotation rotation, |
| 443 float ui_scale, | 446 float ui_scale, |
| 444 const gfx::Insets* overscan_insets, | 447 const gfx::Insets* overscan_insets, |
| 445 const gfx::Size& resolution_in_pixels, | 448 const gfx::Size& resolution_in_pixels, |
| 446 float device_scale_factor, | 449 float device_scale_factor, |
| 447 ui::ColorCalibrationProfile color_profile) { | 450 ui::ColorCalibrationProfile color_profile) { |
| 448 if (display_info_.find(display_id) == display_info_.end()) | 451 if (display_info_.find(display_id) == display_info_.end()) |
| 449 display_info_[display_id] = DisplayInfo(display_id, std::string(), false); | 452 display_info_[display_id] = DisplayInfo(display_id, std::string(), false); |
| 450 | 453 |
| 451 display_info_[display_id].set_rotation(rotation); | 454 display_info_[display_id].SetRotation(rotation, |
| 455 gfx::Display::ROTATION_SOURCE_ACTIVE); |
| 452 display_info_[display_id].SetColorProfile(color_profile); | 456 display_info_[display_id].SetColorProfile(color_profile); |
| 453 // Just in case the preference file was corrupted. | 457 // Just in case the preference file was corrupted. |
| 454 // TODO(mukai): register |display_modes_| here as well, so the lookup for the | 458 // TODO(mukai): register |display_modes_| here as well, so the lookup for the |
| 455 // default mode in GetActiveModeForDisplayId() gets much simpler. | 459 // default mode in GetActiveModeForDisplayId() gets much simpler. |
| 456 if (0.5f <= ui_scale && ui_scale <= 2.0f) | 460 if (0.5f <= ui_scale && ui_scale <= 2.0f) |
| 457 display_info_[display_id].set_configured_ui_scale(ui_scale); | 461 display_info_[display_id].set_configured_ui_scale(ui_scale); |
| 458 if (overscan_insets) | 462 if (overscan_insets) |
| 459 display_info_[display_id].SetOverscanInsets(*overscan_insets); | 463 display_info_[display_id].SetOverscanInsets(*overscan_insets); |
| 460 if (!resolution_in_pixels.IsEmpty()) { | 464 if (!resolution_in_pixels.IsEmpty()) { |
| 461 DCHECK(!IsInternalDisplayId(display_id)); | 465 DCHECK(!IsInternalDisplayId(display_id)); |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 | 1096 |
| 1093 gfx::Display new_display(display_info.id()); | 1097 gfx::Display new_display(display_info.id()); |
| 1094 gfx::Rect bounds_in_native(display_info.size_in_pixel()); | 1098 gfx::Rect bounds_in_native(display_info.size_in_pixel()); |
| 1095 float device_scale_factor = display_info.GetEffectiveDeviceScaleFactor(); | 1099 float device_scale_factor = display_info.GetEffectiveDeviceScaleFactor(); |
| 1096 | 1100 |
| 1097 // Simply set the origin to (0,0). The primary display's origin is | 1101 // Simply set the origin to (0,0). The primary display's origin is |
| 1098 // always (0,0) and the bounds of non-primary display(s) will be updated | 1102 // always (0,0) and the bounds of non-primary display(s) will be updated |
| 1099 // in |UpdateNonPrimaryDisplayBoundsForLayout| called in |UpdateDisplay|. | 1103 // in |UpdateNonPrimaryDisplayBoundsForLayout| called in |UpdateDisplay|. |
| 1100 new_display.SetScaleAndBounds( | 1104 new_display.SetScaleAndBounds( |
| 1101 device_scale_factor, gfx::Rect(bounds_in_native.size())); | 1105 device_scale_factor, gfx::Rect(bounds_in_native.size())); |
| 1102 new_display.set_rotation(display_info.rotation()); | 1106 new_display.set_rotation(display_info.GetActiveRotation()); |
| 1103 new_display.set_touch_support(display_info.touch_support()); | 1107 new_display.set_touch_support(display_info.touch_support()); |
| 1104 return new_display; | 1108 return new_display; |
| 1105 } | 1109 } |
| 1106 | 1110 |
| 1107 bool DisplayManager::UpdateNonPrimaryDisplayBoundsForLayout( | 1111 bool DisplayManager::UpdateNonPrimaryDisplayBoundsForLayout( |
| 1108 DisplayList* displays, | 1112 DisplayList* displays, |
| 1109 std::vector<size_t>* updated_indices) const { | 1113 std::vector<size_t>* updated_indices) const { |
| 1110 | 1114 |
| 1111 if (displays->size() < 2U) | 1115 if (displays->size() < 2U) |
| 1112 return false; | 1116 return false; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 1217 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
| 1214 secondary_display->UpdateWorkAreaFromInsets(insets); | 1218 secondary_display->UpdateWorkAreaFromInsets(insets); |
| 1215 } | 1219 } |
| 1216 | 1220 |
| 1217 void DisplayManager::RunPendingTasksForTest() { | 1221 void DisplayManager::RunPendingTasksForTest() { |
| 1218 if (software_mirroring_display_.is_valid()) | 1222 if (software_mirroring_display_.is_valid()) |
| 1219 base::RunLoop().RunUntilIdle(); | 1223 base::RunLoop().RunUntilIdle(); |
| 1220 } | 1224 } |
| 1221 | 1225 |
| 1222 } // namespace ash | 1226 } // namespace ash |
| OLD | NEW |