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 "ui/display/manager/managed_display_info.h" | 5 #include "ui/display/manager/managed_display_info.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 namespace display { | 27 namespace display { |
28 namespace { | 28 namespace { |
29 | 29 |
30 // Use larger than max int to catch overflow early. | 30 // Use larger than max int to catch overflow early. |
31 const int64_t kSynthesizedDisplayIdStart = 2200000000LL; | 31 const int64_t kSynthesizedDisplayIdStart = 2200000000LL; |
32 | 32 |
33 int64_t synthesized_display_id = kSynthesizedDisplayIdStart; | 33 int64_t synthesized_display_id = kSynthesizedDisplayIdStart; |
34 | 34 |
35 const float kDpi96 = 96.0; | 35 const float kDpi96 = 96.0; |
36 bool use_125_dsf_for_ui_scaling = true; | |
37 | 36 |
38 // Check the content of |spec| and fill |bounds| and |device_scale_factor|. | 37 // Check the content of |spec| and fill |bounds| and |device_scale_factor|. |
39 // Returns true when |bounds| is found. | 38 // Returns true when |bounds| is found. |
40 bool GetDisplayBounds(const std::string& spec, | 39 bool GetDisplayBounds(const std::string& spec, |
41 gfx::Rect* bounds, | 40 gfx::Rect* bounds, |
42 float* device_scale_factor) { | 41 float* device_scale_factor) { |
43 int width = 0; | 42 int width = 0; |
44 int height = 0; | 43 int height = 0; |
45 int x = 0; | 44 int x = 0; |
46 int y = 0; | 45 int y = 0; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 is_interlaced_(is_interlaced), | 138 is_interlaced_(is_interlaced), |
140 native_(native), | 139 native_(native), |
141 ui_scale_(ui_scale), | 140 ui_scale_(ui_scale), |
142 device_scale_factor_(device_scale_factor) {} | 141 device_scale_factor_(device_scale_factor) {} |
143 | 142 |
144 gfx::Size ManagedDisplayMode::GetSizeInDIP(bool is_internal) const { | 143 gfx::Size ManagedDisplayMode::GetSizeInDIP(bool is_internal) const { |
145 gfx::SizeF size_dip(size_); | 144 gfx::SizeF size_dip(size_); |
146 size_dip.Scale(ui_scale_); | 145 size_dip.Scale(ui_scale_); |
147 // DSF=1.25 is special on internal display. The screen is drawn with DSF=1.25 | 146 // DSF=1.25 is special on internal display. The screen is drawn with DSF=1.25 |
148 // but it doesn't affect the screen size computation. | 147 // but it doesn't affect the screen size computation. |
149 if (use_125_dsf_for_ui_scaling && is_internal && | 148 if (is_internal && device_scale_factor_ == 1.25f) |
150 device_scale_factor_ == 1.25f) | |
151 return gfx::ToFlooredSize(size_dip); | 149 return gfx::ToFlooredSize(size_dip); |
152 size_dip.Scale(1.0f / device_scale_factor_); | 150 size_dip.Scale(1.0f / device_scale_factor_); |
153 return gfx::ToFlooredSize(size_dip); | 151 return gfx::ToFlooredSize(size_dip); |
154 } | 152 } |
155 | 153 |
156 bool ManagedDisplayMode::IsEquivalent( | 154 bool ManagedDisplayMode::IsEquivalent( |
157 const scoped_refptr<ManagedDisplayMode>& other) const { | 155 const scoped_refptr<ManagedDisplayMode>& other) const { |
158 const float kEpsilon = 0.0001f; | 156 const float kEpsilon = 0.0001f; |
159 return size_ == other->size_ && | 157 return size_ == other->size_ && |
160 std::abs(ui_scale_ - other->ui_scale_) < kEpsilon && | 158 std::abs(ui_scale_ - other->ui_scale_) < kEpsilon && |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 int height = bounds_in_native.height() / device_scale_factor / 40; | 285 int height = bounds_in_native.height() / device_scale_factor / 40; |
288 display_info.SetOverscanInsets(gfx::Insets(height, width, height, width)); | 286 display_info.SetOverscanInsets(gfx::Insets(height, width, height, width)); |
289 display_info.UpdateDisplaySize(); | 287 display_info.UpdateDisplaySize(); |
290 } | 288 } |
291 | 289 |
292 DVLOG(1) << "DisplayInfoFromSpec info=" << display_info.ToString() | 290 DVLOG(1) << "DisplayInfoFromSpec info=" << display_info.ToString() |
293 << ", spec=" << spec; | 291 << ", spec=" << spec; |
294 return display_info; | 292 return display_info; |
295 } | 293 } |
296 | 294 |
297 // static | |
298 void ManagedDisplayInfo::SetUse125DSFForUIScalingForTest(bool enable) { | |
299 use_125_dsf_for_ui_scaling = enable; | |
300 } | |
301 | |
302 ManagedDisplayInfo::ManagedDisplayInfo() | 295 ManagedDisplayInfo::ManagedDisplayInfo() |
303 : id_(kInvalidDisplayId), | 296 : id_(kInvalidDisplayId), |
304 has_overscan_(false), | 297 has_overscan_(false), |
305 active_rotation_source_(Display::ROTATION_SOURCE_UNKNOWN), | 298 active_rotation_source_(Display::ROTATION_SOURCE_UNKNOWN), |
306 touch_support_(Display::TOUCH_SUPPORT_UNKNOWN), | 299 touch_support_(Display::TOUCH_SUPPORT_UNKNOWN), |
307 has_touch_calibration_data_(false), | 300 has_touch_calibration_data_(false), |
308 device_scale_factor_(1.0f), | 301 device_scale_factor_(1.0f), |
309 device_dpi_(kDpi96), | 302 device_dpi_(kDpi96), |
310 overscan_insets_in_dip_(0, 0, 0, 0), | 303 overscan_insets_in_dip_(0, 0, 0, 0), |
311 configured_ui_scale_(1.0f), | 304 configured_ui_scale_(1.0f), |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 if (IsColorProfileAvailable(profile)) | 497 if (IsColorProfileAvailable(profile)) |
505 color_profile_ = profile; | 498 color_profile_ = profile; |
506 } | 499 } |
507 | 500 |
508 bool ManagedDisplayInfo::IsColorProfileAvailable( | 501 bool ManagedDisplayInfo::IsColorProfileAvailable( |
509 ColorCalibrationProfile profile) const { | 502 ColorCalibrationProfile profile) const { |
510 return base::ContainsValue(available_color_profiles_, profile); | 503 return base::ContainsValue(available_color_profiles_, profile); |
511 } | 504 } |
512 | 505 |
513 bool ManagedDisplayInfo::Use125DSFForUIScaling() const { | 506 bool ManagedDisplayInfo::Use125DSFForUIScaling() const { |
514 return use_125_dsf_for_ui_scaling && Display::IsInternalDisplayId(id_); | 507 return Display::IsInternalDisplayId(id_); |
515 } | 508 } |
516 | 509 |
517 void ManagedDisplayInfo::AddInputDevice(int id) { | 510 void ManagedDisplayInfo::AddInputDevice(int id) { |
518 input_devices_.push_back(id); | 511 input_devices_.push_back(id); |
519 } | 512 } |
520 | 513 |
521 void ManagedDisplayInfo::ClearInputDevices() { | 514 void ManagedDisplayInfo::ClearInputDevices() { |
522 input_devices_.clear(); | 515 input_devices_.clear(); |
523 } | 516 } |
524 | 517 |
525 void ResetDisplayIdForTest() { | 518 void ResetDisplayIdForTest() { |
526 synthesized_display_id = kSynthesizedDisplayIdStart; | 519 synthesized_display_id = kSynthesizedDisplayIdStart; |
527 } | 520 } |
528 | 521 |
529 void ManagedDisplayInfo::SetTouchCalibrationData( | 522 void ManagedDisplayInfo::SetTouchCalibrationData( |
530 const TouchCalibrationData& touch_calibration_data) { | 523 const TouchCalibrationData& touch_calibration_data) { |
531 has_touch_calibration_data_ = true; | 524 has_touch_calibration_data_ = true; |
532 touch_calibration_data_ = touch_calibration_data; | 525 touch_calibration_data_ = touch_calibration_data; |
533 } | 526 } |
534 | 527 |
535 } // namespace display | 528 } // namespace display |
OLD | NEW |