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

Side by Side Diff: ash/display/display_manager.cc

Issue 1107383002: Merge Prevent DisplayPreferences from saving incorrect rotations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2357
Patch Set: Created 5 years, 7 months 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 | « ash/display/display_manager.h ('k') | ash/display/root_window_transformers.cc » ('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 "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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } 336 }
337 if (update) { 337 if (update) {
338 AddMirrorDisplayInfoIfAny(&display_info_list); 338 AddMirrorDisplayInfoIfAny(&display_info_list);
339 UpdateDisplays(display_info_list); 339 UpdateDisplays(display_info_list);
340 } else { 340 } else {
341 display_info_[display_id].SetOverscanInsets(insets_in_dip); 341 display_info_[display_id].SetOverscanInsets(insets_in_dip);
342 } 342 }
343 } 343 }
344 344
345 void DisplayManager::SetDisplayRotation(int64 display_id, 345 void DisplayManager::SetDisplayRotation(int64 display_id,
346 gfx::Display::Rotation rotation) { 346 gfx::Display::Rotation rotation,
347 gfx::Display::RotationSource source) {
347 DisplayInfoList display_info_list; 348 DisplayInfoList display_info_list;
348 for (DisplayList::const_iterator iter = displays_.begin(); 349 for (DisplayList::const_iterator iter = displays_.begin();
349 iter != displays_.end(); ++iter) { 350 iter != displays_.end(); ++iter) {
350 DisplayInfo info = GetDisplayInfo(iter->id()); 351 DisplayInfo info = GetDisplayInfo(iter->id());
351 if (info.id() == display_id) { 352 if (info.id() == display_id) {
352 if (info.rotation() == rotation) 353 if (info.GetRotation(source) == rotation &&
354 info.GetActiveRotation() == rotation) {
353 return; 355 return;
354 info.set_rotation(rotation); 356 }
357 info.SetRotation(rotation, source);
355 } 358 }
356 display_info_list.push_back(info); 359 display_info_list.push_back(info);
357 } 360 }
358 AddMirrorDisplayInfoIfAny(&display_info_list); 361 AddMirrorDisplayInfoIfAny(&display_info_list);
359 UpdateDisplays(display_info_list); 362 UpdateDisplays(display_info_list);
360 } 363 }
361 364
362 bool DisplayManager::SetDisplayUIScale(int64 display_id, 365 bool DisplayManager::SetDisplayUIScale(int64 display_id,
363 float ui_scale) { 366 float ui_scale) {
364 if (!IsDisplayUIScalingEnabled() || 367 if (!IsDisplayUIScalingEnabled() ||
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 int64 display_id, 465 int64 display_id,
463 gfx::Display::Rotation rotation, 466 gfx::Display::Rotation rotation,
464 float ui_scale, 467 float ui_scale,
465 const gfx::Insets* overscan_insets, 468 const gfx::Insets* overscan_insets,
466 const gfx::Size& resolution_in_pixels, 469 const gfx::Size& resolution_in_pixels,
467 float device_scale_factor, 470 float device_scale_factor,
468 ui::ColorCalibrationProfile color_profile) { 471 ui::ColorCalibrationProfile color_profile) {
469 if (display_info_.find(display_id) == display_info_.end()) 472 if (display_info_.find(display_id) == display_info_.end())
470 display_info_[display_id] = DisplayInfo(display_id, std::string(), false); 473 display_info_[display_id] = DisplayInfo(display_id, std::string(), false);
471 474
472 display_info_[display_id].set_rotation(rotation); 475 display_info_[display_id].SetRotation(rotation,
476 gfx::Display::ROTATION_SOURCE_ACTIVE);
473 display_info_[display_id].SetColorProfile(color_profile); 477 display_info_[display_id].SetColorProfile(color_profile);
474 // Just in case the preference file was corrupted. 478 // Just in case the preference file was corrupted.
475 // TODO(mukai): register |display_modes_| here as well, so the lookup for the 479 // TODO(mukai): register |display_modes_| here as well, so the lookup for the
476 // default mode in GetActiveModeForDisplayId() gets much simpler. 480 // default mode in GetActiveModeForDisplayId() gets much simpler.
477 if (0.5f <= ui_scale && ui_scale <= 2.0f) 481 if (0.5f <= ui_scale && ui_scale <= 2.0f)
478 display_info_[display_id].set_configured_ui_scale(ui_scale); 482 display_info_[display_id].set_configured_ui_scale(ui_scale);
479 if (overscan_insets) 483 if (overscan_insets)
480 display_info_[display_id].SetOverscanInsets(*overscan_insets); 484 display_info_[display_id].SetOverscanInsets(*overscan_insets);
481 if (!resolution_in_pixels.IsEmpty()) { 485 if (!resolution_in_pixels.IsEmpty()) {
482 DCHECK(!IsInternalDisplayId(display_id)); 486 DCHECK(!IsInternalDisplayId(display_id));
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 1149
1146 gfx::Display new_display(display_info.id()); 1150 gfx::Display new_display(display_info.id());
1147 gfx::Rect bounds_in_native(display_info.size_in_pixel()); 1151 gfx::Rect bounds_in_native(display_info.size_in_pixel());
1148 float device_scale_factor = display_info.GetEffectiveDeviceScaleFactor(); 1152 float device_scale_factor = display_info.GetEffectiveDeviceScaleFactor();
1149 1153
1150 // Simply set the origin to (0,0). The primary display's origin is 1154 // Simply set the origin to (0,0). The primary display's origin is
1151 // always (0,0) and the bounds of non-primary display(s) will be updated 1155 // always (0,0) and the bounds of non-primary display(s) will be updated
1152 // in |UpdateNonPrimaryDisplayBoundsForLayout| called in |UpdateDisplay|. 1156 // in |UpdateNonPrimaryDisplayBoundsForLayout| called in |UpdateDisplay|.
1153 new_display.SetScaleAndBounds( 1157 new_display.SetScaleAndBounds(
1154 device_scale_factor, gfx::Rect(bounds_in_native.size())); 1158 device_scale_factor, gfx::Rect(bounds_in_native.size()));
1155 new_display.set_rotation(display_info.rotation()); 1159 new_display.set_rotation(display_info.GetActiveRotation());
1156 new_display.set_touch_support(display_info.touch_support()); 1160 new_display.set_touch_support(display_info.touch_support());
1157 return new_display; 1161 return new_display;
1158 } 1162 }
1159 1163
1160 bool DisplayManager::UpdateNonPrimaryDisplayBoundsForLayout( 1164 bool DisplayManager::UpdateNonPrimaryDisplayBoundsForLayout(
1161 DisplayList* displays, 1165 DisplayList* displays,
1162 std::vector<size_t>* updated_indices) const { 1166 std::vector<size_t>* updated_indices) const {
1163 1167
1164 if (displays->size() < 2U) 1168 if (displays->size() < 2U)
1165 return false; 1169 return false;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 new_secondary_origin.Offset(-secondary_bounds.width(), offset); 1270 new_secondary_origin.Offset(-secondary_bounds.width(), offset);
1267 break; 1271 break;
1268 } 1272 }
1269 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); 1273 gfx::Insets insets = secondary_display->GetWorkAreaInsets();
1270 secondary_display->set_bounds( 1274 secondary_display->set_bounds(
1271 gfx::Rect(new_secondary_origin, secondary_bounds.size())); 1275 gfx::Rect(new_secondary_origin, secondary_bounds.size()));
1272 secondary_display->UpdateWorkAreaFromInsets(insets); 1276 secondary_display->UpdateWorkAreaFromInsets(insets);
1273 } 1277 }
1274 1278
1275 } // namespace ash 1279 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_manager.h ('k') | ash/display/root_window_transformers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698