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

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

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