Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 num_connected_displays_(0), | 161 num_connected_displays_(0), |
| 162 force_bounds_changed_(false), | 162 force_bounds_changed_(false), |
| 163 change_display_upon_host_resize_(false), | 163 change_display_upon_host_resize_(false), |
| 164 second_display_mode_(EXTENDED), | 164 second_display_mode_(EXTENDED), |
| 165 mirrored_display_id_(gfx::Display::kInvalidDisplayID), | 165 mirrored_display_id_(gfx::Display::kInvalidDisplayID), |
| 166 registered_internal_display_rotation_lock_(false), | 166 registered_internal_display_rotation_lock_(false), |
| 167 registered_internal_display_rotation_(gfx::Display::ROTATE_0) { | 167 registered_internal_display_rotation_(gfx::Display::ROTATE_0) { |
| 168 #if defined(OS_CHROMEOS) | 168 #if defined(OS_CHROMEOS) |
| 169 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS(); | 169 change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS(); |
| 170 #endif | 170 #endif |
| 171 DisplayInfo::SetAllowUpgradeToHighDPI( | |
| 172 ui::ResourceBundle::GetSharedInstance().GetMaxScaleFactor() == | |
| 173 ui::SCALE_FACTOR_200P); | |
| 174 | |
|
oshima
2014/09/16 17:11:42
I also want to remove this, as installing 2x asset
Jun Mukai
2014/09/16 18:18:56
Removing this means allow_upgrade_to_high_dpi neve
oshima
2014/09/16 18:47:15
Pixel doesn't rely on this as its dfs is 2x.
| |
| 175 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, | 171 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, |
| 176 screen_ash_.get()); | 172 screen_ash_.get()); |
| 177 gfx::Screen* current_native = | 173 gfx::Screen* current_native = |
| 178 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); | 174 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); |
| 179 // If there is no native, or the native was for shutdown, | 175 // If there is no native, or the native was for shutdown, |
| 180 // use ash's screen. | 176 // use ash's screen. |
| 181 if (!current_native || | 177 if (!current_native || |
| 182 current_native == screen_for_shutdown) { | 178 current_native == screen_for_shutdown) { |
| 183 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, | 179 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, |
| 184 screen_ash_.get()); | 180 screen_ash_.get()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 241 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 246 if (!command_line->HasSwitch(switches::kAshHostWindowBounds)) | 242 if (!command_line->HasSwitch(switches::kAshHostWindowBounds)) |
| 247 return false; | 243 return false; |
| 248 const string size_str = | 244 const string size_str = |
| 249 command_line->GetSwitchValueASCII(switches::kAshHostWindowBounds); | 245 command_line->GetSwitchValueASCII(switches::kAshHostWindowBounds); |
| 250 vector<string> parts; | 246 vector<string> parts; |
| 251 base::SplitString(size_str, ',', &parts); | 247 base::SplitString(size_str, ',', &parts); |
| 252 for (vector<string>::const_iterator iter = parts.begin(); | 248 for (vector<string>::const_iterator iter = parts.begin(); |
| 253 iter != parts.end(); ++iter) { | 249 iter != parts.end(); ++iter) { |
| 254 info_list.push_back(DisplayInfo::CreateFromSpec(*iter)); | 250 info_list.push_back(DisplayInfo::CreateFromSpec(*iter)); |
| 251 info_list.back().set_native(true); | |
| 255 } | 252 } |
| 256 MaybeInitInternalDisplay(info_list[0].id()); | 253 MaybeInitInternalDisplay(info_list[0].id()); |
| 257 if (info_list.size() > 1 && | 254 if (info_list.size() > 1 && |
| 258 command_line->HasSwitch(switches::kAshEnableSoftwareMirroring)) { | 255 command_line->HasSwitch(switches::kAshEnableSoftwareMirroring)) { |
| 259 SetSecondDisplayMode(MIRRORING); | 256 SetSecondDisplayMode(MIRRORING); |
| 260 } | 257 } |
| 261 OnNativeDisplaysChanged(info_list); | 258 OnNativeDisplaysChanged(info_list); |
| 262 return true; | 259 return true; |
| 263 } | 260 } |
| 264 | 261 |
| 265 void DisplayManager::InitDefaultDisplay() { | 262 void DisplayManager::InitDefaultDisplay() { |
| 266 DisplayInfoList info_list; | 263 DisplayInfoList info_list; |
| 267 info_list.push_back(DisplayInfo::CreateFromSpec(std::string())); | 264 info_list.push_back(DisplayInfo::CreateFromSpec(std::string())); |
| 265 info_list.back().set_native(true); | |
| 268 MaybeInitInternalDisplay(info_list[0].id()); | 266 MaybeInitInternalDisplay(info_list[0].id()); |
| 269 OnNativeDisplaysChanged(info_list); | 267 OnNativeDisplaysChanged(info_list); |
| 270 } | 268 } |
| 271 | 269 |
| 272 void DisplayManager::InitFontParams() { | 270 void DisplayManager::InitFontParams() { |
| 273 #if defined(OS_CHROMEOS) | 271 #if defined(OS_CHROMEOS) |
| 274 if (!HasInternalDisplay()) | 272 if (!HasInternalDisplay()) |
| 275 return; | 273 return; |
| 276 const DisplayInfo& display_info = | 274 const DisplayInfo& display_info = |
| 277 GetDisplayInfo(gfx::Display::InternalDisplayId()); | 275 GetDisplayInfo(gfx::Display::InternalDisplayId()); |
| 278 gfx::SetFontRenderParamsDeviceScaleFactor( | 276 gfx::SetFontRenderParamsDeviceScaleFactor( |
| 279 display_info.device_scale_factor()); | 277 display_info.GetEffectiveDeviceScaleFactor()); |
| 280 #endif // OS_CHROMEOS | 278 #endif // OS_CHROMEOS |
| 281 } | 279 } |
| 282 | 280 |
| 283 // static | 281 // static |
| 284 void DisplayManager::UpdateDisplayBoundsForLayoutById( | 282 void DisplayManager::UpdateDisplayBoundsForLayoutById( |
| 285 const DisplayLayout& layout, | 283 const DisplayLayout& layout, |
| 286 const gfx::Display& primary_display, | 284 const gfx::Display& primary_display, |
| 287 int64 secondary_display_id) { | 285 int64 secondary_display_id) { |
| 288 DCHECK_NE(gfx::Display::kInvalidDisplayID, secondary_display_id); | 286 DCHECK_NE(gfx::Display::kInvalidDisplayID, secondary_display_id); |
| 289 UpdateDisplayBoundsForLayout( | 287 UpdateDisplayBoundsForLayout( |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1259 new_secondary_origin.Offset(-secondary_bounds.width(), offset); | 1257 new_secondary_origin.Offset(-secondary_bounds.width(), offset); |
| 1260 break; | 1258 break; |
| 1261 } | 1259 } |
| 1262 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); | 1260 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); |
| 1263 secondary_display->set_bounds( | 1261 secondary_display->set_bounds( |
| 1264 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 1262 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
| 1265 secondary_display->UpdateWorkAreaFromInsets(insets); | 1263 secondary_display->UpdateWorkAreaFromInsets(insets); |
| 1266 } | 1264 } |
| 1267 | 1265 |
| 1268 } // namespace ash | 1266 } // namespace ash |
| OLD | NEW |