| 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 <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 const scoped_refptr<display::ManagedDisplayMode>& other) const { | 132 const scoped_refptr<display::ManagedDisplayMode>& other) const { |
| 133 const float kEpsilon = 0.0001f; | 133 const float kEpsilon = 0.0001f; |
| 134 return size_ == other->size_ && | 134 return size_ == other->size_ && |
| 135 std::abs(ui_scale_ - other->ui_scale_) < kEpsilon && | 135 std::abs(ui_scale_ - other->ui_scale_) < kEpsilon && |
| 136 std::abs(device_scale_factor_ - other->device_scale_factor_) < | 136 std::abs(device_scale_factor_ - other->device_scale_factor_) < |
| 137 kEpsilon; | 137 kEpsilon; |
| 138 } | 138 } |
| 139 | 139 |
| 140 // static | 140 // static |
| 141 ManagedDisplayInfo ManagedDisplayInfo::CreateFromSpec(const std::string& spec) { | 141 ManagedDisplayInfo ManagedDisplayInfo::CreateFromSpec(const std::string& spec) { |
| 142 return CreateFromSpecWithID(spec, display::Display::kInvalidDisplayID); | 142 return CreateFromSpecWithID(spec, kInvalidDisplayId); |
| 143 } | 143 } |
| 144 | 144 |
| 145 // static | 145 // static |
| 146 ManagedDisplayInfo ManagedDisplayInfo::CreateFromSpecWithID( | 146 ManagedDisplayInfo ManagedDisplayInfo::CreateFromSpecWithID( |
| 147 const std::string& spec, | 147 const std::string& spec, |
| 148 int64_t id) { | 148 int64_t id) { |
| 149 #if defined(OS_WIN) | 149 #if defined(OS_WIN) |
| 150 gfx::Rect bounds_in_native( | 150 gfx::Rect bounds_in_native( |
| 151 gfx::Size(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN))); | 151 gfx::Size(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN))); |
| 152 #else | 152 #else |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 new ManagedDisplayMode(size, refresh_rate, is_interlaced, false, | 239 new ManagedDisplayMode(size, refresh_rate, is_interlaced, false, |
| 240 1.0, device_scale_factor))); | 240 1.0, device_scale_factor))); |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 scoped_refptr<display::ManagedDisplayMode> dm = display_modes[native_mode]; | 243 scoped_refptr<display::ManagedDisplayMode> dm = display_modes[native_mode]; |
| 244 display_modes[native_mode] = new ManagedDisplayMode( | 244 display_modes[native_mode] = new ManagedDisplayMode( |
| 245 dm->size(), dm->refresh_rate(), dm->is_interlaced(), true, | 245 dm->size(), dm->refresh_rate(), dm->is_interlaced(), true, |
| 246 dm->ui_scale(), dm->device_scale_factor()); | 246 dm->ui_scale(), dm->device_scale_factor()); |
| 247 } | 247 } |
| 248 | 248 |
| 249 if (id == display::Display::kInvalidDisplayID) | 249 if (id == kInvalidDisplayId) |
| 250 id = synthesized_display_id++; | 250 id = synthesized_display_id++; |
| 251 display::ManagedDisplayInfo display_info( | 251 display::ManagedDisplayInfo display_info( |
| 252 id, base::StringPrintf("Display-%d", static_cast<int>(id)), has_overscan); | 252 id, base::StringPrintf("Display-%d", static_cast<int>(id)), has_overscan); |
| 253 display_info.set_device_scale_factor(device_scale_factor); | 253 display_info.set_device_scale_factor(device_scale_factor); |
| 254 display_info.SetRotation(rotation, display::Display::ROTATION_SOURCE_ACTIVE); | 254 display_info.SetRotation(rotation, display::Display::ROTATION_SOURCE_ACTIVE); |
| 255 display_info.set_configured_ui_scale(ui_scale); | 255 display_info.set_configured_ui_scale(ui_scale); |
| 256 display_info.SetBounds(bounds_in_native); | 256 display_info.SetBounds(bounds_in_native); |
| 257 display_info.SetManagedDisplayModes(display_modes); | 257 display_info.SetManagedDisplayModes(display_modes); |
| 258 | 258 |
| 259 // To test the overscan, it creates the default 5% overscan. | 259 // To test the overscan, it creates the default 5% overscan. |
| 260 if (has_overscan) { | 260 if (has_overscan) { |
| 261 int width = bounds_in_native.width() / device_scale_factor / 40; | 261 int width = bounds_in_native.width() / device_scale_factor / 40; |
| 262 int height = bounds_in_native.height() / device_scale_factor / 40; | 262 int height = bounds_in_native.height() / device_scale_factor / 40; |
| 263 display_info.SetOverscanInsets(gfx::Insets(height, width, height, width)); | 263 display_info.SetOverscanInsets(gfx::Insets(height, width, height, width)); |
| 264 display_info.UpdateDisplaySize(); | 264 display_info.UpdateDisplaySize(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 DVLOG(1) << "DisplayInfoFromSpec info=" << display_info.ToString() | 267 DVLOG(1) << "DisplayInfoFromSpec info=" << display_info.ToString() |
| 268 << ", spec=" << spec; | 268 << ", spec=" << spec; |
| 269 return display_info; | 269 return display_info; |
| 270 } | 270 } |
| 271 | 271 |
| 272 // static | 272 // static |
| 273 void ManagedDisplayInfo::SetUse125DSFForUIScalingForTest(bool enable) { | 273 void ManagedDisplayInfo::SetUse125DSFForUIScalingForTest(bool enable) { |
| 274 use_125_dsf_for_ui_scaling = enable; | 274 use_125_dsf_for_ui_scaling = enable; |
| 275 } | 275 } |
| 276 | 276 |
| 277 ManagedDisplayInfo::ManagedDisplayInfo() | 277 ManagedDisplayInfo::ManagedDisplayInfo() |
| 278 : id_(display::Display::kInvalidDisplayID), | 278 : id_(kInvalidDisplayId), |
| 279 has_overscan_(false), | 279 has_overscan_(false), |
| 280 active_rotation_source_(display::Display::ROTATION_SOURCE_UNKNOWN), | 280 active_rotation_source_(display::Display::ROTATION_SOURCE_UNKNOWN), |
| 281 touch_support_(display::Display::TOUCH_SUPPORT_UNKNOWN), | 281 touch_support_(display::Display::TOUCH_SUPPORT_UNKNOWN), |
| 282 device_scale_factor_(1.0f), | 282 device_scale_factor_(1.0f), |
| 283 device_dpi_(kDpi96), | 283 device_dpi_(kDpi96), |
| 284 overscan_insets_in_dip_(0, 0, 0, 0), | 284 overscan_insets_in_dip_(0, 0, 0, 0), |
| 285 configured_ui_scale_(1.0f), | 285 configured_ui_scale_(1.0f), |
| 286 native_(false), | 286 native_(false), |
| 287 is_aspect_preserving_scaling_(false), | 287 is_aspect_preserving_scaling_(false), |
| 288 clear_overscan_insets_(false), | 288 clear_overscan_insets_(false), |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 494 |
| 495 void ManagedDisplayInfo::ClearInputDevices() { | 495 void ManagedDisplayInfo::ClearInputDevices() { |
| 496 input_devices_.clear(); | 496 input_devices_.clear(); |
| 497 } | 497 } |
| 498 | 498 |
| 499 void ResetDisplayIdForTest() { | 499 void ResetDisplayIdForTest() { |
| 500 synthesized_display_id = kSynthesizedDisplayIdStart; | 500 synthesized_display_id = kSynthesizedDisplayIdStart; |
| 501 } | 501 } |
| 502 | 502 |
| 503 } // namespace display | 503 } // namespace display |
| OLD | NEW |