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

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

Powered by Google App Engine
This is Rietveld 408576698