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

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

Issue 2196923002: Make ash::DisplayMode more like ui::DisplayMode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 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
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 <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "ash/common/ash_switches.h" 16 #include "ash/common/ash_switches.h"
17 #include "ash/common/display/display_info.h"
17 #include "ash/display/display_layout_store.h" 18 #include "ash/display/display_layout_store.h"
18 #include "ash/display/display_util.h" 19 #include "ash/display/display_util.h"
19 #include "ash/display/extended_mouse_warp_controller.h" 20 #include "ash/display/extended_mouse_warp_controller.h"
20 #include "ash/display/null_mouse_warp_controller.h" 21 #include "ash/display/null_mouse_warp_controller.h"
21 #include "ash/display/screen_ash.h" 22 #include "ash/display/screen_ash.h"
22 #include "ash/display/unified_mouse_warp_controller.h" 23 #include "ash/display/unified_mouse_warp_controller.h"
23 #include "ash/screen_util.h" 24 #include "ash/screen_util.h"
24 #include "ash/shell.h" 25 #include "ash/shell.h"
25 #include "base/auto_reset.h" 26 #include "base/auto_reset.h"
26 #include "base/command_line.h" 27 #include "base/command_line.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 bool operator()(const DisplayInfo& a, const DisplayInfo& b) { 78 bool operator()(const DisplayInfo& a, const DisplayInfo& b) {
78 return CompareDisplayIds(a.id(), b.id()); 79 return CompareDisplayIds(a.id(), b.id());
79 } 80 }
80 }; 81 };
81 82
82 display::Display& GetInvalidDisplay() { 83 display::Display& GetInvalidDisplay() {
83 static display::Display* invalid_display = new display::Display(); 84 static display::Display* invalid_display = new display::Display();
84 return *invalid_display; 85 return *invalid_display;
85 } 86 }
86 87
87 std::vector<DisplayMode>::const_iterator FindDisplayMode( 88 DisplayInfo::DisplayModeList::const_iterator FindDisplayMode(
88 const DisplayInfo& info, 89 const DisplayInfo& info,
89 const DisplayMode& target_mode) { 90 const scoped_refptr<DisplayMode>& target_mode) {
90 const std::vector<DisplayMode>& modes = info.display_modes(); 91 const DisplayInfo::DisplayModeList& modes = info.display_modes();
91 return std::find_if(modes.begin(), modes.end(), 92 return std::find_if(modes.begin(), modes.end(),
92 [target_mode](const DisplayMode& mode) { 93 [target_mode](const scoped_refptr<DisplayMode>& mode) {
93 return target_mode.IsEquivalent(mode); 94 return target_mode->IsEquivalent(mode);
94 }); 95 });
95 } 96 }
96 97
97 void SetInternalDisplayModeList(DisplayInfo* info) { 98 void SetInternalDisplayModeList(DisplayInfo* info) {
98 DisplayMode native_mode; 99 scoped_refptr<DisplayMode> native_mode =
99 native_mode.size = info->bounds_in_native().size(); 100 new DisplayMode(info->bounds_in_native().size(), 0.0 /* refresh_rate */,
100 native_mode.device_scale_factor = info->device_scale_factor(); 101 false /* interlaced */, false /* native_mode */,
101 native_mode.ui_scale = 1.0f; 102 1.0 /* ui_scale */, info->device_scale_factor());
102 info->SetDisplayModes(CreateInternalDisplayModeList(native_mode)); 103 info->SetDisplayModes(CreateInternalDisplayModeList(native_mode));
103 } 104 }
104 105
105 void MaybeInitInternalDisplay(DisplayInfo* info) { 106 void MaybeInitInternalDisplay(DisplayInfo* info) {
106 int64_t id = info->id(); 107 int64_t id = info->id();
107 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 108 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
108 if (command_line->HasSwitch(switches::kAshUseFirstDisplayAsInternal)) { 109 if (command_line->HasSwitch(switches::kAshUseFirstDisplayAsInternal)) {
109 display::Display::SetInternalDisplayId(id); 110 display::Display::SetInternalDisplayId(id);
110 SetInternalDisplayModeList(info); 111 SetInternalDisplayModeList(info);
111 } 112 }
112 } 113 }
113 114
114 gfx::Size GetMaxNativeSize(const DisplayInfo& info) { 115 gfx::Size GetMaxNativeSize(const DisplayInfo& info) {
115 gfx::Size size; 116 gfx::Size size;
116 for (auto& mode : info.display_modes()) { 117 for (auto& mode : info.display_modes()) {
117 if (mode.size.GetArea() > size.GetArea()) 118 if (mode->size().GetArea() > size.GetArea())
118 size = mode.size; 119 size = mode->size();
119 } 120 }
120 return size; 121 return size;
121 } 122 }
122 123
123 } // namespace 124 } // namespace
124 125
125 using std::string; 126 using std::string;
126 using std::vector; 127 using std::vector;
127 128
128 // static 129 // static
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 341 }
341 if (is_active) { 342 if (is_active) {
342 AddMirrorDisplayInfoIfAny(&display_info_list); 343 AddMirrorDisplayInfoIfAny(&display_info_list);
343 UpdateDisplaysWith(display_info_list); 344 UpdateDisplaysWith(display_info_list);
344 } else if (display_info_.find(display_id) != display_info_.end()) { 345 } else if (display_info_.find(display_id) != display_info_.end()) {
345 // Inactive displays can reactivate, ensure they have been updated. 346 // Inactive displays can reactivate, ensure they have been updated.
346 display_info_[display_id].SetRotation(rotation, source); 347 display_info_[display_id].SetRotation(rotation, source);
347 } 348 }
348 } 349 }
349 350
350 bool DisplayManager::SetDisplayMode(int64_t display_id, 351 bool DisplayManager::SetDisplayMode(
351 const DisplayMode& display_mode) { 352 int64_t display_id,
353 const scoped_refptr<DisplayMode>& display_mode) {
352 bool change_ui_scale = GetDisplayIdForUIScaling() == display_id; 354 bool change_ui_scale = GetDisplayIdForUIScaling() == display_id;
353 355
354 DisplayInfoList display_info_list; 356 DisplayInfoList display_info_list;
355 bool display_property_changed = false; 357 bool display_property_changed = false;
356 bool resolution_changed = false; 358 bool resolution_changed = false;
357 for (const auto& display : active_display_list_) { 359 for (const auto& display : active_display_list_) {
358 DisplayInfo info = GetDisplayInfo(display.id()); 360 DisplayInfo info = GetDisplayInfo(display.id());
359 if (info.id() == display_id) { 361 if (info.id() == display_id) {
360 auto iter = FindDisplayMode(info, display_mode); 362 auto iter = FindDisplayMode(info, display_mode);
361 if (iter == info.display_modes().end()) { 363 if (iter == info.display_modes().end()) {
362 LOG(WARNING) << "Unsupported display mode was requested:" 364 LOG(WARNING) << "Unsupported display mode was requested:"
363 << "size=" << display_mode.size.ToString() 365 << "size=" << display_mode->size().ToString()
364 << ", ui scale=" << display_mode.ui_scale 366 << ", ui scale=" << display_mode->ui_scale()
365 << ", scale fator=" << display_mode.device_scale_factor; 367 << ", scale factor="
368 << display_mode->device_scale_factor();
366 return false; 369 return false;
367 } 370 }
368 371
369 if (change_ui_scale) { 372 if (change_ui_scale) {
370 if (info.configured_ui_scale() == display_mode.ui_scale) 373 if (info.configured_ui_scale() == display_mode->ui_scale())
371 return true; 374 return true;
372 info.set_configured_ui_scale(display_mode.ui_scale); 375 info.set_configured_ui_scale(display_mode->ui_scale());
373 display_property_changed = true; 376 display_property_changed = true;
374 } else { 377 } else {
375 display_modes_[display_id] = *iter; 378 display_modes_[display_id] = *iter;
376 if (info.bounds_in_native().size() != display_mode.size) 379 if (info.bounds_in_native().size() != display_mode->size())
377 resolution_changed = true; 380 resolution_changed = true;
378 if (info.device_scale_factor() != display_mode.device_scale_factor) { 381 if (info.device_scale_factor() != display_mode->device_scale_factor()) {
379 info.set_device_scale_factor(display_mode.device_scale_factor); 382 info.set_device_scale_factor(display_mode->device_scale_factor());
380 display_property_changed = true; 383 display_property_changed = true;
381 } 384 }
382 } 385 }
383 } 386 }
384 display_info_list.push_back(info); 387 display_info_list.push_back(info);
385 } 388 }
386 if (display_property_changed) { 389 if (display_property_changed) {
387 AddMirrorDisplayInfoIfAny(&display_info_list); 390 AddMirrorDisplayInfoIfAny(&display_info_list);
388 UpdateDisplaysWith(display_info_list); 391 UpdateDisplaysWith(display_info_list);
389 } 392 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // TODO(mukai): register |display_modes_| here as well, so the lookup for the 424 // TODO(mukai): register |display_modes_| here as well, so the lookup for the
422 // default mode in GetActiveModeForDisplayId() gets much simpler. 425 // default mode in GetActiveModeForDisplayId() gets much simpler.
423 if (0.5f <= ui_scale && ui_scale <= 2.0f) 426 if (0.5f <= ui_scale && ui_scale <= 2.0f)
424 display_info_[display_id].set_configured_ui_scale(ui_scale); 427 display_info_[display_id].set_configured_ui_scale(ui_scale);
425 if (overscan_insets) 428 if (overscan_insets)
426 display_info_[display_id].SetOverscanInsets(*overscan_insets); 429 display_info_[display_id].SetOverscanInsets(*overscan_insets);
427 if (!resolution_in_pixels.IsEmpty()) { 430 if (!resolution_in_pixels.IsEmpty()) {
428 DCHECK(!display::Display::IsInternalDisplayId(display_id)); 431 DCHECK(!display::Display::IsInternalDisplayId(display_id));
429 // Default refresh rate, until OnNativeDisplaysChanged() updates us with the 432 // Default refresh rate, until OnNativeDisplaysChanged() updates us with the
430 // actual display info, is 60 Hz. 433 // actual display info, is 60 Hz.
431 DisplayMode mode(resolution_in_pixels, 60.0f, false, false); 434 scoped_refptr<DisplayMode> mode = new DisplayMode(
432 mode.device_scale_factor = device_scale_factor; 435 resolution_in_pixels, 60.0f, false, false, 1.0, device_scale_factor);
433 display_modes_[display_id] = mode; 436 display_modes_[display_id] = mode;
434 } 437 }
435 } 438 }
436 439
437 DisplayMode DisplayManager::GetActiveModeForDisplayId( 440 scoped_refptr<DisplayMode> DisplayManager::GetActiveModeForDisplayId(
438 int64_t display_id) const { 441 int64_t display_id) const {
439 DisplayMode selected_mode; 442 scoped_refptr<DisplayMode> selected_mode(
440 if (GetSelectedModeForDisplayId(display_id, &selected_mode)) 443 GetSelectedModeForDisplayId(display_id));
444 if (selected_mode)
441 return selected_mode; 445 return selected_mode;
442 446
443 // If 'selected' mode is empty, it should return the default mode. This means 447 // If 'selected' mode is empty, it should return the default mode. This means
444 // the native mode for the external display. Unfortunately this is not true 448 // the native mode for the external display. Unfortunately this is not true
445 // for the internal display because restoring UI-scale doesn't register the 449 // for the internal display because restoring UI-scale doesn't register the
446 // restored mode to |display_mode_|, so it needs to look up the mode whose 450 // restored mode to |display_mode_|, so it needs to look up the mode whose
447 // UI-scale value matches. See the TODO in RegisterDisplayProperty(). 451 // UI-scale value matches. See the TODO in RegisterDisplayProperty().
448 const DisplayInfo& info = GetDisplayInfo(display_id); 452 const DisplayInfo& info = GetDisplayInfo(display_id);
449 453
450 for (auto& mode : info.display_modes()) { 454 for (auto& mode : info.display_modes()) {
451 if (GetDisplayIdForUIScaling() == display_id) { 455 if (GetDisplayIdForUIScaling() == display_id) {
452 if (info.configured_ui_scale() == mode.ui_scale) 456 if (info.configured_ui_scale() == mode->ui_scale())
453 return mode; 457 return mode.get();
454 } else if (mode.native) { 458 } else if (mode->native()) {
455 return mode; 459 return mode.get();
456 } 460 }
457 } 461 }
458 return selected_mode; 462 return selected_mode;
459 } 463 }
460 464
461 void DisplayManager::RegisterDisplayRotationProperties( 465 void DisplayManager::RegisterDisplayRotationProperties(
462 bool rotation_lock, 466 bool rotation_lock,
463 display::Display::Rotation rotation) { 467 display::Display::Rotation rotation) {
464 if (delegate_) 468 if (delegate_)
465 delegate_->PreDisplayConfigurationChange(false); 469 delegate_->PreDisplayConfigurationChange(false);
466 registered_internal_display_rotation_lock_ = rotation_lock; 470 registered_internal_display_rotation_lock_ = rotation_lock;
467 registered_internal_display_rotation_ = rotation; 471 registered_internal_display_rotation_ = rotation;
468 if (delegate_) 472 if (delegate_)
469 delegate_->PostDisplayConfigurationChange(); 473 delegate_->PostDisplayConfigurationChange();
470 } 474 }
471 475
472 bool DisplayManager::GetSelectedModeForDisplayId(int64_t id, 476 scoped_refptr<DisplayMode> DisplayManager::GetSelectedModeForDisplayId(
473 DisplayMode* mode_out) const { 477 int64_t id) const {
474 std::map<int64_t, DisplayMode>::const_iterator iter = display_modes_.find(id); 478 std::map<int64_t, scoped_refptr<DisplayMode>>::const_iterator iter =
479 display_modes_.find(id);
475 if (iter == display_modes_.end()) 480 if (iter == display_modes_.end())
476 return false; 481 return scoped_refptr<DisplayMode>();
477 *mode_out = iter->second; 482 return iter->second;
478 return true;
479 } 483 }
480 484
481 bool DisplayManager::IsDisplayUIScalingEnabled() const { 485 bool DisplayManager::IsDisplayUIScalingEnabled() const {
482 return GetDisplayIdForUIScaling() != display::Display::kInvalidDisplayID; 486 return GetDisplayIdForUIScaling() != display::Display::kInvalidDisplayID;
483 } 487 }
484 488
485 gfx::Insets DisplayManager::GetOverscanInsets(int64_t display_id) const { 489 gfx::Insets DisplayManager::GetOverscanInsets(int64_t display_id) const {
486 std::map<int64_t, DisplayInfo>::const_iterator it = 490 std::map<int64_t, DisplayInfo>::const_iterator it =
487 display_info_.find(display_id); 491 display_info_.find(display_id);
488 return (it != display_info_.end()) ? it->second.overscan_insets_in_dip() 492 return (it != display_info_.end()) ? it->second.overscan_insets_in_dip()
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 // Mirrored monitors have the same origins. 566 // Mirrored monitors have the same origins.
563 gfx::Point origin = iter->bounds_in_native().origin(); 567 gfx::Point origin = iter->bounds_in_native().origin();
564 if (origins.find(origin) != origins.end()) { 568 if (origins.find(origin) != origins.end()) {
565 InsertAndUpdateDisplayInfo(*iter); 569 InsertAndUpdateDisplayInfo(*iter);
566 mirroring_display_id_ = iter->id(); 570 mirroring_display_id_ = iter->id();
567 } else { 571 } else {
568 origins.insert(origin); 572 origins.insert(origin);
569 new_display_info_list.push_back(*iter); 573 new_display_info_list.push_back(*iter);
570 } 574 }
571 575
572 DisplayMode new_mode; 576 scoped_refptr<DisplayMode> new_mode(new DisplayMode(
573 new_mode.size = iter->bounds_in_native().size(); 577 iter->bounds_in_native().size(), 0.0 /* refresh rate */,
574 new_mode.device_scale_factor = iter->device_scale_factor(); 578 false /* interlaced */, false /* native */, iter->configured_ui_scale(),
575 new_mode.ui_scale = iter->configured_ui_scale(); 579 iter->device_scale_factor()));
576 const std::vector<DisplayMode>& display_modes = iter->display_modes(); 580 const DisplayInfo::DisplayModeList& display_modes = iter->display_modes();
577 // This is empty the displays are initialized from InitFromCommandLine. 581 // This is empty the displays are initialized from InitFromCommandLine.
578 if (display_modes.empty()) 582 if (display_modes.empty())
579 continue; 583 continue;
580 auto display_modes_iter = FindDisplayMode(*iter, new_mode); 584 auto display_modes_iter = FindDisplayMode(*iter, new_mode);
581 // Update the actual resolution selected as the resolution request may fail. 585 // Update the actual resolution selected as the resolution request may fail.
582 if (display_modes_iter == display_modes.end()) 586 if (display_modes_iter == display_modes.end())
583 display_modes_.erase(iter->id()); 587 display_modes_.erase(iter->id());
584 else if (display_modes_.find(iter->id()) != display_modes_.end()) 588 else if (display_modes_.find(iter->id()) != display_modes_.end())
585 display_modes_[iter->id()] = *display_modes_iter; 589 display_modes_[iter->id()] = *display_modes_iter;
586 } 590 }
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 float default_device_scale_factor = 1.0f; 1122 float default_device_scale_factor = 1.0f;
1119 for (auto& info : *display_info_list) { 1123 for (auto& info : *display_info_list) {
1120 max_height = std::max(max_height, info.size_in_pixel().height()); 1124 max_height = std::max(max_height, info.size_in_pixel().height());
1121 if (!default_height || 1125 if (!default_height ||
1122 display::Display::IsInternalDisplayId(info.id())) { 1126 display::Display::IsInternalDisplayId(info.id())) {
1123 default_height = info.size_in_pixel().height(); 1127 default_height = info.size_in_pixel().height();
1124 default_device_scale_factor = info.device_scale_factor(); 1128 default_device_scale_factor = info.device_scale_factor();
1125 } 1129 }
1126 } 1130 }
1127 1131
1128 std::vector<DisplayMode> display_mode_list; 1132 DisplayInfo::DisplayModeList display_mode_list;
1129 std::set<std::pair<float, float>> dsf_scale_list; 1133 std::set<std::pair<float, float>> dsf_scale_list;
1130 1134
1131 // 2nd Pass. Compute the unified display size. 1135 // 2nd Pass. Compute the unified display size.
1132 for (auto& info : *display_info_list) { 1136 for (auto& info : *display_info_list) {
1133 InsertAndUpdateDisplayInfo(info); 1137 InsertAndUpdateDisplayInfo(info);
1134 gfx::Point origin(unified_bounds.right(), 0); 1138 gfx::Point origin(unified_bounds.right(), 0);
1135 float scale = 1139 float scale =
1136 info.size_in_pixel().height() / static_cast<float>(max_height); 1140 info.size_in_pixel().height() / static_cast<float>(max_height);
1137 // The display is scaled to fit the unified desktop size. 1141 // The display is scaled to fit the unified desktop size.
1138 display::Display display = CreateMirroringDisplayFromDisplayInfoById( 1142 display::Display display = CreateMirroringDisplayFromDisplayInfoById(
1139 info.id(), origin, 1.0f / scale); 1143 info.id(), origin, 1.0f / scale);
1140 unified_bounds.Union(display.bounds()); 1144 unified_bounds.Union(display.bounds());
1141 1145
1142 dsf_scale_list.insert( 1146 dsf_scale_list.insert(
1143 std::make_pair(info.device_scale_factor(), scale)); 1147 std::make_pair(info.device_scale_factor(), scale));
1144 } 1148 }
1145 1149
1146 DisplayInfo info(kUnifiedDisplayId, "Unified Desktop", false); 1150 DisplayInfo info(kUnifiedDisplayId, "Unified Desktop", false);
1147 1151
1148 DisplayMode native_mode(unified_bounds.size(), 60.0f, false, true); 1152 scoped_refptr<DisplayMode> native_mode(
1149 std::vector<DisplayMode> modes = 1153 new DisplayMode(unified_bounds.size(), 60.0f, false, true, 1.0, 1.0));
1154 DisplayInfo::DisplayModeList modes =
1150 CreateUnifiedDisplayModeList(native_mode, dsf_scale_list); 1155 CreateUnifiedDisplayModeList(native_mode, dsf_scale_list);
1151 1156
1152 // Find the default mode. 1157 // Find the default mode.
1153 auto iter = std::find_if( 1158 auto iter = std::find_if(
1154 modes.begin(), modes.end(), 1159 modes.begin(), modes.end(),
1155 [default_height, 1160 [default_height, default_device_scale_factor](
1156 default_device_scale_factor](const DisplayMode& mode) { 1161 const scoped_refptr<DisplayMode>& mode) {
1157 return mode.size.height() == default_height && 1162 return mode->size().height() == default_height &&
1158 mode.device_scale_factor == default_device_scale_factor; 1163 mode->device_scale_factor() == default_device_scale_factor;
1159 }); 1164 });
1160 iter->native = true; 1165
1166 scoped_refptr<DisplayMode> dm(*iter);
1167 *iter = make_scoped_refptr(new DisplayMode(
1168 dm->size(), dm->refresh_rate(), dm->is_interlaced(),
1169 true /* native */, dm->ui_scale(), dm->device_scale_factor()));
1170
1161 info.SetDisplayModes(modes); 1171 info.SetDisplayModes(modes);
1162 info.set_device_scale_factor(iter->device_scale_factor); 1172 info.set_device_scale_factor(dm->device_scale_factor());
1163 info.SetBounds(gfx::Rect(iter->size)); 1173 info.SetBounds(gfx::Rect(dm->size()));
1164 1174
1165 // Forget the configured resolution if the original unified 1175 // Forget the configured resolution if the original unified
1166 // desktop resolution has changed. 1176 // desktop resolution has changed.
1167 if (display_info_.count(kUnifiedDisplayId) != 0 && 1177 if (display_info_.count(kUnifiedDisplayId) != 0 &&
1168 GetMaxNativeSize(display_info_[kUnifiedDisplayId]) != 1178 GetMaxNativeSize(display_info_[kUnifiedDisplayId]) !=
1169 unified_bounds.size()) { 1179 unified_bounds.size()) {
1170 display_modes_.erase(kUnifiedDisplayId); 1180 display_modes_.erase(kUnifiedDisplayId);
1171 } 1181 }
1172 1182
1173 // 3rd Pass. Set the selected mode, then recompute the mirroring 1183 // 3rd Pass. Set the selected mode, then recompute the mirroring
1174 // display size. 1184 // display size.
1175 DisplayMode mode; 1185 scoped_refptr<DisplayMode> mode =
1176 if (GetSelectedModeForDisplayId(kUnifiedDisplayId, &mode) && 1186 GetSelectedModeForDisplayId(kUnifiedDisplayId);
1177 FindDisplayMode(info, mode) != info.display_modes().end()) { 1187 if (mode && FindDisplayMode(info, mode) != info.display_modes().end()) {
1178 info.set_device_scale_factor(mode.device_scale_factor); 1188 info.set_device_scale_factor(mode->device_scale_factor());
1179 info.SetBounds(gfx::Rect(mode.size)); 1189 info.SetBounds(gfx::Rect(mode->size()));
1180 } else { 1190 } else {
1181 display_modes_.erase(kUnifiedDisplayId); 1191 display_modes_.erase(kUnifiedDisplayId);
1182 } 1192 }
1183 1193
1184 int unified_display_height = info.size_in_pixel().height(); 1194 int unified_display_height = info.size_in_pixel().height();
1185 gfx::Point origin; 1195 gfx::Point origin;
1186 for (auto& info : *display_info_list) { 1196 for (auto& info : *display_info_list) {
1187 float display_scale = info.size_in_pixel().height() / 1197 float display_scale = info.size_in_pixel().height() /
1188 static_cast<float>(unified_display_height); 1198 static_cast<float>(unified_display_height);
1189 display::Display display = CreateMirroringDisplayFromDisplayInfoById( 1199 display::Display display = CreateMirroringDisplayFromDisplayInfoById(
(...skipping 12 matching lines...) Expand all
1202 break; 1212 break;
1203 } 1213 }
1204 } 1214 }
1205 1215
1206 display::Display* DisplayManager::FindDisplayForId(int64_t id) { 1216 display::Display* DisplayManager::FindDisplayForId(int64_t id) {
1207 auto iter = std::find_if( 1217 auto iter = std::find_if(
1208 active_display_list_.begin(), active_display_list_.end(), 1218 active_display_list_.begin(), active_display_list_.end(),
1209 [id](const display::Display& display) { return display.id() == id; }); 1219 [id](const display::Display& display) { return display.id() == id; });
1210 if (iter != active_display_list_.end()) 1220 if (iter != active_display_list_.end())
1211 return &(*iter); 1221 return &(*iter);
1212 // TODO(oshima): This happens when a windows in unified desktop have 1222 // TODO(oshima): This happens when windows in unified desktop have
1213 // been moved to normal window. Fix this. 1223 // been moved to a normal window. Fix this.
1214 if (id != kUnifiedDisplayId) 1224 if (id != kUnifiedDisplayId)
1215 DLOG(WARNING) << "Could not find display:" << id; 1225 DLOG(WARNING) << "Could not find display:" << id;
1216 return nullptr; 1226 return nullptr;
1217 } 1227 }
1218 1228
1219 void DisplayManager::AddMirrorDisplayInfoIfAny( 1229 void DisplayManager::AddMirrorDisplayInfoIfAny(
1220 std::vector<DisplayInfo>* display_info_list) { 1230 std::vector<DisplayInfo>* display_info_list) {
1221 if (software_mirroring_enabled() && IsInMirrorMode()) { 1231 if (software_mirroring_enabled() && IsInMirrorMode()) {
1222 display_info_list->push_back(GetDisplayInfo(mirroring_display_id_)); 1232 display_info_list->push_back(GetDisplayInfo(mirroring_display_id_));
1223 software_mirroring_display_list_.clear(); 1233 software_mirroring_display_list_.clear();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 layout.ApplyToDisplayList(display_list, updated_ids, 1344 layout.ApplyToDisplayList(display_list, updated_ids,
1335 kMinimumOverlapForInvalidOffset); 1345 kMinimumOverlapForInvalidOffset);
1336 } 1346 }
1337 1347
1338 void DisplayManager::RunPendingTasksForTest() { 1348 void DisplayManager::RunPendingTasksForTest() {
1339 if (!software_mirroring_display_list_.empty()) 1349 if (!software_mirroring_display_list_.empty())
1340 base::RunLoop().RunUntilIdle(); 1350 base::RunLoop().RunUntilIdle();
1341 } 1351 }
1342 1352
1343 } // namespace ash 1353 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698