| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 kSynthesizedDisplayIdStart = 2200000000LL; |
| 29 | 29 |
| 30 int64 synthesized_display_id = kSynthesizedDisplayIdStart; | 30 int64 synthesized_display_id = kSynthesizedDisplayIdStart; |
| 31 | 31 |
| 32 const float kDpi96 = 96.0; |
| 32 bool use_125_dsf_for_ui_scaling = true; | 33 bool use_125_dsf_for_ui_scaling = true; |
| 33 | 34 |
| 34 // 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|. |
| 35 // Returns true when |bounds| is found. | 36 // Returns true when |bounds| is found. |
| 36 bool GetDisplayBounds( | 37 bool GetDisplayBounds( |
| 37 const std::string& spec, gfx::Rect* bounds, float* device_scale_factor) { | 38 const std::string& spec, gfx::Rect* bounds, float* device_scale_factor) { |
| 38 int width = 0; | 39 int width = 0; |
| 39 int height = 0; | 40 int height = 0; |
| 40 int x = 0; | 41 int x = 0; |
| 41 int y = 0; | 42 int y = 0; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 // static | 231 // static |
| 231 void DisplayInfo::SetUse125DSFForUIScalingForTest(bool enable) { | 232 void DisplayInfo::SetUse125DSFForUIScalingForTest(bool enable) { |
| 232 use_125_dsf_for_ui_scaling = enable; | 233 use_125_dsf_for_ui_scaling = enable; |
| 233 } | 234 } |
| 234 | 235 |
| 235 DisplayInfo::DisplayInfo() | 236 DisplayInfo::DisplayInfo() |
| 236 : id_(gfx::Display::kInvalidDisplayID), | 237 : id_(gfx::Display::kInvalidDisplayID), |
| 237 has_overscan_(false), | 238 has_overscan_(false), |
| 238 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), | 239 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), |
| 239 device_scale_factor_(1.0f), | 240 device_scale_factor_(1.0f), |
| 241 device_dpi_(kDpi96), |
| 240 overscan_insets_in_dip_(0, 0, 0, 0), | 242 overscan_insets_in_dip_(0, 0, 0, 0), |
| 241 configured_ui_scale_(1.0f), | 243 configured_ui_scale_(1.0f), |
| 242 native_(false), | 244 native_(false), |
| 243 is_aspect_preserving_scaling_(false), | 245 is_aspect_preserving_scaling_(false), |
| 244 clear_overscan_insets_(false), | 246 clear_overscan_insets_(false), |
| 245 color_profile_(ui::COLOR_PROFILE_STANDARD) { | 247 color_profile_(ui::COLOR_PROFILE_STANDARD) { |
| 246 } | 248 } |
| 247 | 249 |
| 248 DisplayInfo::DisplayInfo(int64 id, | 250 DisplayInfo::DisplayInfo(int64 id, |
| 249 const std::string& name, | 251 const std::string& name, |
| 250 bool has_overscan) | 252 bool has_overscan) |
| 251 : id_(id), | 253 : id_(id), |
| 252 name_(name), | 254 name_(name), |
| 253 has_overscan_(has_overscan), | 255 has_overscan_(has_overscan), |
| 254 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), | 256 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), |
| 255 device_scale_factor_(1.0f), | 257 device_scale_factor_(1.0f), |
| 258 device_dpi_(kDpi96), |
| 256 overscan_insets_in_dip_(0, 0, 0, 0), | 259 overscan_insets_in_dip_(0, 0, 0, 0), |
| 257 configured_ui_scale_(1.0f), | 260 configured_ui_scale_(1.0f), |
| 258 native_(false), | 261 native_(false), |
| 259 is_aspect_preserving_scaling_(false), | 262 is_aspect_preserving_scaling_(false), |
| 260 clear_overscan_insets_(false), | 263 clear_overscan_insets_(false), |
| 261 color_profile_(ui::COLOR_PROFILE_STANDARD) { | 264 color_profile_(ui::COLOR_PROFILE_STANDARD) { |
| 262 } | 265 } |
| 263 | 266 |
| 264 DisplayInfo::~DisplayInfo() { | 267 DisplayInfo::~DisplayInfo() { |
| 265 } | 268 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 284 void DisplayInfo::Copy(const DisplayInfo& native_info) { | 287 void DisplayInfo::Copy(const DisplayInfo& native_info) { |
| 285 DCHECK(id_ == native_info.id_); | 288 DCHECK(id_ == native_info.id_); |
| 286 name_ = native_info.name_; | 289 name_ = native_info.name_; |
| 287 has_overscan_ = native_info.has_overscan_; | 290 has_overscan_ = native_info.has_overscan_; |
| 288 | 291 |
| 289 touch_support_ = native_info.touch_support_; | 292 touch_support_ = native_info.touch_support_; |
| 290 input_devices_ = native_info.input_devices_; | 293 input_devices_ = native_info.input_devices_; |
| 291 device_scale_factor_ = native_info.device_scale_factor_; | 294 device_scale_factor_ = native_info.device_scale_factor_; |
| 292 DCHECK(!native_info.bounds_in_native_.IsEmpty()); | 295 DCHECK(!native_info.bounds_in_native_.IsEmpty()); |
| 293 bounds_in_native_ = native_info.bounds_in_native_; | 296 bounds_in_native_ = native_info.bounds_in_native_; |
| 297 device_dpi_ = native_info.device_dpi_; |
| 294 size_in_pixel_ = native_info.size_in_pixel_; | 298 size_in_pixel_ = native_info.size_in_pixel_; |
| 295 is_aspect_preserving_scaling_ = native_info.is_aspect_preserving_scaling_; | 299 is_aspect_preserving_scaling_ = native_info.is_aspect_preserving_scaling_; |
| 296 display_modes_ = native_info.display_modes_; | 300 display_modes_ = native_info.display_modes_; |
| 297 available_color_profiles_ = native_info.available_color_profiles_; | 301 available_color_profiles_ = native_info.available_color_profiles_; |
| 298 | 302 |
| 299 // Rotation, ui_scale, color_profile and overscan are given by preference, | 303 // Rotation, ui_scale, color_profile and overscan are given by preference, |
| 300 // or unit tests. Don't copy if this native_info came from | 304 // or unit tests. Don't copy if this native_info came from |
| 301 // DisplayChangeObserver. | 305 // DisplayChangeObserver. |
| 302 if (!native_info.native()) { | 306 if (!native_info.native()) { |
| 303 // Update the overscan_insets_in_dip_ either if the inset should be | 307 // Update the overscan_insets_in_dip_ either if the inset should be |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 449 |
| 446 void DisplayInfo::ClearInputDevices() { | 450 void DisplayInfo::ClearInputDevices() { |
| 447 input_devices_.clear(); | 451 input_devices_.clear(); |
| 448 } | 452 } |
| 449 | 453 |
| 450 void ResetDisplayIdForTest() { | 454 void ResetDisplayIdForTest() { |
| 451 synthesized_display_id = kSynthesizedDisplayIdStart; | 455 synthesized_display_id = kSynthesizedDisplayIdStart; |
| 452 } | 456 } |
| 453 | 457 |
| 454 } // namespace ash | 458 } // namespace ash |
| OLD | NEW |