| 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 11 matching lines...) Expand all Loading... |
| 22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/string_split.h" | 23 #include "base/strings/string_split.h" |
| 24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| 26 #include "grit/ash_strings.h" | 26 #include "grit/ash_strings.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/layout.h" | 28 #include "ui/base/layout.h" |
| 29 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| 30 #include "ui/gfx/display.h" | 30 #include "ui/gfx/display.h" |
| 31 #include "ui/gfx/display_observer.h" | 31 #include "ui/gfx/display_observer.h" |
| 32 #include "ui/gfx/font_render_params.h" |
| 32 #include "ui/gfx/rect.h" | 33 #include "ui/gfx/rect.h" |
| 33 #include "ui/gfx/screen.h" | 34 #include "ui/gfx/screen.h" |
| 34 #include "ui/gfx/size_conversions.h" | 35 #include "ui/gfx/size_conversions.h" |
| 35 | 36 |
| 36 #if defined(USE_X11) | 37 #if defined(USE_X11) |
| 37 #include "ui/base/x/x11_util.h" | 38 #include "ui/base/x/x11_util.h" |
| 38 #endif | 39 #endif |
| 39 | 40 |
| 40 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
| 41 #include "ash/display/display_configurator_animation.h" | 42 #include "ash/display/display_configurator_animation.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // If there is no native, or the native was for shutdown, | 177 // If there is no native, or the native was for shutdown, |
| 177 // use ash's screen. | 178 // use ash's screen. |
| 178 if (!current_native || | 179 if (!current_native || |
| 179 current_native == screen_for_shutdown) { | 180 current_native == screen_for_shutdown) { |
| 180 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, | 181 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, |
| 181 screen_ash_.get()); | 182 screen_ash_.get()); |
| 182 } | 183 } |
| 183 } | 184 } |
| 184 | 185 |
| 185 DisplayManager::~DisplayManager() { | 186 DisplayManager::~DisplayManager() { |
| 187 #if defined(OS_CHROMEOS) |
| 188 // Reset the font params. |
| 189 gfx::SetFontRenderParamsDeviceScaleFactor(1.0f); |
| 190 #endif |
| 186 } | 191 } |
| 187 | 192 |
| 188 // static | 193 // static |
| 189 std::vector<float> DisplayManager::GetScalesForDisplay( | 194 std::vector<float> DisplayManager::GetScalesForDisplay( |
| 190 const DisplayInfo& info) { | 195 const DisplayInfo& info) { |
| 191 | 196 |
| 192 #define ASSIGN_ARRAY(v, a) v.assign(a, a + arraysize(a)) | 197 #define ASSIGN_ARRAY(v, a) v.assign(a, a + arraysize(a)) |
| 193 | 198 |
| 194 std::vector<float> ret; | 199 std::vector<float> ret; |
| 195 if (info.device_scale_factor() == 2.0f) { | 200 if (info.device_scale_factor() == 2.0f) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 return true; | 260 return true; |
| 256 } | 261 } |
| 257 | 262 |
| 258 void DisplayManager::InitDefaultDisplay() { | 263 void DisplayManager::InitDefaultDisplay() { |
| 259 DisplayInfoList info_list; | 264 DisplayInfoList info_list; |
| 260 info_list.push_back(DisplayInfo::CreateFromSpec(std::string())); | 265 info_list.push_back(DisplayInfo::CreateFromSpec(std::string())); |
| 261 MaybeInitInternalDisplay(info_list[0].id()); | 266 MaybeInitInternalDisplay(info_list[0].id()); |
| 262 OnNativeDisplaysChanged(info_list); | 267 OnNativeDisplaysChanged(info_list); |
| 263 } | 268 } |
| 264 | 269 |
| 270 void DisplayManager::InitFontParams() { |
| 271 #if defined(OS_CHROMEOS) |
| 272 if (!HasInternalDisplay()) |
| 273 return; |
| 274 const DisplayInfo& display_info = |
| 275 GetDisplayInfo(gfx::Display::InternalDisplayId()); |
| 276 gfx::SetFontRenderParamsDeviceScaleFactor( |
| 277 display_info.device_scale_factor()); |
| 278 #endif // OS_CHROMEOS |
| 279 } |
| 280 |
| 265 // static | 281 // static |
| 266 void DisplayManager::UpdateDisplayBoundsForLayoutById( | 282 void DisplayManager::UpdateDisplayBoundsForLayoutById( |
| 267 const DisplayLayout& layout, | 283 const DisplayLayout& layout, |
| 268 const gfx::Display& primary_display, | 284 const gfx::Display& primary_display, |
| 269 int64 secondary_display_id) { | 285 int64 secondary_display_id) { |
| 270 DCHECK_NE(gfx::Display::kInvalidDisplayID, secondary_display_id); | 286 DCHECK_NE(gfx::Display::kInvalidDisplayID, secondary_display_id); |
| 271 UpdateDisplayBoundsForLayout( | 287 UpdateDisplayBoundsForLayout( |
| 272 layout, primary_display, | 288 layout, primary_display, |
| 273 Shell::GetInstance()->display_manager()-> | 289 Shell::GetInstance()->display_manager()-> |
| 274 FindDisplayForId(secondary_display_id)); | 290 FindDisplayForId(secondary_display_id)); |
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 new_secondary_origin.Offset(-secondary_bounds.width(), offset); | 1247 new_secondary_origin.Offset(-secondary_bounds.width(), offset); |
| 1232 break; | 1248 break; |
| 1233 } | 1249 } |
| 1234 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); | 1250 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); |
| 1235 secondary_display->set_bounds( | 1251 secondary_display->set_bounds( |
| 1236 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 1252 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
| 1237 secondary_display->UpdateWorkAreaFromInsets(insets); | 1253 secondary_display->UpdateWorkAreaFromInsets(insets); |
| 1238 } | 1254 } |
| 1239 | 1255 |
| 1240 } // namespace ash | 1256 } // namespace ash |
| OLD | NEW |