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

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

Issue 1263853002: Unified Desktop: Support 2xDSF display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility>
11 #include <vector> 12 #include <vector>
12 13
13 #include "ash/ash_switches.h" 14 #include "ash/ash_switches.h"
14 #include "ash/display/display_layout_store.h" 15 #include "ash/display/display_layout_store.h"
15 #include "ash/display/display_util.h" 16 #include "ash/display/display_util.h"
16 #include "ash/display/extended_mouse_warp_controller.h" 17 #include "ash/display/extended_mouse_warp_controller.h"
17 #include "ash/display/null_mouse_warp_controller.h" 18 #include "ash/display/null_mouse_warp_controller.h"
18 #include "ash/display/screen_ash.h" 19 #include "ash/display/screen_ash.h"
19 #include "ash/display/unified_mouse_warp_controller.h" 20 #include "ash/display/unified_mouse_warp_controller.h"
20 #include "ash/screen_util.h" 21 #include "ash/screen_util.h"
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 } 1108 }
1108 case UNIFIED: { 1109 case UNIFIED: {
1109 // TODO(oshima): Currently, all displays are laid out horizontally, 1110 // TODO(oshima): Currently, all displays are laid out horizontally,
1110 // from left to right. Allow more flexible layouts, such as 1111 // from left to right. Allow more flexible layouts, such as
1111 // right to left, or vertical layouts. 1112 // right to left, or vertical layouts.
1112 gfx::Rect unified_bounds; 1113 gfx::Rect unified_bounds;
1113 software_mirroring_display_list_.clear(); 1114 software_mirroring_display_list_.clear();
1114 1115
1115 // 1st Pass. Find the max size. 1116 // 1st Pass. Find the max size.
1116 int max_height = std::numeric_limits<int>::min(); 1117 int max_height = std::numeric_limits<int>::min();
1117 for (auto& info : *display_info_list) 1118 float default_device_scale_factor = 1.0f;
1118 max_height = std::max(max_height, info.size_in_pixel().height()); 1119
1120 for (auto& info : *display_info_list) {
1121 if (max_height < info.size_in_pixel().height()) {
1122 max_height = info.size_in_pixel().height();
1123 default_device_scale_factor = info.device_scale_factor();
Jun Mukai 2015/07/29 21:26:28 This means that if two displays are in the same he
oshima 2015/07/30 01:33:31 Per offline discussion, changed to use the 1st or
1124 }
1125 }
1119 1126
1120 std::vector<DisplayMode> display_mode_list; 1127 std::vector<DisplayMode> display_mode_list;
1121 std::set<float> scales; 1128 std::set<std::pair<float, float>> dsf_scale_list;
1122 1129
1123 // 2nd Pass. Compute the unified display size. 1130 // 2nd Pass. Compute the unified display size.
1124 for (auto& info : *display_info_list) { 1131 for (auto& info : *display_info_list) {
1125 InsertAndUpdateDisplayInfo(info); 1132 InsertAndUpdateDisplayInfo(info);
1126 gfx::Point origin(unified_bounds.right(), 0); 1133 gfx::Point origin(unified_bounds.right(), 0);
1127 float scale = 1134 float scale =
1128 info.size_in_pixel().height() / static_cast<float>(max_height); 1135 info.size_in_pixel().height() / static_cast<float>(max_height);
1129 // The display is scaled to fit the unified desktop size. 1136 // The display is scaled to fit the unified desktop size.
1130 gfx::Display display = CreateMirroringDisplayFromDisplayInfoById( 1137 gfx::Display display = CreateMirroringDisplayFromDisplayInfoById(
1131 info.id(), origin, 1.0f / scale); 1138 info.id(), origin, 1.0f / scale);
1132 unified_bounds.Union(display.bounds()); 1139 unified_bounds.Union(display.bounds());
1133 1140
1134 scales.insert(scale); 1141 dsf_scale_list.insert(
1142 std::make_pair(info.device_scale_factor(), scale));
Jun Mukai 2015/07/29 21:26:28 Also, can we add a case of dsf=1.0 as an option?
oshima 2015/07/30 01:33:32 Let's wait for user's feedback. My guess is that u
1135 } 1143 }
1136 1144
1137 DisplayInfo info(kUnifiedDisplayId, "Unified Desktop", false); 1145 DisplayInfo info(kUnifiedDisplayId, "Unified Desktop", false);
1146 info.set_device_scale_factor(default_device_scale_factor);
1138 info.SetBounds(unified_bounds); 1147 info.SetBounds(unified_bounds);
1139 1148
1140 DisplayMode native_mode(unified_bounds.size(), 60.0f, false, true); 1149 DisplayMode native_mode(unified_bounds.size(), 60.0f, false, true);
1141 info.SetDisplayModes(CreateUnifiedDisplayModeList(native_mode, scales)); 1150 info.SetDisplayModes(
1151 CreateUnifiedDisplayModeList(native_mode, dsf_scale_list));
1142 1152
1143 // Forget the configured resolution if the original unified 1153 // Forget the configured resolution if the original unified
1144 // desktop resolution has changed. 1154 // desktop resolution has changed.
1145 if (display_info_.count(kUnifiedDisplayId) != 0 && 1155 if (display_info_.count(kUnifiedDisplayId) != 0 &&
1146 display_info_[kUnifiedDisplayId].size_in_pixel() != 1156 display_info_[kUnifiedDisplayId].size_in_pixel() !=
1147 info.size_in_pixel()) { 1157 info.size_in_pixel()) {
1148 display_modes_.erase(kUnifiedDisplayId); 1158 display_modes_.erase(kUnifiedDisplayId);
1149 } 1159 }
1150 1160
1151 // 3rd Pass. Set the selected mode, then recompute the mirroring 1161 // 3rd Pass. Set the selected mode, then recompute the mirroring
1152 // display size. 1162 // display size.
1153 DisplayMode mode; 1163 DisplayMode mode;
1154 if (GetSelectedModeForDisplayId(kUnifiedDisplayId, &mode) && 1164 if (GetSelectedModeForDisplayId(kUnifiedDisplayId, &mode) &&
1155 FindDisplayMode(info, mode) != info.display_modes().end()) { 1165 FindDisplayMode(info, mode) != info.display_modes().end()) {
1156 // TODO(oshima): device scale factor. 1166 info.set_device_scale_factor(mode.device_scale_factor);
1157 info.SetBounds(gfx::Rect(mode.size)); 1167 info.SetBounds(gfx::Rect(mode.size));
1158 } else { 1168 } else {
1159 display_modes_.erase(kUnifiedDisplayId); 1169 display_modes_.erase(kUnifiedDisplayId);
1160 } 1170 }
1161 1171
1162 int unified_display_height = info.size_in_pixel().height(); 1172 int unified_display_height = info.size_in_pixel().height();
1163 gfx::Point origin; 1173 gfx::Point origin;
1164 for (auto& info : *display_info_list) { 1174 for (auto& info : *display_info_list) {
1165 float display_scale = info.size_in_pixel().height() / 1175 float display_scale = info.size_in_pixel().height() /
1166 static_cast<float>(unified_display_height); 1176 static_cast<float>(unified_display_height);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 gfx::Rect(new_secondary_origin, secondary_bounds.size())); 1377 gfx::Rect(new_secondary_origin, secondary_bounds.size()));
1368 secondary_display->UpdateWorkAreaFromInsets(insets); 1378 secondary_display->UpdateWorkAreaFromInsets(insets);
1369 } 1379 }
1370 1380
1371 void DisplayManager::RunPendingTasksForTest() { 1381 void DisplayManager::RunPendingTasksForTest() {
1372 if (!software_mirroring_display_list_.empty()) 1382 if (!software_mirroring_display_list_.empty())
1373 base::RunLoop().RunUntilIdle(); 1383 base::RunLoop().RunUntilIdle();
1374 } 1384 }
1375 1385
1376 } // namespace ash 1386 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698