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 "ash/common/display/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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "ui/display/display.h" | 18 #include "ui/display/display.h" |
19 #include "ui/gfx/geometry/size_conversions.h" | 19 #include "ui/gfx/geometry/size_conversions.h" |
20 #include "ui/gfx/geometry/size_f.h" | 20 #include "ui/gfx/geometry/size_f.h" |
21 | 21 |
22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
23 #include <windows.h> | 23 #include <windows.h> |
24 #include "ui/display/win/dpi.h" | 24 #include "ui/display/win/dpi.h" |
25 #endif | 25 #endif |
26 | 26 |
27 namespace ash { | 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; | 36 bool use_125_dsf_for_ui_scaling = true; |
37 | 37 |
(...skipping 16 matching lines...) Expand all Loading... |
54 return false; | 54 return false; |
55 } | 55 } |
56 | 56 |
57 // Display mode list is sorted by: | 57 // Display mode list is sorted by: |
58 // * the area in pixels in ascending order | 58 // * the area in pixels in ascending order |
59 // * refresh rate in descending order | 59 // * refresh rate in descending order |
60 struct ManagedDisplayModeSorter { | 60 struct ManagedDisplayModeSorter { |
61 explicit ManagedDisplayModeSorter(bool is_internal) | 61 explicit ManagedDisplayModeSorter(bool is_internal) |
62 : is_internal(is_internal) {} | 62 : is_internal(is_internal) {} |
63 | 63 |
64 bool operator()(const scoped_refptr<ManagedDisplayMode>& a, | 64 bool operator()(const scoped_refptr<display::ManagedDisplayMode>& a, |
65 const scoped_refptr<ManagedDisplayMode>& b) { | 65 const scoped_refptr<display::ManagedDisplayMode>& b) { |
66 gfx::Size size_a_dip = a->GetSizeInDIP(is_internal); | 66 gfx::Size size_a_dip = a->GetSizeInDIP(is_internal); |
67 gfx::Size size_b_dip = b->GetSizeInDIP(is_internal); | 67 gfx::Size size_b_dip = b->GetSizeInDIP(is_internal); |
68 if (size_a_dip.GetArea() == size_b_dip.GetArea()) | 68 if (size_a_dip.GetArea() == size_b_dip.GetArea()) |
69 return (a->refresh_rate() > b->refresh_rate()); | 69 return (a->refresh_rate() > b->refresh_rate()); |
70 return (size_a_dip.GetArea() < size_b_dip.GetArea()); | 70 return (size_a_dip.GetArea() < size_b_dip.GetArea()); |
71 } | 71 } |
72 | 72 |
73 bool is_internal; | 73 bool is_internal; |
74 }; | 74 }; |
75 | 75 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // DSF=1.25 is special on internal display. The screen is drawn with DSF=1.25 | 122 // DSF=1.25 is special on internal display. The screen is drawn with DSF=1.25 |
123 // but it doesn't affect the screen size computation. | 123 // but it doesn't affect the screen size computation. |
124 if (use_125_dsf_for_ui_scaling && is_internal && | 124 if (use_125_dsf_for_ui_scaling && is_internal && |
125 device_scale_factor_ == 1.25f) | 125 device_scale_factor_ == 1.25f) |
126 return gfx::ToFlooredSize(size_dip); | 126 return gfx::ToFlooredSize(size_dip); |
127 size_dip.Scale(1.0f / device_scale_factor_); | 127 size_dip.Scale(1.0f / device_scale_factor_); |
128 return gfx::ToFlooredSize(size_dip); | 128 return gfx::ToFlooredSize(size_dip); |
129 } | 129 } |
130 | 130 |
131 bool ManagedDisplayMode::IsEquivalent( | 131 bool ManagedDisplayMode::IsEquivalent( |
132 const scoped_refptr<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 DisplayInfo DisplayInfo::CreateFromSpec(const std::string& spec) { | 141 ManagedDisplayInfo ManagedDisplayInfo::CreateFromSpec(const std::string& spec) { |
142 return CreateFromSpecWithID(spec, display::Display::kInvalidDisplayID); | 142 return CreateFromSpecWithID(spec, display::Display::kInvalidDisplayID); |
143 } | 143 } |
144 | 144 |
145 // static | 145 // static |
146 DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, | 146 ManagedDisplayInfo ManagedDisplayInfo::CreateFromSpecWithID( |
147 int64_t id) { | 147 const std::string& spec, |
| 148 int64_t id) { |
148 #if defined(OS_WIN) | 149 #if defined(OS_WIN) |
149 gfx::Rect bounds_in_native( | 150 gfx::Rect bounds_in_native( |
150 gfx::Size(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN))); | 151 gfx::Size(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN))); |
151 #else | 152 #else |
152 // Default bounds for a display. | 153 // Default bounds for a display. |
153 const int kDefaultHostWindowX = 200; | 154 const int kDefaultHostWindowX = 200; |
154 const int kDefaultHostWindowY = 200; | 155 const int kDefaultHostWindowY = 200; |
155 const int kDefaultHostWindowWidth = 1366; | 156 const int kDefaultHostWindowWidth = 1366; |
156 const int kDefaultHostWindowHeight = 768; | 157 const int kDefaultHostWindowHeight = 768; |
157 gfx::Rect bounds_in_native(kDefaultHostWindowX, kDefaultHostWindowY, | 158 gfx::Rect bounds_in_native(kDefaultHostWindowX, kDefaultHostWindowY, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // Use mode with largest area and highest refresh rate as native. | 233 // Use mode with largest area and highest refresh rate as native. |
233 largest_area = size.GetArea(); | 234 largest_area = size.GetArea(); |
234 highest_refresh_rate = refresh_rate; | 235 highest_refresh_rate = refresh_rate; |
235 native_mode = i; | 236 native_mode = i; |
236 } | 237 } |
237 display_modes.push_back(make_scoped_refptr( | 238 display_modes.push_back(make_scoped_refptr( |
238 new ManagedDisplayMode(size, refresh_rate, is_interlaced, false, | 239 new ManagedDisplayMode(size, refresh_rate, is_interlaced, false, |
239 1.0, device_scale_factor))); | 240 1.0, device_scale_factor))); |
240 } | 241 } |
241 } | 242 } |
242 scoped_refptr<ManagedDisplayMode> dm = display_modes[native_mode]; | 243 scoped_refptr<display::ManagedDisplayMode> dm = display_modes[native_mode]; |
243 display_modes[native_mode] = new ManagedDisplayMode( | 244 display_modes[native_mode] = new ManagedDisplayMode( |
244 dm->size(), dm->refresh_rate(), dm->is_interlaced(), true, | 245 dm->size(), dm->refresh_rate(), dm->is_interlaced(), true, |
245 dm->ui_scale(), dm->device_scale_factor()); | 246 dm->ui_scale(), dm->device_scale_factor()); |
246 } | 247 } |
247 | 248 |
248 if (id == display::Display::kInvalidDisplayID) | 249 if (id == display::Display::kInvalidDisplayID) |
249 id = synthesized_display_id++; | 250 id = synthesized_display_id++; |
250 DisplayInfo display_info( | 251 display::ManagedDisplayInfo display_info( |
251 id, base::StringPrintf("Display-%d", static_cast<int>(id)), has_overscan); | 252 id, base::StringPrintf("Display-%d", static_cast<int>(id)), has_overscan); |
252 display_info.set_device_scale_factor(device_scale_factor); | 253 display_info.set_device_scale_factor(device_scale_factor); |
253 display_info.SetRotation(rotation, display::Display::ROTATION_SOURCE_ACTIVE); | 254 display_info.SetRotation(rotation, display::Display::ROTATION_SOURCE_ACTIVE); |
254 display_info.set_configured_ui_scale(ui_scale); | 255 display_info.set_configured_ui_scale(ui_scale); |
255 display_info.SetBounds(bounds_in_native); | 256 display_info.SetBounds(bounds_in_native); |
256 display_info.SetManagedDisplayModes(display_modes); | 257 display_info.SetManagedDisplayModes(display_modes); |
257 | 258 |
258 // To test the overscan, it creates the default 5% overscan. | 259 // To test the overscan, it creates the default 5% overscan. |
259 if (has_overscan) { | 260 if (has_overscan) { |
260 int width = bounds_in_native.width() / device_scale_factor / 40; | 261 int width = bounds_in_native.width() / device_scale_factor / 40; |
261 int height = bounds_in_native.height() / device_scale_factor / 40; | 262 int height = bounds_in_native.height() / device_scale_factor / 40; |
262 display_info.SetOverscanInsets(gfx::Insets(height, width, height, width)); | 263 display_info.SetOverscanInsets(gfx::Insets(height, width, height, width)); |
263 display_info.UpdateDisplaySize(); | 264 display_info.UpdateDisplaySize(); |
264 } | 265 } |
265 | 266 |
266 DVLOG(1) << "DisplayInfoFromSpec info=" << display_info.ToString() | 267 DVLOG(1) << "DisplayInfoFromSpec info=" << display_info.ToString() |
267 << ", spec=" << spec; | 268 << ", spec=" << spec; |
268 return display_info; | 269 return display_info; |
269 } | 270 } |
270 | 271 |
271 // static | 272 // static |
272 void DisplayInfo::SetUse125DSFForUIScalingForTest(bool enable) { | 273 void ManagedDisplayInfo::SetUse125DSFForUIScalingForTest(bool enable) { |
273 use_125_dsf_for_ui_scaling = enable; | 274 use_125_dsf_for_ui_scaling = enable; |
274 } | 275 } |
275 | 276 |
276 DisplayInfo::DisplayInfo() | 277 ManagedDisplayInfo::ManagedDisplayInfo() |
277 : id_(display::Display::kInvalidDisplayID), | 278 : id_(display::Display::kInvalidDisplayID), |
278 has_overscan_(false), | 279 has_overscan_(false), |
279 active_rotation_source_(display::Display::ROTATION_SOURCE_UNKNOWN), | 280 active_rotation_source_(display::Display::ROTATION_SOURCE_UNKNOWN), |
280 touch_support_(display::Display::TOUCH_SUPPORT_UNKNOWN), | 281 touch_support_(display::Display::TOUCH_SUPPORT_UNKNOWN), |
281 device_scale_factor_(1.0f), | 282 device_scale_factor_(1.0f), |
282 device_dpi_(kDpi96), | 283 device_dpi_(kDpi96), |
283 overscan_insets_in_dip_(0, 0, 0, 0), | 284 overscan_insets_in_dip_(0, 0, 0, 0), |
284 configured_ui_scale_(1.0f), | 285 configured_ui_scale_(1.0f), |
285 native_(false), | 286 native_(false), |
286 is_aspect_preserving_scaling_(false), | 287 is_aspect_preserving_scaling_(false), |
287 clear_overscan_insets_(false), | 288 clear_overscan_insets_(false), |
288 color_profile_(ui::COLOR_PROFILE_STANDARD) {} | 289 color_profile_(ui::COLOR_PROFILE_STANDARD) {} |
289 | 290 |
290 DisplayInfo::DisplayInfo(int64_t id, const std::string& name, bool has_overscan) | 291 ManagedDisplayInfo::ManagedDisplayInfo(int64_t id, |
| 292 const std::string& name, |
| 293 bool has_overscan) |
291 : id_(id), | 294 : id_(id), |
292 name_(name), | 295 name_(name), |
293 has_overscan_(has_overscan), | 296 has_overscan_(has_overscan), |
294 active_rotation_source_(display::Display::ROTATION_SOURCE_UNKNOWN), | 297 active_rotation_source_(display::Display::ROTATION_SOURCE_UNKNOWN), |
295 touch_support_(display::Display::TOUCH_SUPPORT_UNKNOWN), | 298 touch_support_(display::Display::TOUCH_SUPPORT_UNKNOWN), |
296 device_scale_factor_(1.0f), | 299 device_scale_factor_(1.0f), |
297 device_dpi_(kDpi96), | 300 device_dpi_(kDpi96), |
298 overscan_insets_in_dip_(0, 0, 0, 0), | 301 overscan_insets_in_dip_(0, 0, 0, 0), |
299 configured_ui_scale_(1.0f), | 302 configured_ui_scale_(1.0f), |
300 native_(false), | 303 native_(false), |
301 is_aspect_preserving_scaling_(false), | 304 is_aspect_preserving_scaling_(false), |
302 clear_overscan_insets_(false), | 305 clear_overscan_insets_(false), |
303 color_profile_(ui::COLOR_PROFILE_STANDARD) {} | 306 color_profile_(ui::COLOR_PROFILE_STANDARD) {} |
304 | 307 |
305 DisplayInfo::DisplayInfo(const DisplayInfo& other) = default; | 308 ManagedDisplayInfo::ManagedDisplayInfo(const ManagedDisplayInfo& other) = |
| 309 default; |
306 | 310 |
307 DisplayInfo::~DisplayInfo() {} | 311 ManagedDisplayInfo::~ManagedDisplayInfo() {} |
308 | 312 |
309 void DisplayInfo::SetRotation(display::Display::Rotation rotation, | 313 void ManagedDisplayInfo::SetRotation(display::Display::Rotation rotation, |
310 display::Display::RotationSource source) { | 314 display::Display::RotationSource source) { |
311 rotations_[source] = rotation; | 315 rotations_[source] = rotation; |
312 rotations_[display::Display::ROTATION_SOURCE_ACTIVE] = rotation; | 316 rotations_[display::Display::ROTATION_SOURCE_ACTIVE] = rotation; |
313 active_rotation_source_ = source; | 317 active_rotation_source_ = source; |
314 } | 318 } |
315 | 319 |
316 display::Display::Rotation DisplayInfo::GetActiveRotation() const { | 320 display::Display::Rotation ManagedDisplayInfo::GetActiveRotation() const { |
317 return GetRotation(display::Display::ROTATION_SOURCE_ACTIVE); | 321 return GetRotation(display::Display::ROTATION_SOURCE_ACTIVE); |
318 } | 322 } |
319 | 323 |
320 display::Display::Rotation DisplayInfo::GetRotation( | 324 display::Display::Rotation ManagedDisplayInfo::GetRotation( |
321 display::Display::RotationSource source) const { | 325 display::Display::RotationSource source) const { |
322 if (rotations_.find(source) == rotations_.end()) | 326 if (rotations_.find(source) == rotations_.end()) |
323 return display::Display::ROTATE_0; | 327 return display::Display::ROTATE_0; |
324 return rotations_.at(source); | 328 return rotations_.at(source); |
325 } | 329 } |
326 | 330 |
327 void DisplayInfo::Copy(const DisplayInfo& native_info) { | 331 void ManagedDisplayInfo::Copy(const ManagedDisplayInfo& native_info) { |
328 DCHECK(id_ == native_info.id_); | 332 DCHECK(id_ == native_info.id_); |
329 name_ = native_info.name_; | 333 name_ = native_info.name_; |
330 has_overscan_ = native_info.has_overscan_; | 334 has_overscan_ = native_info.has_overscan_; |
331 | 335 |
332 active_rotation_source_ = native_info.active_rotation_source_; | 336 active_rotation_source_ = native_info.active_rotation_source_; |
333 touch_support_ = native_info.touch_support_; | 337 touch_support_ = native_info.touch_support_; |
334 input_devices_ = native_info.input_devices_; | 338 input_devices_ = native_info.input_devices_; |
335 device_scale_factor_ = native_info.device_scale_factor_; | 339 device_scale_factor_ = native_info.device_scale_factor_; |
336 DCHECK(!native_info.bounds_in_native_.IsEmpty()); | 340 DCHECK(!native_info.bounds_in_native_.IsEmpty()); |
337 bounds_in_native_ = native_info.bounds_in_native_; | 341 bounds_in_native_ = native_info.bounds_in_native_; |
(...skipping 14 matching lines...) Expand all Loading... |
352 overscan_insets_in_dip_.Set(0, 0, 0, 0); | 356 overscan_insets_in_dip_.Set(0, 0, 0, 0); |
353 else if (!native_info.overscan_insets_in_dip_.IsEmpty()) | 357 else if (!native_info.overscan_insets_in_dip_.IsEmpty()) |
354 overscan_insets_in_dip_ = native_info.overscan_insets_in_dip_; | 358 overscan_insets_in_dip_ = native_info.overscan_insets_in_dip_; |
355 | 359 |
356 rotations_ = native_info.rotations_; | 360 rotations_ = native_info.rotations_; |
357 configured_ui_scale_ = native_info.configured_ui_scale_; | 361 configured_ui_scale_ = native_info.configured_ui_scale_; |
358 color_profile_ = native_info.color_profile(); | 362 color_profile_ = native_info.color_profile(); |
359 } | 363 } |
360 } | 364 } |
361 | 365 |
362 void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_native) { | 366 void ManagedDisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_native) { |
363 bounds_in_native_ = new_bounds_in_native; | 367 bounds_in_native_ = new_bounds_in_native; |
364 size_in_pixel_ = new_bounds_in_native.size(); | 368 size_in_pixel_ = new_bounds_in_native.size(); |
365 UpdateDisplaySize(); | 369 UpdateDisplaySize(); |
366 } | 370 } |
367 | 371 |
368 float DisplayInfo::GetEffectiveDeviceScaleFactor() const { | 372 float ManagedDisplayInfo::GetEffectiveDeviceScaleFactor() const { |
369 if (Use125DSFForUIScaling() && device_scale_factor_ == 1.25f) | 373 if (Use125DSFForUIScaling() && device_scale_factor_ == 1.25f) |
370 return (configured_ui_scale_ == 0.8f) ? 1.25f : 1.0f; | 374 return (configured_ui_scale_ == 0.8f) ? 1.25f : 1.0f; |
371 if (device_scale_factor_ == configured_ui_scale_) | 375 if (device_scale_factor_ == configured_ui_scale_) |
372 return 1.0f; | 376 return 1.0f; |
373 return device_scale_factor_; | 377 return device_scale_factor_; |
374 } | 378 } |
375 | 379 |
376 float DisplayInfo::GetEffectiveUIScale() const { | 380 float ManagedDisplayInfo::GetEffectiveUIScale() const { |
377 if (Use125DSFForUIScaling() && device_scale_factor_ == 1.25f) | 381 if (Use125DSFForUIScaling() && device_scale_factor_ == 1.25f) |
378 return (configured_ui_scale_ == 0.8f) ? 1.0f : configured_ui_scale_; | 382 return (configured_ui_scale_ == 0.8f) ? 1.0f : configured_ui_scale_; |
379 if (device_scale_factor_ == configured_ui_scale_) | 383 if (device_scale_factor_ == configured_ui_scale_) |
380 return 1.0f; | 384 return 1.0f; |
381 return configured_ui_scale_; | 385 return configured_ui_scale_; |
382 } | 386 } |
383 | 387 |
384 void DisplayInfo::UpdateDisplaySize() { | 388 void ManagedDisplayInfo::UpdateDisplaySize() { |
385 size_in_pixel_ = bounds_in_native_.size(); | 389 size_in_pixel_ = bounds_in_native_.size(); |
386 if (!overscan_insets_in_dip_.IsEmpty()) { | 390 if (!overscan_insets_in_dip_.IsEmpty()) { |
387 gfx::Insets insets_in_pixel = | 391 gfx::Insets insets_in_pixel = |
388 overscan_insets_in_dip_.Scale(device_scale_factor_); | 392 overscan_insets_in_dip_.Scale(device_scale_factor_); |
389 size_in_pixel_.Enlarge(-insets_in_pixel.width(), -insets_in_pixel.height()); | 393 size_in_pixel_.Enlarge(-insets_in_pixel.width(), -insets_in_pixel.height()); |
390 } else { | 394 } else { |
391 overscan_insets_in_dip_.Set(0, 0, 0, 0); | 395 overscan_insets_in_dip_.Set(0, 0, 0, 0); |
392 } | 396 } |
393 | 397 |
394 if (GetActiveRotation() == display::Display::ROTATE_90 || | 398 if (GetActiveRotation() == display::Display::ROTATE_90 || |
395 GetActiveRotation() == display::Display::ROTATE_270) { | 399 GetActiveRotation() == display::Display::ROTATE_270) { |
396 size_in_pixel_.SetSize(size_in_pixel_.height(), size_in_pixel_.width()); | 400 size_in_pixel_.SetSize(size_in_pixel_.height(), size_in_pixel_.width()); |
397 } | 401 } |
398 gfx::SizeF size_f(size_in_pixel_); | 402 gfx::SizeF size_f(size_in_pixel_); |
399 size_f.Scale(GetEffectiveUIScale()); | 403 size_f.Scale(GetEffectiveUIScale()); |
400 size_in_pixel_ = gfx::ToFlooredSize(size_f); | 404 size_in_pixel_ = gfx::ToFlooredSize(size_f); |
401 } | 405 } |
402 | 406 |
403 void DisplayInfo::SetOverscanInsets(const gfx::Insets& insets_in_dip) { | 407 void ManagedDisplayInfo::SetOverscanInsets(const gfx::Insets& insets_in_dip) { |
404 overscan_insets_in_dip_ = insets_in_dip; | 408 overscan_insets_in_dip_ = insets_in_dip; |
405 } | 409 } |
406 | 410 |
407 gfx::Insets DisplayInfo::GetOverscanInsetsInPixel() const { | 411 gfx::Insets ManagedDisplayInfo::GetOverscanInsetsInPixel() const { |
408 return overscan_insets_in_dip_.Scale(device_scale_factor_); | 412 return overscan_insets_in_dip_.Scale(device_scale_factor_); |
409 } | 413 } |
410 | 414 |
411 void DisplayInfo::SetManagedDisplayModes( | 415 void ManagedDisplayInfo::SetManagedDisplayModes( |
412 const ManagedDisplayModeList& display_modes) { | 416 const ManagedDisplayModeList& display_modes) { |
413 display_modes_ = display_modes; | 417 display_modes_ = display_modes; |
414 std::sort( | 418 std::sort( |
415 display_modes_.begin(), display_modes_.end(), | 419 display_modes_.begin(), display_modes_.end(), |
416 ManagedDisplayModeSorter(display::Display::IsInternalDisplayId(id_))); | 420 ManagedDisplayModeSorter(display::Display::IsInternalDisplayId(id_))); |
417 } | 421 } |
418 | 422 |
419 gfx::Size DisplayInfo::GetNativeModeSize() const { | 423 gfx::Size ManagedDisplayInfo::GetNativeModeSize() const { |
420 for (size_t i = 0; i < display_modes_.size(); ++i) { | 424 for (size_t i = 0; i < display_modes_.size(); ++i) { |
421 if (display_modes_[i]->native()) | 425 if (display_modes_[i]->native()) |
422 return display_modes_[i]->size(); | 426 return display_modes_[i]->size(); |
423 } | 427 } |
424 return gfx::Size(); | 428 return gfx::Size(); |
425 } | 429 } |
426 | 430 |
427 std::string DisplayInfo::ToString() const { | 431 std::string ManagedDisplayInfo::ToString() const { |
428 int rotation_degree = static_cast<int>(GetActiveRotation()) * 90; | 432 int rotation_degree = static_cast<int>(GetActiveRotation()) * 90; |
429 std::string devices_str; | 433 std::string devices_str; |
430 | 434 |
431 for (size_t i = 0; i < input_devices_.size(); ++i) { | 435 for (size_t i = 0; i < input_devices_.size(); ++i) { |
432 devices_str += base::IntToString(input_devices_[i]); | 436 devices_str += base::IntToString(input_devices_[i]); |
433 if (i != input_devices_.size() - 1) | 437 if (i != input_devices_.size() - 1) |
434 devices_str += ", "; | 438 devices_str += ", "; |
435 } | 439 } |
436 | 440 |
437 std::string result = base::StringPrintf( | 441 std::string result = base::StringPrintf( |
438 "DisplayInfo[%lld] native bounds=%s, size=%s, scale=%f, " | 442 "ManagedDisplayInfo[%lld] native bounds=%s, size=%s, scale=%f, " |
439 "overscan=%s, rotation=%d, ui-scale=%f, touchscreen=%s, " | 443 "overscan=%s, rotation=%d, ui-scale=%f, touchscreen=%s, " |
440 "input_devices=[%s]", | 444 "input_devices=[%s]", |
441 static_cast<long long int>(id_), bounds_in_native_.ToString().c_str(), | 445 static_cast<long long int>(id_), bounds_in_native_.ToString().c_str(), |
442 size_in_pixel_.ToString().c_str(), device_scale_factor_, | 446 size_in_pixel_.ToString().c_str(), device_scale_factor_, |
443 overscan_insets_in_dip_.ToString().c_str(), rotation_degree, | 447 overscan_insets_in_dip_.ToString().c_str(), rotation_degree, |
444 configured_ui_scale_, | 448 configured_ui_scale_, |
445 touch_support_ == display::Display::TOUCH_SUPPORT_AVAILABLE | 449 touch_support_ == display::Display::TOUCH_SUPPORT_AVAILABLE |
446 ? "yes" | 450 ? "yes" |
447 : touch_support_ == display::Display::TOUCH_SUPPORT_UNAVAILABLE | 451 : touch_support_ == display::Display::TOUCH_SUPPORT_UNAVAILABLE |
448 ? "no" | 452 ? "no" |
449 : "unknown", | 453 : "unknown", |
450 devices_str.c_str()); | 454 devices_str.c_str()); |
451 | 455 |
452 return result; | 456 return result; |
453 } | 457 } |
454 | 458 |
455 std::string DisplayInfo::ToFullString() const { | 459 std::string ManagedDisplayInfo::ToFullString() const { |
456 std::string display_modes_str; | 460 std::string display_modes_str; |
457 ManagedDisplayModeList::const_iterator iter = display_modes_.begin(); | 461 ManagedDisplayModeList::const_iterator iter = display_modes_.begin(); |
458 for (; iter != display_modes_.end(); ++iter) { | 462 for (; iter != display_modes_.end(); ++iter) { |
459 scoped_refptr<ManagedDisplayMode> m(*iter); | 463 scoped_refptr<ManagedDisplayMode> m(*iter); |
460 if (!display_modes_str.empty()) | 464 if (!display_modes_str.empty()) |
461 display_modes_str += ","; | 465 display_modes_str += ","; |
462 base::StringAppendF(&display_modes_str, "(%dx%d@%f%c%s)", m->size().width(), | 466 base::StringAppendF(&display_modes_str, "(%dx%d@%f%c%s)", m->size().width(), |
463 m->size().height(), m->refresh_rate(), | 467 m->size().height(), m->refresh_rate(), |
464 m->is_interlaced() ? 'I' : 'P', | 468 m->is_interlaced() ? 'I' : 'P', |
465 m->native() ? "(N)" : ""); | 469 m->native() ? "(N)" : ""); |
466 } | 470 } |
467 return ToString() + ", display_modes==" + display_modes_str; | 471 return ToString() + ", display_modes==" + display_modes_str; |
468 } | 472 } |
469 | 473 |
470 void DisplayInfo::SetColorProfile(ui::ColorCalibrationProfile profile) { | 474 void ManagedDisplayInfo::SetColorProfile(ui::ColorCalibrationProfile profile) { |
471 if (IsColorProfileAvailable(profile)) | 475 if (IsColorProfileAvailable(profile)) |
472 color_profile_ = profile; | 476 color_profile_ = profile; |
473 } | 477 } |
474 | 478 |
475 bool DisplayInfo::IsColorProfileAvailable( | 479 bool ManagedDisplayInfo::IsColorProfileAvailable( |
476 ui::ColorCalibrationProfile profile) const { | 480 ui::ColorCalibrationProfile profile) const { |
477 return std::find(available_color_profiles_.begin(), | 481 return std::find(available_color_profiles_.begin(), |
478 available_color_profiles_.end(), | 482 available_color_profiles_.end(), |
479 profile) != available_color_profiles_.end(); | 483 profile) != available_color_profiles_.end(); |
480 } | 484 } |
481 | 485 |
482 bool DisplayInfo::Use125DSFForUIScaling() const { | 486 bool ManagedDisplayInfo::Use125DSFForUIScaling() const { |
483 return use_125_dsf_for_ui_scaling && | 487 return use_125_dsf_for_ui_scaling && |
484 display::Display::IsInternalDisplayId(id_); | 488 display::Display::IsInternalDisplayId(id_); |
485 } | 489 } |
486 | 490 |
487 void DisplayInfo::AddInputDevice(int id) { | 491 void ManagedDisplayInfo::AddInputDevice(int id) { |
488 input_devices_.push_back(id); | 492 input_devices_.push_back(id); |
489 } | 493 } |
490 | 494 |
491 void DisplayInfo::ClearInputDevices() { | 495 void ManagedDisplayInfo::ClearInputDevices() { |
492 input_devices_.clear(); | 496 input_devices_.clear(); |
493 } | 497 } |
494 | 498 |
495 void ResetDisplayIdForTest() { | 499 void ResetDisplayIdForTest() { |
496 synthesized_display_id = kSynthesizedDisplayIdStart; | 500 synthesized_display_id = kSynthesizedDisplayIdStart; |
497 } | 501 } |
498 | 502 |
499 } // namespace ash | 503 } // namespace display |
OLD | NEW |