OLD | NEW |
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 <cmath> | 7 #include <cmath> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // The number of pixels to overlap between the primary and secondary displays, | 58 // The number of pixels to overlap between the primary and secondary displays, |
59 // in case that the offset value is too large. | 59 // in case that the offset value is too large. |
60 const int kMinimumOverlapForInvalidOffset = 100; | 60 const int kMinimumOverlapForInvalidOffset = 100; |
61 | 61 |
62 // List of value UI Scale values. Scales for 2x are equivalent to 640, | 62 // List of value UI Scale values. Scales for 2x are equivalent to 640, |
63 // 800, 1024, 1280, 1440, 1600 and 1920 pixel width respectively on | 63 // 800, 1024, 1280, 1440, 1600 and 1920 pixel width respectively on |
64 // 2560 pixel width 2x density display. Please see crbug.com/233375 | 64 // 2560 pixel width 2x density display. Please see crbug.com/233375 |
65 // for the full list of resolutions. | 65 // for the full list of resolutions. |
66 const float kUIScalesFor2x[] = | 66 const float kUIScalesFor2x[] = |
67 {0.5f, 0.625f, 0.8f, 1.0f, 1.125f, 1.25f, 1.5f, 2.0f}; | 67 {0.5f, 0.625f, 0.8f, 1.0f, 1.125f, 1.25f, 1.5f, 2.0f}; |
| 68 const float kUIScalesFor1_25x[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.25f }; |
68 const float kUIScalesFor1280[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.125f }; | 69 const float kUIScalesFor1280[] = {0.5f, 0.625f, 0.8f, 1.0f, 1.125f }; |
69 const float kUIScalesFor1366[] = {0.5f, 0.6f, 0.75f, 1.0f, 1.125f }; | 70 const float kUIScalesFor1366[] = {0.5f, 0.6f, 0.75f, 1.0f, 1.125f }; |
70 | 71 |
71 struct DisplaySortFunctor { | 72 struct DisplaySortFunctor { |
72 bool operator()(const gfx::Display& a, const gfx::Display& b) { | 73 bool operator()(const gfx::Display& a, const gfx::Display& b) { |
73 return a.id() < b.id(); | 74 return a.id() < b.id(); |
74 } | 75 } |
75 }; | 76 }; |
76 | 77 |
77 struct DisplayInfoSortFunctor { | 78 struct DisplayInfoSortFunctor { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 screen_ash_.get()); | 177 screen_ash_.get()); |
177 } | 178 } |
178 } | 179 } |
179 | 180 |
180 DisplayManager::~DisplayManager() { | 181 DisplayManager::~DisplayManager() { |
181 } | 182 } |
182 | 183 |
183 // static | 184 // static |
184 std::vector<float> DisplayManager::GetScalesForDisplay( | 185 std::vector<float> DisplayManager::GetScalesForDisplay( |
185 const DisplayInfo& info) { | 186 const DisplayInfo& info) { |
| 187 |
| 188 #define ASSIGN_ARRAY(v, a) v.assign(a, a + arraysize(a)) |
| 189 |
186 std::vector<float> ret; | 190 std::vector<float> ret; |
187 if (info.device_scale_factor() == 2.0f) { | 191 if (info.device_scale_factor() == 2.0f) { |
188 ret.assign(kUIScalesFor2x, kUIScalesFor2x + arraysize(kUIScalesFor2x)); | 192 ASSIGN_ARRAY(ret, kUIScalesFor2x); |
| 193 return ret; |
| 194 } else if (info.device_scale_factor() == 1.25f) { |
| 195 ASSIGN_ARRAY(ret, kUIScalesFor1_25x); |
189 return ret; | 196 return ret; |
190 } | 197 } |
191 switch (info.bounds_in_native().width()) { | 198 switch (info.bounds_in_native().width()) { |
192 case 1280: | 199 case 1280: |
193 ret.assign(kUIScalesFor1280, | 200 ASSIGN_ARRAY(ret, kUIScalesFor1280); |
194 kUIScalesFor1280 + arraysize(kUIScalesFor1280)); | |
195 break; | 201 break; |
196 case 1366: | 202 case 1366: |
197 ret.assign(kUIScalesFor1366, | 203 ASSIGN_ARRAY(ret, kUIScalesFor1366); |
198 kUIScalesFor1366 + arraysize(kUIScalesFor1366)); | |
199 break; | 204 break; |
200 default: | 205 default: |
201 ret.assign(kUIScalesFor1280, | 206 ASSIGN_ARRAY(ret, kUIScalesFor1280); |
202 kUIScalesFor1280 + arraysize(kUIScalesFor1280)); | |
203 #if defined(OS_CHROMEOS) | 207 #if defined(OS_CHROMEOS) |
204 if (base::SysInfo::IsRunningOnChromeOS()) | 208 if (base::SysInfo::IsRunningOnChromeOS()) |
205 NOTREACHED() << "Unknown resolution:" << info.ToString(); | 209 NOTREACHED() << "Unknown resolution:" << info.ToString(); |
206 #endif | 210 #endif |
207 } | 211 } |
208 return ret; | 212 return ret; |
209 } | 213 } |
210 | 214 |
211 // static | 215 // static |
212 float DisplayManager::GetNextUIScale(const DisplayInfo& info, bool up) { | 216 float DisplayManager::GetNextUIScale(const DisplayInfo& info, bool up) { |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 new_secondary_origin.Offset(-secondary_bounds.width(), offset); | 1144 new_secondary_origin.Offset(-secondary_bounds.width(), offset); |
1141 break; | 1145 break; |
1142 } | 1146 } |
1143 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); | 1147 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); |
1144 secondary_display->set_bounds( | 1148 secondary_display->set_bounds( |
1145 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 1149 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
1146 secondary_display->UpdateWorkAreaFromInsets(insets); | 1150 secondary_display->UpdateWorkAreaFromInsets(insets); |
1147 } | 1151 } |
1148 | 1152 |
1149 } // namespace ash | 1153 } // namespace ash |
OLD | NEW |