| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stdio.h> | 5 #include <stdio.h> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/display/display_info.h" | 9 #include "ash/display/display_info.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "ui/gfx/display.h" | 15 #include "ui/gfx/display.h" |
| 16 #include "ui/gfx/geometry/size_conversions.h" | 16 #include "ui/gfx/geometry/size_conversions.h" |
| 17 #include "ui/gfx/geometry/size_f.h" | 17 #include "ui/gfx/geometry/size_f.h" |
| 18 | 18 |
| 19 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 20 #include "ui/aura/window_tree_host.h" | 20 #include "ui/aura/window_tree_host.h" |
| 21 #include "ui/gfx/win/dpi.h" | 21 #include "ui/gfx/win/dpi.h" |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 namespace ash { | 24 namespace ash { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // Use larger than max int to catch overflow early. | 27 // Use larger than max int to catch overflow early. |
| 28 const int64 kSynthesizedDisplayIdStart = 2200000000LL; | 28 const int64_t kSynthesizedDisplayIdStart = 2200000000LL; |
| 29 | 29 |
| 30 int64 synthesized_display_id = kSynthesizedDisplayIdStart; | 30 int64_t synthesized_display_id = kSynthesizedDisplayIdStart; |
| 31 | 31 |
| 32 const float kDpi96 = 96.0; | 32 const float kDpi96 = 96.0; |
| 33 bool use_125_dsf_for_ui_scaling = true; | 33 bool use_125_dsf_for_ui_scaling = true; |
| 34 | 34 |
| 35 // Check the content of |spec| and fill |bounds| and |device_scale_factor|. | 35 // Check the content of |spec| and fill |bounds| and |device_scale_factor|. |
| 36 // Returns true when |bounds| is found. | 36 // Returns true when |bounds| is found. |
| 37 bool GetDisplayBounds( | 37 bool GetDisplayBounds( |
| 38 const std::string& spec, gfx::Rect* bounds, float* device_scale_factor) { | 38 const std::string& spec, gfx::Rect* bounds, float* device_scale_factor) { |
| 39 int width = 0; | 39 int width = 0; |
| 40 int height = 0; | 40 int height = 0; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 std::abs(device_scale_factor - other.device_scale_factor) < kEpsilon; | 105 std::abs(device_scale_factor - other.device_scale_factor) < kEpsilon; |
| 106 } | 106 } |
| 107 | 107 |
| 108 // satic | 108 // satic |
| 109 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) { | 109 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) { |
| 110 return CreateFromSpecWithID(spec, gfx::Display::kInvalidDisplayID); | 110 return CreateFromSpecWithID(spec, gfx::Display::kInvalidDisplayID); |
| 111 } | 111 } |
| 112 | 112 |
| 113 // static | 113 // static |
| 114 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, | 114 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, |
| 115 int64 id) { | 115 int64_t id) { |
| 116 #if defined(OS_WIN) | 116 #if defined(OS_WIN) |
| 117 gfx::Rect bounds_in_native( | 117 gfx::Rect bounds_in_native( |
| 118 gfx::Size(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN))); | 118 gfx::Size(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN))); |
| 119 #else | 119 #else |
| 120 // Default bounds for a display. | 120 // Default bounds for a display. |
| 121 const int kDefaultHostWindowX = 200; | 121 const int kDefaultHostWindowX = 200; |
| 122 const int kDefaultHostWindowY = 200; | 122 const int kDefaultHostWindowY = 200; |
| 123 const int kDefaultHostWindowWidth = 1366; | 123 const int kDefaultHostWindowWidth = 1366; |
| 124 const int kDefaultHostWindowHeight = 768; | 124 const int kDefaultHostWindowHeight = 768; |
| 125 gfx::Rect bounds_in_native(kDefaultHostWindowX, kDefaultHostWindowY, | 125 gfx::Rect bounds_in_native(kDefaultHostWindowX, kDefaultHostWindowY, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), | 240 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), |
| 241 device_scale_factor_(1.0f), | 241 device_scale_factor_(1.0f), |
| 242 device_dpi_(kDpi96), | 242 device_dpi_(kDpi96), |
| 243 overscan_insets_in_dip_(0, 0, 0, 0), | 243 overscan_insets_in_dip_(0, 0, 0, 0), |
| 244 configured_ui_scale_(1.0f), | 244 configured_ui_scale_(1.0f), |
| 245 native_(false), | 245 native_(false), |
| 246 is_aspect_preserving_scaling_(false), | 246 is_aspect_preserving_scaling_(false), |
| 247 clear_overscan_insets_(false), | 247 clear_overscan_insets_(false), |
| 248 color_profile_(ui::COLOR_PROFILE_STANDARD) {} | 248 color_profile_(ui::COLOR_PROFILE_STANDARD) {} |
| 249 | 249 |
| 250 DisplayInfo::DisplayInfo(int64 id, const std::string& name, bool has_overscan) | 250 DisplayInfo::DisplayInfo(int64_t id, const std::string& name, bool has_overscan) |
| 251 : id_(id), | 251 : id_(id), |
| 252 name_(name), | 252 name_(name), |
| 253 has_overscan_(has_overscan), | 253 has_overscan_(has_overscan), |
| 254 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), | 254 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), |
| 255 device_scale_factor_(1.0f), | 255 device_scale_factor_(1.0f), |
| 256 device_dpi_(kDpi96), | 256 device_dpi_(kDpi96), |
| 257 overscan_insets_in_dip_(0, 0, 0, 0), | 257 overscan_insets_in_dip_(0, 0, 0, 0), |
| 258 configured_ui_scale_(1.0f), | 258 configured_ui_scale_(1.0f), |
| 259 native_(false), | 259 native_(false), |
| 260 is_aspect_preserving_scaling_(false), | 260 is_aspect_preserving_scaling_(false), |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 446 |
| 447 void DisplayInfo::ClearInputDevices() { | 447 void DisplayInfo::ClearInputDevices() { |
| 448 input_devices_.clear(); | 448 input_devices_.clear(); |
| 449 } | 449 } |
| 450 | 450 |
| 451 void ResetDisplayIdForTest() { | 451 void ResetDisplayIdForTest() { |
| 452 synthesized_display_id = kSynthesizedDisplayIdStart; | 452 synthesized_display_id = kSynthesizedDisplayIdStart; |
| 453 } | 453 } |
| 454 | 454 |
| 455 } // namespace ash | 455 } // namespace ash |
| OLD | NEW |