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 } | |
247 | 248 |
248 DisplayInfo::DisplayInfo(int64 id, | 249 DisplayInfo::DisplayInfo(int64 id, const std::string& name, bool has_overscan) |
249 const std::string& name, | |
250 bool has_overscan) | |
251 : id_(id), | 250 : id_(id), |
252 name_(name), | 251 name_(name), |
253 has_overscan_(has_overscan), | 252 has_overscan_(has_overscan), |
254 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), | 253 touch_support_(gfx::Display::TOUCH_SUPPORT_UNKNOWN), |
255 device_scale_factor_(1.0f), | 254 device_scale_factor_(1.0f), |
| 255 device_dpi_(kDpi96), |
256 overscan_insets_in_dip_(0, 0, 0, 0), | 256 overscan_insets_in_dip_(0, 0, 0, 0), |
257 configured_ui_scale_(1.0f), | 257 configured_ui_scale_(1.0f), |
258 native_(false), | 258 native_(false), |
259 is_aspect_preserving_scaling_(false), | 259 is_aspect_preserving_scaling_(false), |
260 clear_overscan_insets_(false), | 260 clear_overscan_insets_(false), |
261 color_profile_(ui::COLOR_PROFILE_STANDARD) { | 261 color_profile_(ui::COLOR_PROFILE_STANDARD) {} |
262 } | |
263 | 262 |
264 DisplayInfo::~DisplayInfo() { | 263 DisplayInfo::~DisplayInfo() { |
265 } | 264 } |
266 | 265 |
267 void DisplayInfo::SetRotation(gfx::Display::Rotation rotation, | 266 void DisplayInfo::SetRotation(gfx::Display::Rotation rotation, |
268 gfx::Display::RotationSource source) { | 267 gfx::Display::RotationSource source) { |
269 rotations_[source] = rotation; | 268 rotations_[source] = rotation; |
270 rotations_[gfx::Display::ROTATION_SOURCE_ACTIVE] = rotation; | 269 rotations_[gfx::Display::ROTATION_SOURCE_ACTIVE] = rotation; |
271 } | 270 } |
272 | 271 |
(...skipping 11 matching lines...) Expand all Loading... |
284 void DisplayInfo::Copy(const DisplayInfo& native_info) { | 283 void DisplayInfo::Copy(const DisplayInfo& native_info) { |
285 DCHECK(id_ == native_info.id_); | 284 DCHECK(id_ == native_info.id_); |
286 name_ = native_info.name_; | 285 name_ = native_info.name_; |
287 has_overscan_ = native_info.has_overscan_; | 286 has_overscan_ = native_info.has_overscan_; |
288 | 287 |
289 touch_support_ = native_info.touch_support_; | 288 touch_support_ = native_info.touch_support_; |
290 input_devices_ = native_info.input_devices_; | 289 input_devices_ = native_info.input_devices_; |
291 device_scale_factor_ = native_info.device_scale_factor_; | 290 device_scale_factor_ = native_info.device_scale_factor_; |
292 DCHECK(!native_info.bounds_in_native_.IsEmpty()); | 291 DCHECK(!native_info.bounds_in_native_.IsEmpty()); |
293 bounds_in_native_ = native_info.bounds_in_native_; | 292 bounds_in_native_ = native_info.bounds_in_native_; |
| 293 device_dpi_ = native_info.device_dpi_; |
294 size_in_pixel_ = native_info.size_in_pixel_; | 294 size_in_pixel_ = native_info.size_in_pixel_; |
295 is_aspect_preserving_scaling_ = native_info.is_aspect_preserving_scaling_; | 295 is_aspect_preserving_scaling_ = native_info.is_aspect_preserving_scaling_; |
296 display_modes_ = native_info.display_modes_; | 296 display_modes_ = native_info.display_modes_; |
297 available_color_profiles_ = native_info.available_color_profiles_; | 297 available_color_profiles_ = native_info.available_color_profiles_; |
298 | 298 |
299 // Rotation, ui_scale, color_profile and overscan are given by preference, | 299 // Rotation, ui_scale, color_profile and overscan are given by preference, |
300 // or unit tests. Don't copy if this native_info came from | 300 // or unit tests. Don't copy if this native_info came from |
301 // DisplayChangeObserver. | 301 // DisplayChangeObserver. |
302 if (!native_info.native()) { | 302 if (!native_info.native()) { |
303 // Update the overscan_insets_in_dip_ either if the inset should be | 303 // 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 | 445 |
446 void DisplayInfo::ClearInputDevices() { | 446 void DisplayInfo::ClearInputDevices() { |
447 input_devices_.clear(); | 447 input_devices_.clear(); |
448 } | 448 } |
449 | 449 |
450 void ResetDisplayIdForTest() { | 450 void ResetDisplayIdForTest() { |
451 synthesized_display_id = kSynthesizedDisplayIdStart; | 451 synthesized_display_id = kSynthesizedDisplayIdStart; |
452 } | 452 } |
453 | 453 |
454 } // namespace ash | 454 } // namespace ash |
OLD | NEW |