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

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

Issue 417113012: Introduce user customization of external HighDPI mode for 4K monitor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: polish Created 6 years, 4 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 | Annotate | Revision Log
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 <cmath> 8 #include <cmath>
8 #include <set> 9 #include <set>
9 #include <string> 10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "ash/ash_switches.h" 13 #include "ash/ash_switches.h"
13 #include "ash/display/display_layout_store.h" 14 #include "ash/display/display_layout_store.h"
14 #include "ash/display/screen_ash.h" 15 #include "ash/display/screen_ash.h"
15 #include "ash/screen_util.h" 16 #include "ash/screen_util.h"
16 #include "ash/shell.h" 17 #include "ash/shell.h"
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 << resolution.ToString(); 466 << resolution.ToString();
466 return; 467 return;
467 } 468 }
468 display_modes_[display_id] = *iter; 469 display_modes_[display_id] = *iter;
469 #if defined(OS_CHROMEOS) 470 #if defined(OS_CHROMEOS)
470 if (base::SysInfo::IsRunningOnChromeOS()) 471 if (base::SysInfo::IsRunningOnChromeOS())
471 Shell::GetInstance()->display_configurator()->OnConfigurationChanged(); 472 Shell::GetInstance()->display_configurator()->OnConfigurationChanged();
472 #endif 473 #endif
473 } 474 }
474 475
476 void DisplayManager::SetDisplayMode(int64 display_id,
477 const DisplayMode& display_mode) {
478 if (IsInternalDisplayId(display_id)) {
479 SetDisplayUIScale(display_id, display_mode.ui_scale);
480 return;
481 }
482
483 DisplayInfoList display_info_list;
484 bool display_property_changed = false;
485 bool resolution_changed = false;
486 for (DisplayList::const_iterator iter = displays_.begin();
487 iter != displays_.end(); ++iter) {
488 DisplayInfo info = GetDisplayInfo(iter->id());
489 if (info.id() == display_id) {
490 if (info.bounds_in_native().size() != display_mode.size) {
491 const std::vector<DisplayMode>& modes = info.display_modes();
492 std::vector<DisplayMode>::const_iterator iter =
493 std::find_if(modes.begin(), modes.end(),
494 DisplayModeMatcher(display_mode.size));
495 if (iter == modes.end()) {
496 LOG(WARNING) << "Unsupported resolution was requested:"
497 << display_mode.size.ToString();
498 return;
499 }
500 display_modes_[display_id] = *iter;
501 resolution_changed = true;
502 }
503 if (info.device_scale_factor() != display_mode.device_scale_factor) {
504 info.set_device_scale_factor(display_mode.device_scale_factor);
505 display_property_changed = true;
506 }
507 }
508 display_info_list.push_back(info);
509 }
510 if (display_property_changed) {
511 AddMirrorDisplayInfoIfAny(&display_info_list);
512 UpdateDisplays(display_info_list);
513 }
514 #if defined(OS_CHROMEOS)
515 if (resolution_changed && base::SysInfo::IsRunningOnChromeOS())
516 Shell::GetInstance()->display_configurator()->OnConfigurationChanged();
517 #endif
518 }
519
475 void DisplayManager::RegisterDisplayProperty( 520 void DisplayManager::RegisterDisplayProperty(
476 int64 display_id, 521 int64 display_id,
477 gfx::Display::Rotation rotation, 522 gfx::Display::Rotation rotation,
478 float ui_scale, 523 float ui_scale,
479 const gfx::Insets* overscan_insets, 524 const gfx::Insets* overscan_insets,
480 const gfx::Size& resolution_in_pixels, 525 const gfx::Size& resolution_in_pixels,
481 ui::ColorCalibrationProfile color_profile) { 526 ui::ColorCalibrationProfile color_profile) {
482 if (display_info_.find(display_id) == display_info_.end()) 527 if (display_info_.find(display_id) == display_info_.end())
483 display_info_[display_id] = DisplayInfo(display_id, std::string(), false); 528 display_info_[display_id] = DisplayInfo(display_id, std::string(), false);
484 529
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 new_secondary_origin.Offset(-secondary_bounds.width(), offset); 1189 new_secondary_origin.Offset(-secondary_bounds.width(), offset);
1145 break; 1190 break;
1146 } 1191 }
1147 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); 1192 gfx::Insets insets = secondary_display->GetWorkAreaInsets();
1148 secondary_display->set_bounds( 1193 secondary_display->set_bounds(
1149 gfx::Rect(new_secondary_origin, secondary_bounds.size())); 1194 gfx::Rect(new_secondary_origin, secondary_bounds.size()));
1150 secondary_display->UpdateWorkAreaFromInsets(insets); 1195 secondary_display->UpdateWorkAreaFromInsets(insets);
1151 } 1196 }
1152 1197
1153 } // namespace ash 1198 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698